Refactor SimulationBuilder to initialize fields and simplify end criteria parsing
This commit is contained in:
@@ -19,13 +19,13 @@ import net.berack.upo.valpre.sim.stats.CsvResult;
|
|||||||
* and runs the simulation with the given parameters.
|
* and runs the simulation with the given parameters.
|
||||||
*/
|
*/
|
||||||
public class SimulationBuilder {
|
public class SimulationBuilder {
|
||||||
private String csv;
|
private String csv = null;
|
||||||
private int runs;
|
private int runs = 1;
|
||||||
private long seed;
|
private long seed = 0;
|
||||||
private Net net;
|
private EndCriteria[] endCriteria = new EndCriteria[0];
|
||||||
private EndCriteria[] endCriteria;
|
|
||||||
private ConfidenceIndices confidences;
|
|
||||||
private Type type = Type.Normal;
|
private Type type = Type.Normal;
|
||||||
|
private Net net;
|
||||||
|
private ConfidenceIndices confidences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new simulation for the given net.
|
* Create a new simulation for the given net.
|
||||||
@@ -93,7 +93,7 @@ public class SimulationBuilder {
|
|||||||
* @return this simulation
|
* @return this simulation
|
||||||
*/
|
*/
|
||||||
public SimulationBuilder setParallel(boolean parallel) {
|
public SimulationBuilder setParallel(boolean parallel) {
|
||||||
if (parallel && !this.confidences.isEmpty())
|
if (parallel && this.confidences.isEmpty())
|
||||||
this.type = Type.Parallel;
|
this.type = Type.Parallel;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -142,10 +142,8 @@ public class SimulationBuilder {
|
|||||||
* @throws IllegalArgumentException If one of the criteria is not valid.
|
* @throws IllegalArgumentException If one of the criteria is not valid.
|
||||||
*/
|
*/
|
||||||
public SimulationBuilder parseEndCriteria(String criterias) {
|
public SimulationBuilder parseEndCriteria(String criterias) {
|
||||||
if (criterias == null || criterias.isEmpty()) {
|
if (criterias == null || criterias.isEmpty())
|
||||||
this.endCriteria = new EndCriteria[0];
|
|
||||||
return this;
|
return this;
|
||||||
}
|
|
||||||
|
|
||||||
var criteria = criterias.split(";");
|
var criteria = criterias.split(";");
|
||||||
this.endCriteria = new EndCriteria[criteria.length];
|
this.endCriteria = new EndCriteria[criteria.length];
|
||||||
@@ -171,7 +169,6 @@ public class SimulationBuilder {
|
|||||||
* Add a confidence index for the given node and stat.
|
* Add a confidence index for the given node and stat.
|
||||||
* The confidence index is used to determine when the simulation should stop.
|
* The confidence index is used to determine when the simulation should stop.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param node the node
|
* @param node the node
|
||||||
* @param stat the stat to calculate the confidence index for
|
* @param stat the stat to calculate the confidence index for
|
||||||
* @param confidence the confidence level expressed as a percentage [0,1]
|
* @param confidence the confidence level expressed as a percentage [0,1]
|
||||||
|
|||||||
Reference in New Issue
Block a user