Debian Codegraph @

src/dr/evomodel/epidemiology/LogisticGrowthN0Model.java

raw symbols SCIP
1 /*
2 * LogisticGrowthN0Model.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 /*
27 * LogisticGrowthN0Model.java
28 *
29 * Daniel Wilson 4th October 2011
30 *
31 */
32
33 package dr.evomodel.epidemiology;
34
35 import dr.evomodel.coalescent.*;
36 import dr.evolution.coalescent.DemographicFunction;
37 import dr.inference.model.Parameter;
38
39 /**
40 * Logistic growth.
41 *
42 * @version $Id: LogisticGrowthN0Model.java,v 1.21 2008/03/21 20:25:57 rambaut Exp $
43 *
44 * @author Daniel Wilson
45 * @author Alexei Drummond
46 * @author Andrew Rambaut
47 */
48 public class LogisticGrowthN0Model extends DemographicModel
49 {
50 //
51 // Public stuff
52 //
53
54 /**
55 * Construct demographic model with default settings
56 */
57 public LogisticGrowthN0Model(Parameter N0Parameter, Parameter growthRateParameter,
58 Parameter t50Parameter, Type units, boolean usingGrowthRate) {
59 this(LogisticGrowthN0ModelParser.LOGISTIC_GROWTH_MODEL, N0Parameter, growthRateParameter, t50Parameter, units, usingGrowthRate);
60 }
61
62 /**
63 * Construct demographic model with default settings
64 */
65 public LogisticGrowthN0Model(String name, Parameter N0Parameter, Parameter growthRateParameter, Parameter t50Parameter, Type units, boolean usingGrowthRate) {
66 super(name);
67
68 logisticGrowthN0 = new LogisticGrowthN0(units);
69
70 this.N0Parameter = N0Parameter;
71 addVariable(N0Parameter);
72 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
73
74 this.growthRateParameter = growthRateParameter;
75 addVariable(growthRateParameter);
76 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
77
78 this.t50Parameter = t50Parameter;
79 addVariable(t50Parameter);
80 t50Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
81
82 this.usingGrowthRate = usingGrowthRate;
83
84 setUnits(units);
85 }
86
87
88 // general functions
89
90 public DemographicFunction getDemographicFunction() {
91 logisticGrowthN0.setN0(N0Parameter.getParameterValue(0));
92 if (usingGrowthRate) {
93 double r = growthRateParameter.getParameterValue(0);
94 logisticGrowthN0.setGrowthRate(r);
95 } else {
96 double doublingTime = growthRateParameter.getParameterValue(0);
97 logisticGrowthN0.setDoublingTime(doublingTime);
98 }
99 logisticGrowthN0.setT50(t50Parameter.getParameterValue(0));
100
101 return logisticGrowthN0;
102 }
103
104 //
105 // protected stuff
106 //
107
108 Parameter N0Parameter = null;
109 Parameter growthRateParameter = null;
110 Parameter t50Parameter = null;
111 LogisticGrowthN0 logisticGrowthN0 = null;
112 boolean usingGrowthRate = true;
113 }