1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

added methods to memorize solutions in

analysis.toolbox.ComputationalLaboratory.DataCollector.java
This commit is contained in:
oblonski 2014-04-16 14:02:40 +02:00
parent cdbdd23583
commit e9f36b99dd

View file

@ -125,8 +125,11 @@ public class ComputationalLaboratory {
}
private final static String SOLUTION_INDICATOR_NAME = "vehicle-routing-problem-solution";
private ConcurrentHashMap<Key, Double> data = new ConcurrentHashMap<ComputationalLaboratory.DataCollector.Key, Double>();
private ConcurrentHashMap<Key, VehicleRoutingProblemSolution> solutions = new ConcurrentHashMap<ComputationalLaboratory.DataCollector.Key, VehicleRoutingProblemSolution>();
/**
* Adds a single date by instanceName, algorithmName, run and indicatorName.
* <p>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.
*
@ -173,15 +182,31 @@ public class ComputationalLaboratory {
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<Key> keySet(){
public Set<Key> getDataKeySet(){
return data.keySet();
}
public Set<Key> getSolutionKeySet(){
return solutions.keySet();
}
public VehicleRoutingProblemSolution getSolution(Key solutionKey){
return solutions.get(solutionKey);
}
public Collection<VehicleRoutingProblemSolution> getSolutions(){
return solutions.values();
}
/**
* Returns date associated to specified key.
*