Debian Codegraph @

src/dr/evomodel/coalescent/ExponentialSawtoothModel.java

raw symbols SCIP
1 /*
2 * ExponentialSawtoothModel.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.DemographicFunction;
29 import dr.evolution.coalescent.ExponentialSawtooth;
30 import dr.evomodelxml.coalescent.ExponentialSawtoothModelParser;
31 import dr.inference.model.Parameter;
32
33 /**
34 * @author Alexei Drummond
35 * @version $Id: ExponentialSawtoothModel.java,v 1.4 2005/04/11 11:24:39 alexei Exp $
36 */
37 public class ExponentialSawtoothModel extends DemographicModel {
38
39 //
40 // Public stuff
41 //
42 /**
43 * Construct demographic model with default settings
44 */
45 public ExponentialSawtoothModel(Parameter N0Parameter, Parameter growthRateParameter, Parameter wavelengthParameter, Parameter offsetParameter, Type units) {
46
47 this(ExponentialSawtoothModelParser.EXPONENTIAL_SAWTOOTH, N0Parameter, growthRateParameter, wavelengthParameter, offsetParameter, units);
48 }
49
50 /**
51 * Construct demographic model with default settings
52 */
53 public ExponentialSawtoothModel(String name, Parameter N0Parameter, Parameter growthRateParameter, Parameter wavelengthParameter, Parameter offsetParameter, Type units) {
54
55 super(name);
56
57 expSaw = new ExponentialSawtooth(units);
58
59 this.N0Parameter = N0Parameter;
60 addVariable(N0Parameter);
61 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.MIN_VALUE, 1));
62
63 this.growthRateParameter = growthRateParameter;
64 addVariable(growthRateParameter);
65 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, -Double.MAX_VALUE, 1));
66
67 this.wavelengthParameter = wavelengthParameter;
68 addVariable(wavelengthParameter);
69 wavelengthParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.MIN_VALUE, 1));
70
71 this.offsetParameter = offsetParameter;
72 addVariable(offsetParameter);
73 offsetParameter.addBounds(new Parameter.DefaultBounds(1.0, -1.0, 1));
74
75 setUnits(units);
76 }
77
78
79 // general functions
80
81 public DemographicFunction getDemographicFunction() {
82 expSaw.setN0(N0Parameter.getParameterValue(0));
83 expSaw.setGrowthRate(growthRateParameter.getParameterValue(0));
84 expSaw.setWavelength(wavelengthParameter.getParameterValue(0));
85
86 double offset = offsetParameter.getParameterValue(0);
87 if (offset < 0.0) {
88 offset += 1.0;
89 }
90 expSaw.setOffset(offset);
91
92 return expSaw;
93 }
94 //
95 // protected stuff
96 //
97
98 Parameter N0Parameter = null;
99 Parameter growthRateParameter = null;
100 Parameter wavelengthParameter = null;
101 Parameter offsetParameter = null;
102 ExponentialSawtooth expSaw = null;
103 }