Debian Codegraph @

src/dr/evomodel/coalescent/ConstantLogisticModel.java

raw symbols SCIP
1 /*
2 * ConstantLogisticModel.java
3 *
4 * Copyright (c) 2002-2015 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.coalescent;
27
28 import dr.evolution.coalescent.ConstLogistic;
29 import dr.evolution.coalescent.DemographicFunction;
30 import dr.evomodelxml.coalescent.ConstantLogisticModelParser;
31 import dr.inference.model.Parameter;
32 import dr.util.Author;
33 import dr.util.Citable;
34 import dr.util.Citation;
35
36 import java.util.Collections;
37 import java.util.List;
38
39 /**
40 * Logistic growth from a constant ancestral population size.
41 *
42 * @author Alexei Drummond
43 * @author Andrew Rambaut
44 * @version $Id: ConstantLogisticModel.java,v 1.7 2005/04/11 11:24:39 alexei Exp $
45 */
46 public class ConstantLogisticModel extends DemographicModel implements Citable {
47
48 //
49 // Public stuff
50 //
51
52 /**
53 * Construct demographic model with default settings
54 */
55 public ConstantLogisticModel(Parameter N0Parameter, Parameter N1Parameter, Parameter growthRateParameter, Parameter shapeParameter, double alpha, Type units) {
56
57 this(ConstantLogisticModelParser.CONSTANT_LOGISTIC_MODEL, N0Parameter, N1Parameter, growthRateParameter, shapeParameter, alpha, units);
58 }
59
60 /**
61 * Construct demographic model with default settings
62 */
63 private ConstantLogisticModel(String name, Parameter N0Parameter, Parameter N1Parameter, Parameter growthRateParameter, Parameter shapeParameter, double alpha, Type units) {
64
65 super(name);
66
67 constLogistic = new ConstLogistic(units);
68
69 this.N0Parameter = N0Parameter;
70 addVariable(N0Parameter);
71 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
72
73 this.N1Parameter = N1Parameter;
74 addVariable(N1Parameter);
75 N1Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
76
77 this.growthRateParameter = growthRateParameter;
78 addVariable(growthRateParameter);
79 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
80
81 this.shapeParameter = shapeParameter;
82 addVariable(shapeParameter);
83 shapeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
84
85 this.alpha = alpha;
86
87 setUnits(units);
88 }
89
90
91 // general functions
92
93 public DemographicFunction getDemographicFunction() {
94 constLogistic.setN0(N0Parameter.getParameterValue(0));
95 constLogistic.setN1(N1Parameter.getParameterValue(0));
96
97 double r = growthRateParameter.getParameterValue(0);
98 constLogistic.setGrowthRate(r);
99
100 // AER 24/02/03
101 // logisticGrowth.setShape(Math.exp(shapeParameter.getParameterValue(0)));
102
103 // New parameterization of logistic shape to be the time at which the
104 // population reached some proportion alpha:
105 double C = ((1.0 - alpha) * Math.exp(-r * shapeParameter.getParameterValue(0))) / alpha;
106 constLogistic.setShape(C);
107
108 return constLogistic;
109 }
110
111 //
112 // protected stuff
113 //
114
115 private Parameter N0Parameter = null;
116 private Parameter N1Parameter = null;
117 private Parameter growthRateParameter = null;
118 private Parameter shapeParameter = null;
119 private double alpha = 0.5;
120 private ConstLogistic constLogistic = null;
121
122 @Override
123 public Citation.Category getCategory() {
124 return Citation.Category.TREE_PRIORS;
125 }
126
127 @Override
128 public String getDescription() {
129 return "Constant-Logistic Coalescent";
130 }
131
132 @Override
133 public List<Citation> getCitations() {
134 return Collections.singletonList(CITATION);
135 }
136
137 public static Citation CITATION = new Citation(
138 new Author[]{
139 new Author("OG", "Pybus"),
140 new Author("A", "Rambaut")
141 },
142 "GENIE: estimating demographic history from molecular phylogenies",
143 2001,
144 "Bioinformatics",
145 18, 1404, 1405
146 );
147 }