Debian Codegraph @

src/dr/evomodel/branchmodel/lineagespecific/RatioParameter.java

raw symbols SCIP
1 /*
2 * RatioParameter.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.branchmodel.lineagespecific;
27
28 import java.util.List;
29
30 import dr.inference.model.Bounds;
31 import dr.inference.model.Parameter;
32 import dr.inference.model.Variable;
33 import dr.inference.model.VariableListener;
34
35 public class RatioParameter extends Parameter.Abstract implements
36 VariableListener {
37
38 private Parameter parameter1;
39 private Parameter parameter2;
40 private Bounds bounds = null;
41
42 public RatioParameter(Parameter parameter1, Parameter parameter2) {
43
44 this.parameter1 = parameter1;
45 this.parameter2 = parameter2;
46
47 this.parameter1.addVariableListener(this);
48 this.parameter2.addVariableListener(this);
49
50 }// END: Constructor
51
52 @Override
53 public double getParameterValue(int dim) {
54
55 double value = parameter1.getParameterValue(dim)
56 / parameter2.getParameterValue(dim);
57
58 return value;
59 }// END: getParameterValue
60
61 @Override
62 public void setParameterValue(int dim, double value) {
63 throw new RuntimeException("Not implemented");
64 }
65
66 @Override
67 public void setParameterValueQuietly(int dim, double value) {
68 throw new RuntimeException("Not implemented");
69 }
70
71 @Override
72 public void setParameterValueNotifyChangedAll(int dim, double value) {
73 throw new RuntimeException("Not implemented");
74 }
75
76 @Override
77 public String getParameterName() {
78 if (getId() == null) {
79
80 StringBuilder sb = new StringBuilder("ratio");
81 sb.append(parameter1.getId()).append(".")
82 .append(parameter2.getId());
83 setId(sb.toString());
84 }
85
86 return getId();
87 }// END: getParameterName
88
89 @Override
90 public void addBounds(Bounds<Double> bounds) {
91 this.bounds = bounds;
92 }
93
94 @Override
95 public Bounds<Double> getBounds() {
96 return bounds;
97 }
98
99 @Override
100 public void addDimension(int index, double value) {
101 throw new RuntimeException("Not yet implemented.");
102 }
103
104 @Override
105 public double removeDimension(int index) {
106 throw new RuntimeException("Not yet implemented.");
107 }
108
109 @Override
110 public void variableChangedEvent(Variable variable, int index,
111 dr.inference.model.Variable.ChangeType type) {
112 fireParameterChangedEvent(index, type);
113 }
114
115 @Override
116 protected void storeValues() {
117 parameter1.storeParameterValues();
118 parameter2.storeParameterValues();
119 }
120
121 @Override
122 protected void restoreValues() {
123 parameter1.restoreParameterValues();
124 parameter2.restoreParameterValues();
125 }
126
127 @Override
128 protected void acceptValues() {
129 parameter1.acceptParameterValues();
130 parameter2.acceptParameterValues();
131 }
132
133 @Override
134 protected void adoptValues(Parameter source) {
135 throw new RuntimeException("Not implemented");
136 }
137
138 }// END: class