Debian Codegraph @

src/dr/evomodel/alloppnet/operators/AlloppHybPopSizesScale.java

raw symbols SCIP
1 /*
2 * AlloppHybPopSizesScale.java
3 *
4 * Copyright (c) 2002-2017 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.evomodel.alloppnet.operators;
27
28 import dr.evomodel.alloppnet.speciation.AlloppSpeciesBindings;
29 import dr.evomodel.alloppnet.speciation.AlloppSpeciesNetworkModel;
30 import dr.evomodel.alloppnet.parsers.AlloppHybPopSizesScaleParser;
31 import dr.inference.operators.SimpleMCMCOperator;
32 import dr.math.MathUtils;
33
34 /**
35 * @author Graham Jones
36 * Date: 03/08/12
37 */
38 public class AlloppHybPopSizesScale extends SimpleMCMCOperator {
39
40 private final AlloppSpeciesNetworkModel apspnet;
41 private final AlloppSpeciesBindings apsp;
42 private final double scalingFactor;
43
44 public AlloppHybPopSizesScale(AlloppSpeciesNetworkModel apspnet, AlloppSpeciesBindings apsp, double scalingFactor, double weight) {
45 this.apspnet = apspnet;
46 this.apsp = apsp;
47 this.scalingFactor = scalingFactor;
48 setWeight(weight);
49 }
50
51
52 public String getPerformanceSuggestion() {
53 return "None";
54 }
55
56 @Override
57 public String getOperatorName() {
58 return AlloppHybPopSizesScaleParser.HYB_POP_SIZES_SCALE + "(" + apspnet.getId() +
59 "," + apsp.getId() + ")";
60 }
61
62 @Override
63 public double doOperation() {
64 apspnet.beginNetworkEdit();
65 double b = (1.0-scalingFactor) * (1.0-scalingFactor) / scalingFactor;
66 double c = scalingFactor / (1.0-scalingFactor);
67 double y = MathUtils.nextDouble();
68 double s = b * (y+c) * (y+c);
69 int i = MathUtils.nextInt(apspnet.getNumberOfTetraTrees());
70 apspnet.setOneHybPopValue(i, s * apspnet.getOneHybPopValue(i));
71 apspnet.endNetworkEdit();
72 return 0.0; // this way of scaling, with proposal proportional to x^-(1/2) has hastings ratio 1
73 }
74
75 }