Debian Codegraph @

src/dr/inference/model/ProductParameter.java

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