本文整理汇总了Java中beast.core.State.initialise方法的典型用法代码示例。如果您正苦于以下问题:Java State.initialise方法的具体用法?Java State.initialise怎么用?Java State.initialise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.core.State
的用法示例。
在下文中一共展示了State.initialise方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRates
import beast.core.State; //导入方法依赖的package包/类
@Test
public void testRates() throws Exception {
initializeTree();
meanRateParameter = new RealParameter();
stdevParameter = new RealParameter();
branchRatesParameter = new IntegerParameter();
meanRateParameter.initByName("value", String.valueOf(meanRate));
stdevParameter.initByName("value", String.valueOf(1.0));
branchRatesParameter.initByName("value", String.valueOf(initialBranchRate));
// Create dummy state to allow statenode editing
State state = new State();
state.initByName("stateNode", meanRateParameter);
state.initByName("stateNode", branchRatesParameter);
state.initialise();
clockModel = new UncorrelatedRates();
clockModel.initByName("tree", testTree, "rates", branchRatesParameter, "stdev", stdevParameter, "estimateRoot", false, "clock.rate", meanRateParameter);
initializeRates();
checkRates();
}
示例2: testCanOperate
import beast.core.State; //导入方法依赖的package包/类
@Test
public void testCanOperate() {
// Test whether a validly initialised operator may make proposals
State state = new State();
RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. });
state.initByName("stateNode", parameter);
state.initialise();
DeltaExchangeOperator d = new DeltaExchangeOperator();
// An invalid operator should either fail in initByName or make valid
// proposals
try {
d.initByName("parameter", parameter);
} catch (RuntimeException e) {
return;
}
d.proposal();
}
示例3: testDDPointer
import beast.core.State; //导入方法依赖的package包/类
public void testDDPointer(){
try{
for(Instance test: tests){
test.setup();
DPPointer pointer = test.getDPPointer();
ParameterList paramList = test.getParameterList();
State state = new State();
state.initByName(
"stateNode", pointer,
"stateNode", paramList
);
state.initialise();
operationEx1(pointer,paramList);
}
}catch(Exception e){
throw new RuntimeException(e);
}
}
示例4: testRates
import beast.core.State; //导入方法依赖的package包/类
@Test
public void testRates() throws Exception {
testTree = new TreeParser();
testTree.initByName("newick", newickTree, "IsLabelledNewick", true);
// Create dummy state to allow statenode editing
State state = new State();
state.initialise();
treeLengthLogger = new TreeLengthLogger();
treeLengthLogger.initByName("tree", testTree);
final double computedLength = treeLengthLogger.getArrayValue();
assertEquals(expectedLength, computedLength, allowedError);
}
示例5: testRates
import beast.core.State; //导入方法依赖的package包/类
@Test
public void testRates() throws Exception {
TaxonSet speciesSuperSet = generateSuperset();
initializeTrees(speciesSuperSet);
meanRateParameter = new RealParameter();
stdevParameter = new RealParameter();
branchRatesParameter = new IntegerParameter();
meanRateParameter.initByName("value", String.valueOf(meanRate));
stdevParameter.initByName("value", String.valueOf(1.0));
branchRatesParameter.initByName("value", String.valueOf(initialBranchRate));
// Create dummy state to allow statenode editing
State state = new State();
state.initByName("stateNode", meanRateParameter);
state.initByName("stateNode", branchRatesParameter);
state.initialise();
speciesTreeClock = new UncorrelatedRates();
speciesTreeClock.initByName("tree", speciesTree, "rates", branchRatesParameter, "stdev", stdevParameter, "estimateRoot", true);
initializeRates();
geneTreeClock = new StarBeastClock();
geneTreeClock.initByName("geneTree", geneTreeWrapper, "speciesTreeRates", speciesTreeClock, "clock.rate", meanRateParameter);
checkRates();
}
示例6: register
import beast.core.State; //导入方法依赖的package包/类
static public void register(Operator operator, final Object... operands) {
HashMap<String, StateNode> operandsMap;
operandsMap = new HashMap<String, StateNode>();
if (operands.length % 2 == 1) {
throw new RuntimeException("Expected even number of arguments, name-value pairs");
}
for (int i = 0; i < operands.length; i += 2) {
if (operands[i] instanceof String) {
final String name = (String) operands[i];
if (operands[i + 1] instanceof StateNode) {
final StateNode node = (StateNode) operands[i + 1];
operandsMap.put(name, node);
} else {
throw new IllegalArgumentException("Expected a StateNode in " + (i + 1) + "th argument ");
}
} else {
throw new IllegalArgumentException("Expected a String in " + i + "th argument ");
}
}
State state = new State();
state.initByName("stateNode", new ArrayList<StateNode>(operandsMap.values()));
state.initialise();
Object[] operandsAndWeight = new Object[operands.length + 2];
for (int i = 0; i < operands.length; ++i) {
operandsAndWeight[i] = operands[i];
}
operandsAndWeight[operands.length] = "weight";
operandsAndWeight[operands.length + 1] = "1";
operator.initByName(operandsAndWeight);
operator.validateInputs();
}
示例7: testParameterBound
import beast.core.State; //导入方法依赖的package包/类
public void testParameterBound() {
try {
count = new int[dimension][4]; // 4 vaules {0, 1, 2, 3}
RealParameter parameter = new RealParameter(new Double[]{1.0, 0.0, 2.0});
parameter.setLower(0.0);
parameter.setUpper(3.0);
State state = new State();
state.initByName("stateNode", parameter);
state.initialise();
UniformOperator uniformOperator = new UniformOperator();
uniformOperator.initByName("parameter", parameter, "howMany", 3, "weight", 1.0);
for (int i = 0; i < 400; i++) {
uniformOperator.proposal();
Double [] values = parameter.getValues();
for (int k = 0; k < values.length; k++) {
int j = (int)(double) values[k];
count[k][j] += 1;
}
}
System.out.println("Discretized real distributions lower = 0.0, upper = 3.0");
for (int j = 0; j < count.length; j++) {
System.out.println("x[" +j + "] = " + Arrays.toString(count[j]));
}
assertTrue("Expected count[0][0-2] > 0 && count[0][3] == 0", (count[0][0] > 0) && (count[0][1] > 0) && (count[0][2] > 0) && (count[0][3] == 0));
assertTrue("Expected count[1][0-2] > 0 && count[1][3] == 0", (count[1][0] > 0) && (count[1][1] > 0) && (count[1][2] > 0) && (count[1][3] == 0));
assertTrue("Expected count[2][0-2] > 0 && count[2][3] == 0", (count[2][0] > 0) && (count[2][1] > 0) && (count[2][2] > 0) && (count[2][3] == 0));
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: testIntegerParameterBound
import beast.core.State; //导入方法依赖的package包/类
public void testIntegerParameterBound() {
try {
count = new int[dimension][4]; // 4 vaules {0, 1, 2, 3}
IntegerParameter parameter = new IntegerParameter(new Integer[]{1, 0, 3});
parameter.setLower(0);
parameter.setUpper(3);
State state = new State();
state.initByName("stateNode", parameter);
state.initialise();
UniformOperator uniformOperator = new UniformOperator();
uniformOperator.initByName("parameter", parameter, "howMany", 3, "weight", 1.0);
for (int i = 0; i < 400; i++) {
uniformOperator.proposal();
Integer [] values = parameter.getValues();
for (int k = 0; k < values.length; k++) {
int j = values[k];
count[k][j] += 1;
}
}
System.out.println("Integer distributions lower = 0, upper = 3");
for (int j = 0; j < count.length; j++) {
System.out.println("x[" +j + "] = " + Arrays.toString(count[j]));
}
assertTrue("Expected count[0][0-3] > 0", count[0][0] > 0 && count[0][1] > 0 && count[0][2] > 0 && count[0][3] > 0);
assertTrue("Expected count[1][0-3] > 0", count[1][0] > 0 && count[1][1] > 0 && count[1][2] > 0 && count[1][3] > 0);
assertTrue("Expected count[2][0-3] > 0", count[2][0] > 0 && count[2][1] > 0 && count[2][2] > 0 && count[2][3] > 0);
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: testLogHR
import beast.core.State; //导入方法依赖的package包/类
@Test
public void testLogHR() throws Exception {
TaxonSet speciesSuperSet = generateSuperset();
initializeSpeciesTree(speciesSuperSet);
initializeGeneTrees();
popsizeParameter = new RealParameter();
popsizeParameter.initByName("value", String.valueOf(popSize));
// Create dummy state to allow statenode editing
State state = new State();
state.initByName("stateNode", popsizeParameter);
for (Tree gt: geneTrees) {
state.initByName("stateNode", gt);
}
state.initialise();
populationModel = new ConstantPopulations();
populationModel.initByName("populationSizes", popsizeParameter, "speciesTree", speciesTreeWrapper);
int nBranches = speciesTreeWrapper.getNodeCount();
populationModel.initPopSizes(nBranches);
populationModel.initPopSizes(popSize);
Node cNode = null;
Node bNode = null;
for (Node n: speciesTreeWrapper.getRoot().getAllLeafNodes()) {
if (n.getID().equals(bTipLabel)) {
if (bIsParent) bNode = n.getParent();
else bNode = n;
} else if (n.getID().equals(cTipLabel)) {
if (cIsParent) cNode = n.getParent();
else cNode = n;
}
}
Node yNode = bNode.getParent();
Node zNode = yNode.getParent();
Node aNode = (bNode == yNode.getRight()) ? yNode.getLeft() : yNode.getRight();
if (cNode == null) {
cNode = (yNode == zNode.getRight()) ? zNode.getLeft() : zNode.getRight();
}
CoordinatedExchange coex = new CoordinatedExchange();
coex.initByName("speciesTree", speciesTreeWrapper, "geneTree", geneTrees, "testing", true, "weight", 1.0);
coex.aNode = aNode;
coex.bNode = bNode;
coex.cNode = cNode;
coex.yNode = yNode;
coex.zNode = zNode;
final double calculatedLogHR = coex.proposal();
assertEquals(expectedLogHR, calculatedLogHR, allowedError);
}
示例10: instantiate
import beast.core.State; //导入方法依赖的package包/类
public void instantiate(int dimension, int upper, int runs, Integer[]windowSizes) {
for (int r = 0; r < runs; r++) {
for (Integer windowSize : windowSizes) {
try {
int[][] count = new int[dimension][upper + 1];
Integer [] init = new Integer[dimension];
Arrays.fill(init, 0);
IntegerParameter parameter = new IntegerParameter(init);
parameter.setLower(0);
parameter.setUpper(upper);
State state = new State();
state.initByName("stateNode", parameter);
state.initialise();
IntRandomWalkOperator operator = new IntRandomWalkOperator();
operator.initByName("parameter", parameter, "windowSize", windowSize, "weight", 1.0);
for (int i = 0; i < 1000000 * (upper + 1); i++) {
operator.proposal();
Integer [] values = parameter.getValues();
for (int k = 0; k < values.length; k++) {
int j = values[k];
count[k][j] += 1;
}
}
System.out.print("Distribution lower = 0, upper = " + upper +" windowSize = " + windowSize);
for (int j = 0; j < count.length; j++) {
//System.out.println("x[" +j + "] = " + Arrays.toString(count[j]));
}
int sum = 0;
for (int i = 0; i < dimension; i++) {
for (int k = 0; k < count[i].length; k++) {
sum += Math.abs(count[i][k] - 1000000);
}
}
System.out.println(" Average deviation: " + sum/(dimension * (upper + 1)));
assertTrue("average deviation (" + sum/(dimension * (upper + 1)) + ") exceeds 10000", sum/(dimension * (upper + 1)) < 10000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}