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

add noise

This commit is contained in:
oblonski 2015-01-07 11:37:44 +01:00
parent 5a049d18c6
commit 1fa8afadb6
5 changed files with 83 additions and 29 deletions

View file

@ -80,4 +80,11 @@ public class RuinAndRecreateModule implements SearchStrategyModule{
}
public InsertionStrategy getInsertion() {
return insertion;
}
public RuinStrategy getRuin() {
return ruin;
}
}

View file

@ -43,6 +43,15 @@ public final class BestInsertion extends AbstractInsertionStrategy{
private JobInsertionCostsCalculator bestInsertionCostCalculator;
private NoiseMaker noiseMaker = new NoiseMaker() {
@Override
public double makeNoise() {
return 0;
}
};
public BestInsertion(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem) {
super(vehicleRoutingProblem);
bestInsertionCostCalculator = jobInsertionCalculator;
@ -67,7 +76,7 @@ public final class BestInsertion extends AbstractInsertionStrategy{
if(iData instanceof NoInsertionFound) {
continue;
}
if(iData.getInsertionCost() < bestInsertionCost){
if(iData.getInsertionCost() < bestInsertionCost + noiseMaker.makeNoise()){
bestInsertion = new Insertion(vehicleRoute,iData);
bestInsertionCost = iData.getInsertionCost();
}
@ -75,7 +84,7 @@ public final class BestInsertion extends AbstractInsertionStrategy{
VehicleRoute newRoute = VehicleRoute.emptyRoute();
InsertionData newIData = bestInsertionCostCalculator.getInsertionData(newRoute, unassignedJob, NO_NEW_VEHICLE_YET, NO_NEW_DEPARTURE_TIME_YET, NO_NEW_DRIVER_YET, bestInsertionCost);
if(!(newIData instanceof NoInsertionFound)){
if(newIData.getInsertionCost() < bestInsertionCost){
if(newIData.getInsertionCost() < bestInsertionCost + noiseMaker.makeNoise()){
bestInsertion = new Insertion(newRoute,newIData);
vehicleRoutes.add(newRoute);
}

View file

@ -0,0 +1,9 @@
package jsprit.core.algorithm.recreate;
/**
* Created by schroeder on 06/01/15.
*/
public interface NoiseMaker {
public double makeNoise();
}

View file

@ -55,6 +55,7 @@ public class RegretInsertion extends AbstractInsertionStrategy {
private boolean newRoute;
ScoredJob(Job job, double score, InsertionData insertionData, VehicleRoute route, boolean isNewRoute) {
this.job = job;
this.score = score;
@ -185,6 +186,7 @@ public class RegretInsertion extends AbstractInsertionStrategy {
private JobInsertionCostsCalculator insertionCostsCalculator;
/**
* Sets the scoring function.
*