| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.inference.operators.hmc.deprecated; |
| 27 |
|
| 28 |
import dr.evomodel.continuous.FullyConjugateMultivariateTraitLikelihood; |
| 29 |
import dr.inference.operators.AdaptationMode; |
| 30 |
import dr.inference.model.LatentFactorModel; |
| 31 |
import dr.xml.*; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
@Deprecated |
| 37 |
public class LatentFactorHamiltonianMCParser extends AbstractXMLObjectParser { |
| 38 |
public static final String LATENT_FACTOR_MODEL_HAMILTONIAN_MC="LatentFactorHamiltonianMC"; |
| 39 |
public static final String WEIGHT="weight"; |
| 40 |
public static final String N_STEPS="nSteps"; |
| 41 |
public static final String STEP_SIZE="stepSize"; |
| 42 |
public static final String MOMENTUM_SD="momentumSd"; |
| 43 |
@Override |
| 44 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 45 |
LatentFactorModel lfm=(LatentFactorModel) xo.getChild(LatentFactorModel.class); |
| 46 |
FullyConjugateMultivariateTraitLikelihood tree=(FullyConjugateMultivariateTraitLikelihood) xo.getChild(FullyConjugateMultivariateTraitLikelihood.class); |
| 47 |
double weight=xo.getDoubleAttribute(WEIGHT); |
| 48 |
AdaptationMode mode= AdaptationMode.parseMode(xo); |
| 49 |
int nSteps=xo.getIntegerAttribute(N_STEPS); |
| 50 |
double stepSize=xo.getDoubleAttribute(STEP_SIZE); |
| 51 |
double momentumSd= xo.getDoubleAttribute(MOMENTUM_SD); |
| 52 |
|
| 53 |
|
| 54 |
return new LatentFactorHamiltonianMC(lfm, tree, weight, mode, stepSize, nSteps, momentumSd); |
| 55 |
|
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
@Override |
| 60 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 61 |
return rules; |
| 62 |
} |
| 63 |
|
| 64 |
private static final XMLSyntaxRule[] rules = { |
| 65 |
AttributeRule.newDoubleRule(WEIGHT), |
| 66 |
AttributeRule.newDoubleRule(STEP_SIZE), |
| 67 |
AttributeRule.newIntegerRule(N_STEPS), |
| 68 |
AttributeRule.newDoubleRule(MOMENTUM_SD), |
| 69 |
new ElementRule(LatentFactorModel.class), |
| 70 |
new ElementRule(FullyConjugateMultivariateTraitLikelihood.class), |
| 71 |
}; |
| 72 |
|
| 73 |
@Override |
| 74 |
public String getParserDescription() { |
| 75 |
return "Hamiltonian Monte Carlo For factors"; |
| 76 |
} |
| 77 |
|
| 78 |
@Override |
| 79 |
public Class getReturnType() { |
| 80 |
return LatentFactorHamiltonianMC.class; |
| 81 |
} |
| 82 |
|
| 83 |
@Override |
| 84 |
public String getParserName() { |
| 85 |
return LATENT_FACTOR_MODEL_HAMILTONIAN_MC; |
| 86 |
} |
| 87 |
} |