| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.inference.model; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class ComplementParameter extends Parameter.Abstract implements VariableListener { |
| 32 |
|
| 33 |
public ComplementParameter(Parameter parameter) { |
| 34 |
this.parameter = parameter; |
| 35 |
|
| 36 |
parameter.addVariableListener(this); |
| 37 |
} |
| 38 |
|
| 39 |
public int getDimension() { |
| 40 |
return parameter.getDimension(); |
| 41 |
} |
| 42 |
|
| 43 |
protected void storeValues() { |
| 44 |
parameter.storeParameterValues(); |
| 45 |
} |
| 46 |
|
| 47 |
protected void restoreValues() { |
| 48 |
parameter.restoreParameterValues(); |
| 49 |
} |
| 50 |
|
| 51 |
protected void acceptValues() { |
| 52 |
parameter.acceptParameterValues(); |
| 53 |
} |
| 54 |
|
| 55 |
protected void adoptValues(Parameter source) { |
| 56 |
throw new RuntimeException("Not implemented"); |
| 57 |
} |
| 58 |
|
| 59 |
public double getParameterValue(int dim) { |
| 60 |
return 1.0 - parameter.getParameterValue(dim); |
| 61 |
} |
| 62 |
|
| 63 |
public void setParameterValue(int dim, double value) { |
| 64 |
throw new RuntimeException("Not implemented"); |
| 65 |
} |
| 66 |
|
| 67 |
public void setParameterValueQuietly(int dim, double value) { |
| 68 |
throw new RuntimeException("Not implemented"); |
| 69 |
} |
| 70 |
|
| 71 |
public void setParameterValueNotifyChangedAll(int dim, double value) { |
| 72 |
throw new RuntimeException("Not implemented"); |
| 73 |
} |
| 74 |
|
| 75 |
public String getParameterName() { |
| 76 |
if (getId() == null) { |
| 77 |
StringBuilder sb = new StringBuilder("complement"); |
| 78 |
|
| 79 |
sb.append(".").append(parameter.getId()); |
| 80 |
|
| 81 |
setId(sb.toString()); |
| 82 |
} |
| 83 |
return getId(); |
| 84 |
} |
| 85 |
|
| 86 |
public void addBounds(Bounds bounds) { |
| 87 |
this.bounds = bounds; |
| 88 |
} |
| 89 |
|
| 90 |
public Bounds<Double> getBounds() { |
| 91 |
if (bounds == null) { |
| 92 |
return parameter.getBounds(); |
| 93 |
} else { |
| 94 |
return bounds; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
public void addDimension(int index, double value) { |
| 99 |
throw new RuntimeException("Not yet implemented."); |
| 100 |
} |
| 101 |
|
| 102 |
public double removeDimension(int index) { |
| 103 |
throw new RuntimeException("Not yet implemented."); |
| 104 |
} |
| 105 |
|
| 106 |
public void variableChangedEvent(Variable variable, int index, ChangeType type) { |
| 107 |
fireParameterChangedEvent(index, type); |
| 108 |
} |
| 109 |
|
| 110 |
private final Parameter parameter; |
| 111 |
private Bounds bounds = null; |
| 112 |
} |