mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
speed up regret insertion
This commit is contained in:
parent
c72c243bf0
commit
e12136393a
8 changed files with 75 additions and 98 deletions
|
|
@ -404,7 +404,7 @@ public class Jsprit {
|
||||||
);
|
);
|
||||||
|
|
||||||
AbstractInsertionStrategy regret;
|
AbstractInsertionStrategy regret;
|
||||||
final RegretInsertion.DefaultScorer scorer;
|
final DefaultScorer scorer;
|
||||||
|
|
||||||
if (es != null) {
|
if (es != null) {
|
||||||
RegretInsertionConcurrent regretInsertion = (RegretInsertionConcurrent) new InsertionBuilder(vrp, fm, stateManager, constraintManager)
|
RegretInsertionConcurrent regretInsertion = (RegretInsertionConcurrent) new InsertionBuilder(vrp, fm, stateManager, constraintManager)
|
||||||
|
|
@ -424,7 +424,6 @@ public class Jsprit {
|
||||||
.considerFixedCosts(toDouble(getProperty(Parameter.FIXED_COST_PARAM.toString())))
|
.considerFixedCosts(toDouble(getProperty(Parameter.FIXED_COST_PARAM.toString())))
|
||||||
.setActivityInsertionCostCalculator(activityInsertion)
|
.setActivityInsertionCostCalculator(activityInsertion)
|
||||||
.build();
|
.build();
|
||||||
regretInsertion.setFleetManager(fm);
|
|
||||||
scorer = getRegretScorer(vrp);
|
scorer = getRegretScorer(vrp);
|
||||||
regretInsertion.setScoringFunction(scorer);
|
regretInsertion.setScoringFunction(scorer);
|
||||||
regret = regretInsertion;
|
regret = regretInsertion;
|
||||||
|
|
@ -522,9 +521,9 @@ public class Jsprit {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RegretInsertion.DefaultScorer getRegretScorer(VehicleRoutingProblem vrp) {
|
private DefaultScorer getRegretScorer(VehicleRoutingProblem vrp) {
|
||||||
RegretInsertion.DefaultScorer scorer;
|
DefaultScorer scorer;
|
||||||
scorer = new RegretInsertion.DefaultScorer(vrp);
|
scorer = new DefaultScorer(vrp);
|
||||||
scorer.setTimeWindowParam(Double.valueOf(properties.getProperty(Parameter.REGRET_TIME_WINDOW_SCORER.toString())));
|
scorer.setTimeWindowParam(Double.valueOf(properties.getProperty(Parameter.REGRET_TIME_WINDOW_SCORER.toString())));
|
||||||
scorer.setDepotDistanceParam(Double.valueOf(properties.getProperty(Parameter.REGRET_DISTANCE_SCORER.toString())));
|
scorer.setDepotDistanceParam(Double.valueOf(properties.getProperty(Parameter.REGRET_DISTANCE_SCORER.toString())));
|
||||||
return scorer;
|
return scorer;
|
||||||
|
|
|
||||||
|
|
@ -166,12 +166,11 @@ public class InsertionBuilder {
|
||||||
}
|
}
|
||||||
} else if (strategy.equals(Strategy.REGRET)) {
|
} else if (strategy.equals(Strategy.REGRET)) {
|
||||||
if (executor == null) {
|
if (executor == null) {
|
||||||
RegretInsertion regret = new RegretInsertion(costCalculator, vrp);
|
RegretInsertion regret = new RegretInsertion(costCalculator, vrp, fleetManager);
|
||||||
regret.setFleetManager(fleetManager);
|
|
||||||
insertion = regret;
|
insertion = regret;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
insertion = new RegretInsertionConcurrent(costCalculator, vrp, executor);
|
insertion = new RegretInsertionConcurrent(costCalculator, vrp, executor, fleetManager);
|
||||||
}
|
}
|
||||||
} else throw new IllegalStateException("you should never get here");
|
} else throw new IllegalStateException("you should never get here");
|
||||||
for (InsertionListener l : iListeners) insertion.addListener(l);
|
for (InsertionListener l : iListeners) insertion.addListener(l);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
class InsertionDataUpdater {
|
class InsertionDataUpdater {
|
||||||
|
|
||||||
static void update(VehicleFleetManager fleetManager, JobInsertionCostsCalculator insertionCostsCalculator, TreeSet<VersionedInsertionData> insertionDataSet, int updateRound, Map<VehicleRoute, Integer> updates, Job unassignedJob, Collection<VehicleRoute> routes) {
|
static boolean update(VehicleFleetManager fleetManager, JobInsertionCostsCalculator insertionCostsCalculator, TreeSet<VersionedInsertionData> insertionDataSet, int updateRound, Job unassignedJob, Collection<VehicleRoute> routes) {
|
||||||
for(VehicleRoute route : routes) {
|
for(VehicleRoute route : routes) {
|
||||||
Collection<Vehicle> relevantVehicles = new ArrayList<Vehicle>();
|
Collection<Vehicle> relevantVehicles = new ArrayList<Vehicle>();
|
||||||
if (!(route.getVehicle() instanceof VehicleImpl.NoVehicle)) {
|
if (!(route.getVehicle() instanceof VehicleImpl.NoVehicle)) {
|
||||||
|
|
@ -28,8 +28,8 @@ class InsertionDataUpdater {
|
||||||
}
|
}
|
||||||
insertionDataSet.add(new VersionedInsertionData(iData, updateRound, route));
|
insertionDataSet.add(new VersionedInsertionData(iData, updateRound, route));
|
||||||
}
|
}
|
||||||
updates.put(route, updateRound);
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VehicleRoute findRoute(Collection<VehicleRoute> routes, Job job) {
|
static VehicleRoute findRoute(Collection<VehicleRoute> routes, Job job) {
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,6 @@ public class RegretInsertion extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
private VehicleFleetManager fleetManager;
|
private VehicleFleetManager fleetManager;
|
||||||
|
|
||||||
public void setFleetManager(VehicleFleetManager fleetManager) {
|
|
||||||
this.fleetManager = fleetManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the scoring function.
|
* Sets the scoring function.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
@ -62,10 +58,11 @@ public class RegretInsertion extends AbstractInsertionStrategy {
|
||||||
this.scoringFunction = scoringFunction;
|
this.scoringFunction = scoringFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegretInsertion(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem) {
|
public RegretInsertion(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem, VehicleFleetManager fleetManager) {
|
||||||
super(vehicleRoutingProblem);
|
super(vehicleRoutingProblem);
|
||||||
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
||||||
this.insertionCostsCalculator = jobInsertionCalculator;
|
this.insertionCostsCalculator = jobInsertionCalculator;
|
||||||
|
this.fleetManager = fleetManager;
|
||||||
this.vrp = vehicleRoutingProblem;
|
this.vrp = vehicleRoutingProblem;
|
||||||
logger.debug("initialise {}", this);
|
logger.debug("initialise {}", this);
|
||||||
}
|
}
|
||||||
|
|
@ -117,10 +114,12 @@ public class RegretInsertion extends AbstractInsertionStrategy {
|
||||||
if(!firstRun && lastModified == null) throw new IllegalStateException("fooo");
|
if(!firstRun && lastModified == null) throw new IllegalStateException("fooo");
|
||||||
if(firstRun){
|
if(firstRun){
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
updateInsertionData(priorityQueues, routes, unassignedJobList, badJobList, updateRound, updates);
|
updateInsertionData(priorityQueues, routes, unassignedJobList, updateRound);
|
||||||
|
for(VehicleRoute r : routes) updates.put(r,updateRound);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
updateInsertionData(priorityQueues, Arrays.asList(lastModified), unassignedJobList, badJobList, updateRound, updates);
|
updateInsertionData(priorityQueues, Arrays.asList(lastModified), unassignedJobList, updateRound);
|
||||||
|
updates.put(lastModified,updateRound);
|
||||||
}
|
}
|
||||||
updateRound++;
|
updateRound++;
|
||||||
ScoredJob bestScoredJob = InsertionDataUpdater.getBest(fleetManager,insertionCostsCalculator,scoringFunction,priorityQueues,updates,unassignedJobList,badJobList);
|
ScoredJob bestScoredJob = InsertionDataUpdater.getBest(fleetManager,insertionCostsCalculator,scoringFunction,priorityQueues,updates,unassignedJobList,badJobList);
|
||||||
|
|
@ -141,12 +140,12 @@ public class RegretInsertion extends AbstractInsertionStrategy {
|
||||||
return badJobs;
|
return badJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInsertionData(TreeSet<VersionedInsertionData>[] priorityQueues, Collection<VehicleRoute> routes, List<Job> unassignedJobList, List<Job> badJobList, int updateRound, Map<VehicleRoute, Integer> updates) {
|
private void updateInsertionData(TreeSet<VersionedInsertionData>[] priorityQueues, Collection<VehicleRoute> routes, List<Job> unassignedJobList, int updateRound) {
|
||||||
for (Job unassignedJob : unassignedJobList) {
|
for (Job unassignedJob : unassignedJobList) {
|
||||||
if(priorityQueues[unassignedJob.getIndex()] == null){
|
if(priorityQueues[unassignedJob.getIndex()] == null){
|
||||||
priorityQueues[unassignedJob.getIndex()] = new TreeSet<VersionedInsertionData>(InsertionDataUpdater.getComparator());
|
priorityQueues[unassignedJob.getIndex()] = new TreeSet<VersionedInsertionData>(InsertionDataUpdater.getComparator());
|
||||||
}
|
}
|
||||||
InsertionDataUpdater.update(fleetManager,insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, updates, unassignedJob, routes);
|
InsertionDataUpdater.update(fleetManager,insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,9 @@ import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutorCompletionService;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insertion based on regret approach.
|
* Insertion based on regret approach.
|
||||||
|
|
@ -48,15 +49,10 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
private final JobInsertionCostsCalculator insertionCostsCalculator;
|
private final JobInsertionCostsCalculator insertionCostsCalculator;
|
||||||
|
|
||||||
private final ExecutorCompletionService<ScoredJob> completionService;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
private VehicleFleetManager fleetManager;
|
private VehicleFleetManager fleetManager;
|
||||||
|
|
||||||
|
|
||||||
public void setFleetManager(VehicleFleetManager fleetManager) {
|
|
||||||
this.fleetManager = fleetManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the scoring function.
|
* Sets the scoring function.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
@ -68,12 +64,13 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
this.scoringFunction = scoringFunction;
|
this.scoringFunction = scoringFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegretInsertionConcurrent(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem, ExecutorService executorService) {
|
public RegretInsertionConcurrent(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem, ExecutorService executorService, VehicleFleetManager fleetManager) {
|
||||||
super(vehicleRoutingProblem);
|
super(vehicleRoutingProblem);
|
||||||
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
||||||
this.insertionCostsCalculator = jobInsertionCalculator;
|
this.insertionCostsCalculator = jobInsertionCalculator;
|
||||||
this.vrp = vehicleRoutingProblem;
|
this.vrp = vehicleRoutingProblem;
|
||||||
completionService = new ExecutorCompletionService<ScoredJob>(executorService);
|
this.executor = executorService;
|
||||||
|
this.fleetManager = fleetManager;
|
||||||
logger.debug("initialise " + this);
|
logger.debug("initialise " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,13 +120,15 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
while (!jobs.isEmpty()) {
|
while (!jobs.isEmpty()) {
|
||||||
List<Job> unassignedJobList = new ArrayList<Job>(jobs);
|
List<Job> unassignedJobList = new ArrayList<Job>(jobs);
|
||||||
List<Job> badJobList = new ArrayList<Job>();
|
List<Job> badJobList = new ArrayList<Job>();
|
||||||
if(!firstRun && lastModified == null) throw new IllegalStateException("fooo");
|
if(!firstRun && lastModified == null) throw new IllegalStateException("ho. this must not be.");
|
||||||
if(firstRun){
|
if(firstRun){
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
updateInsertionData(priorityQueues, routes, unassignedJobList, badJobList, updateRound, updates);
|
updateInsertionData(priorityQueues, routes, unassignedJobList, updateRound);
|
||||||
|
for(VehicleRoute r : routes) updates.put(r,updateRound);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
updateInsertionData(priorityQueues, Arrays.asList(lastModified), unassignedJobList, badJobList, updateRound, updates);
|
updateInsertionData(priorityQueues, Arrays.asList(lastModified), unassignedJobList, updateRound);
|
||||||
|
updates.put(lastModified,updateRound);
|
||||||
}
|
}
|
||||||
updateRound++;
|
updateRound++;
|
||||||
ScoredJob bestScoredJob = InsertionDataUpdater.getBest(fleetManager, insertionCostsCalculator, scoringFunction, priorityQueues, updates, unassignedJobList, badJobList);
|
ScoredJob bestScoredJob = InsertionDataUpdater.getBest(fleetManager, insertionCostsCalculator, scoringFunction, priorityQueues, updates, unassignedJobList, badJobList);
|
||||||
|
|
@ -150,13 +149,25 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
return badJobs;
|
return badJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInsertionData(TreeSet<VersionedInsertionData>[] priorityQueues, Collection<VehicleRoute> routes, List<Job> unassignedJobList, List<Job> badJobList, int updateRound, Map<VehicleRoute, Integer> updates) {
|
private void updateInsertionData(final TreeSet<VersionedInsertionData>[] priorityQueues, final Collection<VehicleRoute> routes, List<Job> unassignedJobList, final int updateRound) {
|
||||||
for (Job unassignedJob : unassignedJobList) {
|
List<Callable<Boolean>> tasks = new ArrayList<Callable<Boolean>>();
|
||||||
|
for (final Job unassignedJob : unassignedJobList) {
|
||||||
if(priorityQueues[unassignedJob.getIndex()] == null){
|
if(priorityQueues[unassignedJob.getIndex()] == null){
|
||||||
priorityQueues[unassignedJob.getIndex()] = new TreeSet<VersionedInsertionData>(InsertionDataUpdater.getComparator());
|
priorityQueues[unassignedJob.getIndex()] = new TreeSet<VersionedInsertionData>(InsertionDataUpdater.getComparator());
|
||||||
}
|
}
|
||||||
// completionService.submit(ne)
|
final TreeSet<VersionedInsertionData> priorityQueue = priorityQueues[unassignedJob.getIndex()];
|
||||||
InsertionDataUpdater.update(fleetManager,insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, updates, unassignedJob, routes);
|
tasks.add(new Callable<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return InsertionDataUpdater.update(fleetManager, insertionCostsCalculator, priorityQueue, updateRound, unassignedJob, routes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<Future<Boolean>> futures = executor.invokeAll(tasks);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,7 @@ public class RegretInsertionTest {
|
||||||
|
|
||||||
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||||
JobInsertionCostsCalculator calculator = getCalculator(vrp);
|
JobInsertionCostsCalculator calculator = getCalculator(vrp);
|
||||||
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp);
|
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp, fm);
|
||||||
regretInsertion.setFleetManager(fm);
|
|
||||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||||
|
|
||||||
regretInsertion.insertJobs(routes, vrp.getJobs().values());
|
regretInsertion.insertJobs(routes, vrp.getJobs().values());
|
||||||
|
|
@ -67,8 +66,7 @@ public class RegretInsertionTest {
|
||||||
|
|
||||||
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||||
JobInsertionCostsCalculator calculator = getCalculator(vrp);
|
JobInsertionCostsCalculator calculator = getCalculator(vrp);
|
||||||
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp);
|
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp, fm);
|
||||||
regretInsertion.setFleetManager(fm);
|
|
||||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||||
|
|
||||||
regretInsertion.insertJobs(routes, vrp.getJobs().values());
|
regretInsertion.insertJobs(routes, vrp.getJobs().values());
|
||||||
|
|
@ -85,8 +83,7 @@ public class RegretInsertionTest {
|
||||||
|
|
||||||
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||||
JobInsertionCostsCalculator calculator = getCalculator(vrp);
|
JobInsertionCostsCalculator calculator = getCalculator(vrp);
|
||||||
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp);
|
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp, fm);
|
||||||
regretInsertion.setFleetManager(fm);
|
|
||||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||||
|
|
||||||
CkeckJobSequence position = new CkeckJobSequence(2, s1);
|
CkeckJobSequence position = new CkeckJobSequence(2, s1);
|
||||||
|
|
@ -112,8 +109,7 @@ public class RegretInsertionTest {
|
||||||
|
|
||||||
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
VehicleFleetManager fm = new FiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||||
JobInsertionCostsCalculator calculator = getShipmentCalculator(vrp);
|
JobInsertionCostsCalculator calculator = getShipmentCalculator(vrp);
|
||||||
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp);
|
RegretInsertion regretInsertion = new RegretInsertion(calculator, vrp, fm);
|
||||||
regretInsertion.setFleetManager(fm);
|
|
||||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||||
|
|
||||||
CkeckJobSequence position = new CkeckJobSequence(2, s2);
|
CkeckJobSequence position = new CkeckJobSequence(2, s2);
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,24 @@
|
||||||
<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>INFINITE</fleetSize>
|
<fleetSize>FINITE</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>
|
||||||
|
|
@ -33,58 +48,16 @@
|
||||||
<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>
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public class BuildAlgorithmFromScratch {
|
||||||
InsertionBuilder iBuilder = new InsertionBuilder(vrp, fleetManager, stateManager, constraintManager);
|
InsertionBuilder iBuilder = new InsertionBuilder(vrp, fleetManager, stateManager, constraintManager);
|
||||||
iBuilder.setInsertionStrategy(InsertionBuilder.Strategy.REGRET);
|
iBuilder.setInsertionStrategy(InsertionBuilder.Strategy.REGRET);
|
||||||
RegretInsertion regret = (RegretInsertion) iBuilder.build();
|
RegretInsertion regret = (RegretInsertion) iBuilder.build();
|
||||||
RegretInsertion.DefaultScorer scoringFunction = new RegretInsertion.DefaultScorer(vrp);
|
DefaultScorer scoringFunction = new DefaultScorer(vrp);
|
||||||
scoringFunction.setDepotDistanceParam(0.2);
|
scoringFunction.setDepotDistanceParam(0.2);
|
||||||
scoringFunction.setTimeWindowParam(-.2);
|
scoringFunction.setTimeWindowParam(-.2);
|
||||||
regret.setScoringFunction(scoringFunction);
|
regret.setScoringFunction(scoringFunction);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue