Skip to content

Commit

Permalink
make Experiment timeout per instance a constructor argument and public
Browse files Browse the repository at this point in the history
  • Loading branch information
J-morag committed May 24, 2022
1 parent 7bfa79f commit f0b9411
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/main/java/Environment/Experiment.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* Experiment class lets the user to specify the instances it needs for the experiment.
Expand Down Expand Up @@ -51,19 +52,19 @@ public class Experiment {
*/
public boolean proactiveGarbageCollection = true;
public int sleepTimeAfterGarbageCollection = 100;
public int timeoutEach;
public boolean sharedGoals = false;
public boolean sharedSources = false;

public Experiment(String experimentName, InstanceManager instanceManager) {
public Experiment(String experimentName, InstanceManager instanceManager, Integer numOfInstances, Integer timeoutEach) {
this.experimentName = experimentName;
this.instanceManager = instanceManager;
this.numOfInstances = Integer.MAX_VALUE;
this.numOfInstances = Objects.requireNonNullElse(numOfInstances, Integer.MAX_VALUE);
this.timeoutEach = Objects.requireNonNullElse(timeoutEach, 5 * 60 * 1000);
}

public Experiment(String experimentName, InstanceManager instanceManager, int numOfInstances) {
this.experimentName = experimentName;
this.instanceManager = instanceManager;
this.numOfInstances = numOfInstances;
public Experiment(String experimentName, InstanceManager instanceManager) {
this(experimentName, instanceManager, null, null);
}


Expand Down Expand Up @@ -168,7 +169,7 @@ protected boolean runInstanceOnSolver(I_Solver solver, Map<String, Integer> minN
instanceReport.putIntegerValue(InstanceReport.StandardFields.skipped, 0);
}

RunParameters runParameters = new RunParameters(5 * 60 * 1000, null, instanceReport, null);
RunParameters runParameters = new RunParameters(timeoutEach, null, instanceReport, null);

String instanceName = instance.extendedName;
int numAgents = instance.agents.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void addExperiment_16_7(){
InstanceManager instanceManager = new InstanceManager(path, new InstanceBuilder_BGU(),properties);

/* = Add new experiment = */
Experiment gridExperiment = new Experiment("Experiment_16_7", instanceManager,numOfInstances);
Experiment gridExperiment = new Experiment("Experiment_16_7", instanceManager,numOfInstances, 60 * 1000);
this.experiments.add(gridExperiment);
}

Expand Down

0 comments on commit f0b9411

Please sign in to comment.