SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
GeometricWeights.java
1package umontreal.ssj.latnetbuilder.weights;
2
3import java.io.IOException;
4import java.util.ArrayList;
5
17
19
20 protected double baseWeight = 1.0;
21 protected int truncationLevel;
22 protected double c;
23
32
33 public GeometricWeights(double base, int truncation, double c) {
34 super();
35 baseWeight = base;
36 truncationLevel = truncation;
37 this.c = c;
38 setWeights();
39 }
40
48
49 public GeometricWeights(double base, int truncation) {
50 this(base, truncation, 1.0);
51 }
52
57 super();
58 truncationLevel = 0;
59 }
60
66 public double getC() {
67 return c;
68 }
69
75 public void setC(double c) {
76 this.c = c;
77 }
78
84 public double getBaseWeight() {
85 return baseWeight;
86 }
87
93 public void setBaseWeight(double base) {
94 baseWeight = base;
95 }
96
103 public int getTruncationLevel() {
104 return truncationLevel;
105 }
106
113 public void setTruncationLevel(int trLevel) {
114 truncationLevel = trLevel;
115 }
116
120 public void setWeights() {
121 double w = 1.0;
122 weights = new ArrayList<SingletonWeightComparable<Integer>>(truncationLevel);
123 for (int order = 1; order <= truncationLevel; order++) {
124 weights.add(order - 1, new SingletonWeightComparable<Integer>(order, c * w));
125 w *= baseWeight;
126 }
127 }
128
135 @Override
136 public String toString() {
137 StringBuffer sb = new StringBuffer("");
138 sb.append(
139 "Geometric order dependent weights [default = " + getDefaultWeight() + ", base = " + baseWeight + "]:\n");
140 if (weights.size() > 0)
141 sb.append("[");
142 sb.append(printBody());
143 return sb.toString() + (weights.size() > 0 ? "]" : "");
144 }
145
146}
GeometricWeights(double base, int truncation, double c)
Constructs geometric weights with given baseWeight 'base' and truncationLevel 'truncation'.
void setC(double c)
Sets the constant factor .
void setTruncationLevel(int trLevel)
Sets the truncationLevel.
GeometricWeights(double base, int truncation)
Constructor that sets .
String toString()
Creates a formatted output of the geometric order dependent weights ordered w.r.t.
double getC()
Getter for the constant factor .
void setWeights()
Computes the weights up to the order truncationLevel and assigns them.
int getTruncationLevel()
Returns the current truncationLevel.
void setBaseWeight(double base)
Sets the baseWeight .
String printBody()
Sorts the weights and creates a rudimentary string containing the order dependent weights separated b...
OrderDependentWeights(ArrayList< SingletonWeightComparable< Integer > > weightList)
Constructs an instance of order dependent weights from a given list of comparable weights indexed by ...