Debian Codegraph @

src/dr/evomodel/coalescent/TwoEpochDemographicModel.java

raw symbols SCIP
1 /*
2 * TwoEpochDemographicModel.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.TwoEpochDemographic;
30 import dr.evomodelxml.coalescent.TwoEpochDemographicModelParser;
31 import dr.inference.model.Parameter;
32
33 /**
34 * This class models an exponentially growing model that suffers a
35 * cataclysmic event and goes into exponential decline
36 * This model is nested with the constant-population size model (r=0).
37 *
38 * @author Alexei Drummond
39 * @author Andrew Rambaut
40 * @version $Id: TwoEpochDemographicModel.java,v 1.6 2005/05/24 20:25:57 rambaut Exp $
41 */
42 public class TwoEpochDemographicModel extends DemographicModel {
43 //
44 // Public stuff
45 //
46 /**
47 * Construct demographic model with default settings.
48 */
49 public TwoEpochDemographicModel(DemographicModel demo1, DemographicModel demo2, Parameter transitionTimeParameter, Type units) {
50
51 this(TwoEpochDemographicModelParser.TWO_EPOCH_MODEL, demo1, demo2, transitionTimeParameter, units);
52 }
53
54 /**
55 * Construct demographic model with default settings.
56 */
57 public TwoEpochDemographicModel(String name, DemographicModel demo1, DemographicModel demo2, Parameter transitionTimeParameter, Type units) {
58
59 super(name);
60
61 this.demo1 = demo1;
62 addModel(demo1);
63 for (int i = 0; i < demo1.getVariableCount(); i++) {
64 addVariable((Parameter) demo1.getVariable(i));
65 }
66
67 this.demo2 = demo2;
68 addModel(demo2);
69 for (int i = 0; i < demo2.getVariableCount(); i++) {
70 addVariable((Parameter) demo2.getVariable(i));
71 }
72
73 this.transitionTimeParameter = transitionTimeParameter;
74 addVariable(transitionTimeParameter);
75
76 setUnits(units);
77 }
78
79 // general functions
80
81 public DemographicFunction getDemographicFunction() {
82
83 TwoEpochDemographic twoEpoch = new TwoEpochDemographic(demo1.getDemographicFunction(), demo2.getDemographicFunction(), getUnits());
84 twoEpoch.setTransitionTime(transitionTimeParameter.getParameterValue(0));
85
86 return twoEpoch;
87 }
88
89 private Parameter transitionTimeParameter = null;
90 private DemographicModel demo1 = null;
91 private DemographicModel demo2 = null;
92 }