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:
parent
cdbdd23583
commit
e9f36b99dd
1 changed files with 26 additions and 1 deletions
|
|
@ -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, 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.
|
* 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.
|
* <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
|
* @param value
|
||||||
*/
|
*/
|
||||||
public void addDate(String instanceName, String algorithmName, int run, String indicatorName, double 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);
|
Key key = new Key(instanceName,algorithmName,run,indicatorName);
|
||||||
data.put(key, value);
|
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.
|
* 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){
|
public Double getDate(String instanceName, String algorithmName, int run, String indicator){
|
||||||
return data.get(new Key(instanceName,algorithmName,run,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.
|
* Returns all keys that have been created. A key is a unique combination of algorithmName, instanceName, run and indicator.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Key> keySet(){
|
public Set<Key> getDataKeySet(){
|
||||||
return data.keySet();
|
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.
|
* Returns date associated to specified key.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue