diff --git a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ComputationalLaboratory.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ComputationalLaboratory.java index ef1ba116..c649ff07 100644 --- a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ComputationalLaboratory.java +++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ComputationalLaboratory.java @@ -125,8 +125,11 @@ public class ComputationalLaboratory { } + private final static String SOLUTION_INDICATOR_NAME = "vehicle-routing-problem-solution"; + private ConcurrentHashMap data = new ConcurrentHashMap(); + private ConcurrentHashMap solutions = new ConcurrentHashMap(); /** * Adds a single date by instanceName, algorithmName, run and indicatorName. *

If there is already an entry for this instance, algorithm, run and indicatorName, it is overwritten. @@ -138,10 +141,16 @@ public class ComputationalLaboratory { * @param value */ public void addDate(String instanceName, String algorithmName, int run, String indicatorName, double value){ + if(indicatorName.equals(SOLUTION_INDICATOR_NAME)) throw new IllegalArgumentException(indicatorName + " is already used internally. please choose another indicator-name."); Key key = new Key(instanceName,algorithmName,run,indicatorName); data.put(key, value); } + public void addSolution(String instanceName, String algorithmName, int run, VehicleRoutingProblemSolution solution){ + Key key = new Key(instanceName,algorithmName,run,SOLUTION_INDICATOR_NAME); + solutions.put(key, solution); + } + /** * Returns a collections of indicator values representing the calculated values of individual runs. * @@ -172,16 +181,32 @@ public class ComputationalLaboratory { public Double getDate(String instanceName, String algorithmName, int run, String indicator){ return data.get(new Key(instanceName,algorithmName,run,indicator)); } + + public VehicleRoutingProblemSolution getSolution(String instanceName, String algorithmName, int run){ + return solutions.get(new Key(instanceName,algorithmName,run,"solution")); + } /** * Returns all keys that have been created. A key is a unique combination of algorithmName, instanceName, run and indicator. * * @return */ - public Set keySet(){ + public Set getDataKeySet(){ return data.keySet(); } + public Set getSolutionKeySet(){ + return solutions.keySet(); + } + + public VehicleRoutingProblemSolution getSolution(Key solutionKey){ + return solutions.get(solutionKey); + } + + public Collection getSolutions(){ + return solutions.values(); + } + /** * Returns date associated to specified key. *