mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add noise
This commit is contained in:
parent
5a049d18c6
commit
1fa8afadb6
5 changed files with 83 additions and 29 deletions
|
|
@ -80,4 +80,11 @@ public class RuinAndRecreateModule implements SearchStrategyModule{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InsertionStrategy getInsertion() {
|
||||||
|
return insertion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuinStrategy getRuin() {
|
||||||
|
return ruin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,15 @@ public final class BestInsertion extends AbstractInsertionStrategy{
|
||||||
|
|
||||||
private JobInsertionCostsCalculator bestInsertionCostCalculator;
|
private JobInsertionCostsCalculator bestInsertionCostCalculator;
|
||||||
|
|
||||||
|
private NoiseMaker noiseMaker = new NoiseMaker() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double makeNoise() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public BestInsertion(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem) {
|
public BestInsertion(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem) {
|
||||||
super(vehicleRoutingProblem);
|
super(vehicleRoutingProblem);
|
||||||
bestInsertionCostCalculator = jobInsertionCalculator;
|
bestInsertionCostCalculator = jobInsertionCalculator;
|
||||||
|
|
@ -67,7 +76,7 @@ public final class BestInsertion extends AbstractInsertionStrategy{
|
||||||
if(iData instanceof NoInsertionFound) {
|
if(iData instanceof NoInsertionFound) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(iData.getInsertionCost() < bestInsertionCost){
|
if(iData.getInsertionCost() < bestInsertionCost + noiseMaker.makeNoise()){
|
||||||
bestInsertion = new Insertion(vehicleRoute,iData);
|
bestInsertion = new Insertion(vehicleRoute,iData);
|
||||||
bestInsertionCost = iData.getInsertionCost();
|
bestInsertionCost = iData.getInsertionCost();
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +84,7 @@ public final class BestInsertion extends AbstractInsertionStrategy{
|
||||||
VehicleRoute newRoute = VehicleRoute.emptyRoute();
|
VehicleRoute newRoute = VehicleRoute.emptyRoute();
|
||||||
InsertionData newIData = bestInsertionCostCalculator.getInsertionData(newRoute, unassignedJob, NO_NEW_VEHICLE_YET, NO_NEW_DEPARTURE_TIME_YET, NO_NEW_DRIVER_YET, bestInsertionCost);
|
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 instanceof NoInsertionFound)){
|
||||||
if(newIData.getInsertionCost() < bestInsertionCost){
|
if(newIData.getInsertionCost() < bestInsertionCost + noiseMaker.makeNoise()){
|
||||||
bestInsertion = new Insertion(newRoute,newIData);
|
bestInsertion = new Insertion(newRoute,newIData);
|
||||||
vehicleRoutes.add(newRoute);
|
vehicleRoutes.add(newRoute);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package jsprit.core.algorithm.recreate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by schroeder on 06/01/15.
|
||||||
|
*/
|
||||||
|
public interface NoiseMaker {
|
||||||
|
|
||||||
|
public double makeNoise();
|
||||||
|
}
|
||||||
|
|
@ -55,6 +55,7 @@ public class RegretInsertion extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
private boolean newRoute;
|
private boolean newRoute;
|
||||||
|
|
||||||
|
|
||||||
ScoredJob(Job job, double score, InsertionData insertionData, VehicleRoute route, boolean isNewRoute) {
|
ScoredJob(Job job, double score, InsertionData insertionData, VehicleRoute route, boolean isNewRoute) {
|
||||||
this.job = job;
|
this.job = job;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
|
|
@ -185,6 +186,7 @@ public class RegretInsertion extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
private JobInsertionCostsCalculator insertionCostsCalculator;
|
private JobInsertionCostsCalculator insertionCostsCalculator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the scoring function.
|
* Sets the scoring function.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,9 @@
|
||||||
<problem xmlns="http://www.w3schools.com"
|
<problem xmlns="http://www.w3schools.com"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||||
<problemType>
|
<problemType>
|
||||||
<fleetSize>FINITE</fleetSize>
|
<fleetSize>INFINITE</fleetSize>
|
||||||
</problemType>
|
</problemType>
|
||||||
<vehicles>
|
<vehicles>
|
||||||
<vehicle>
|
|
||||||
<id>v2</id>
|
|
||||||
<typeId>vehType2</typeId>
|
|
||||||
<startLocation>
|
|
||||||
<id>loc</id>
|
|
||||||
</startLocation>
|
|
||||||
<endLocation>
|
|
||||||
<id>loc</id>
|
|
||||||
</endLocation>
|
|
||||||
<timeSchedule>
|
|
||||||
<start>0.0</start>
|
|
||||||
<end>1.7976931348623157E308</end>
|
|
||||||
</timeSchedule>
|
|
||||||
<returnToDepot>true</returnToDepot>
|
|
||||||
</vehicle>
|
|
||||||
<vehicle>
|
<vehicle>
|
||||||
<id>v1</id>
|
<id>v1</id>
|
||||||
<typeId>vehType</typeId>
|
<typeId>vehType</typeId>
|
||||||
|
|
@ -48,16 +33,58 @@
|
||||||
<time>0.0</time>
|
<time>0.0</time>
|
||||||
</costs>
|
</costs>
|
||||||
</type>
|
</type>
|
||||||
<type>
|
|
||||||
<id>vehType2</id>
|
|
||||||
<capacity-dimensions>
|
|
||||||
<dimension index="0">200</dimension>
|
|
||||||
</capacity-dimensions>
|
|
||||||
<costs>
|
|
||||||
<fixed>0.0</fixed>
|
|
||||||
<distance>1.0</distance>
|
|
||||||
<time>0.0</time>
|
|
||||||
</costs>
|
|
||||||
</type>
|
|
||||||
</vehicleTypes>
|
</vehicleTypes>
|
||||||
|
<services>
|
||||||
|
<service id="1" type="service">
|
||||||
|
<location>
|
||||||
|
<id>loc</id>
|
||||||
|
</location>
|
||||||
|
<capacity-dimensions>
|
||||||
|
<dimension index="0">1</dimension>
|
||||||
|
</capacity-dimensions>
|
||||||
|
<duration>2.0</duration>
|
||||||
|
<timeWindows>
|
||||||
|
<timeWindow>
|
||||||
|
<start>0.0</start>
|
||||||
|
<end>1.7976931348623157E308</end>
|
||||||
|
</timeWindow>
|
||||||
|
</timeWindows>
|
||||||
|
</service>
|
||||||
|
<service id="2" type="service">
|
||||||
|
<location>
|
||||||
|
<id>loc2</id>
|
||||||
|
</location>
|
||||||
|
<capacity-dimensions>
|
||||||
|
<dimension index="0">1</dimension>
|
||||||
|
</capacity-dimensions>
|
||||||
|
<duration>4.0</duration>
|
||||||
|
<timeWindows>
|
||||||
|
<timeWindow>
|
||||||
|
<start>0.0</start>
|
||||||
|
<end>1.7976931348623157E308</end>
|
||||||
|
</timeWindow>
|
||||||
|
</timeWindows>
|
||||||
|
</service>
|
||||||
|
</services>
|
||||||
|
<solutions>
|
||||||
|
<solution>
|
||||||
|
<cost>10.0</cost>
|
||||||
|
<routes>
|
||||||
|
<route>
|
||||||
|
<driverId>noDriver</driverId>
|
||||||
|
<vehicleId>v1</vehicleId>
|
||||||
|
<start>0.0</start>
|
||||||
|
<act type="service">
|
||||||
|
<serviceId>1</serviceId>
|
||||||
|
<arrTime>0.0</arrTime>
|
||||||
|
<endTime>0.0</endTime>
|
||||||
|
</act>
|
||||||
|
<end>0.0</end>
|
||||||
|
</route>
|
||||||
|
</routes>
|
||||||
|
<unassignedJobs>
|
||||||
|
<job id="2"/>
|
||||||
|
</unassignedJobs>
|
||||||
|
</solution>
|
||||||
|
</solutions>
|
||||||
</problem>
|
</problem>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue