SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ProductWeights.java
1package umontreal.ssj.latnetbuilder.weights;
2
3import java.util.ArrayList;
4
15
16public class ProductWeights extends WeightsComparable<Integer> {
17
25 public ProductWeights(ArrayList<SingletonWeightComparable<Integer>> weightList) {
26 super(weightList);
27 }
28
32 public ProductWeights() {
33 super();
34 }
35
44 String printBody() {
45 if (!sorted)
46 sort();
47 StringBuffer sb = new StringBuffer("");
48 if (weights.size() > 0) {
49 int index = 0;
50 for (SingletonWeightComparable<Integer> w : weights) {
51 while (index < w.getIndex()) {
52 sb.append(getDefaultWeight() + ",");
53 index++;
54 }
55 sb.append(w.getWeight() + ",");
56 index++;
57 }
58 sb.deleteCharAt(sb.length() - 1);
59 }
60 return sb.toString();
61 }
62
71 @Override
72 public String toString() {
73 StringBuffer sb = new StringBuffer("");
74 sb.append("Product weights [default = " + getDefaultWeight() + "]:\n");
75 if (weights.size() > 0)
76 sb.append("[");
77 sb.append(printBody());
78 return sb.toString() + (weights.size() > 0 ? "]" : "");
79 }
80
86 public String toLatNetBuilder() {
87 StringBuffer sb = new StringBuffer("");
88 sb.append("product:" + getDefaultWeight());
89 if (weights.size() > 0) {
90 sb.append(":");
91 sb.append(printBody());
92 }
93// sb.append(" -o " + weightPower + " ");
94
95 return sb.toString();
96 }
97
98}
String toLatNetBuilder()
Creates a string formatted for passing it to LatNet Builder.
String toString()
Creates a formatted output of the product weights ordered w.r.t.
ProductWeights(ArrayList< SingletonWeightComparable< Integer > > weightList)
Constructor for product weights from a list of SingletonWeightComparable indexed by integers indicati...
String printBody()
Sorts the weights and creates a rudimentary string containing the product weights separated by commas...