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

add editorconfig - #174

This commit is contained in:
oblonski 2015-09-11 12:49:01 +02:00
parent b9c7dc3324
commit 25e5c096f2
43 changed files with 625 additions and 645 deletions

View file

@ -178,8 +178,8 @@ public final class BestInsertionConcurrent extends AbstractInsertionStrategy {
} else { } else {
vehicleRoutes.add(VehicleRoute.emptyRoute()); vehicleRoutes.add(VehicleRoute.emptyRoute());
} }
/* /*
* distribute routes to batches equally * distribute routes to batches equally
*/ */
int count = 0; int count = 0;
for (VehicleRoute route : vehicleRoutes) { for (VehicleRoute route : vehicleRoutes) {

View file

@ -32,63 +32,61 @@ import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.*;
/** /**
* Insertion based on regret approach. * Insertion based on regret approach.
* * <p/>
* <p>Basically calculates the insertion cost of the firstBest and the secondBest alternative. The score is then calculated as difference * <p>Basically calculates the insertion cost of the firstBest and the secondBest alternative. The score is then calculated as difference
* between secondBest and firstBest, plus additional scoring variables that can defined in this.ScoringFunction. * between secondBest and firstBest, plus additional scoring variables that can defined in this.ScoringFunction.
* The idea is that if the cost of the secondBest alternative is way higher than the first best, it seems to be important to insert this * The idea is that if the cost of the secondBest alternative is way higher than the first best, it seems to be important to insert this
* customer immediatedly. If difference is not that high, it might not impact solution if this customer is inserted later. * customer immediatedly. If difference is not that high, it might not impact solution if this customer is inserted later.
* *
* @author stefan schroeder * @author stefan schroeder
* */
*/
public class RegretInsertionConcurrent extends AbstractInsertionStrategy { public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
private static Logger logger = LogManager.getLogger(RegretInsertionConcurrent.class); private static Logger logger = LogManager.getLogger(RegretInsertionConcurrent.class);
private ScoringFunction scoringFunction; private ScoringFunction scoringFunction;
private final JobInsertionCostsCalculator insertionCostsCalculator; private final JobInsertionCostsCalculator insertionCostsCalculator;
private final ExecutorCompletionService<ScoredJob> completionService; private final ExecutorCompletionService<ScoredJob> completionService;
/** /**
* Sets the scoring function. * Sets the scoring function.
* * <p/>
* <p>By default, the this.TimeWindowScorer is used. * <p>By default, the this.TimeWindowScorer is used.
* *
* @param scoringFunction to score * @param scoringFunction to score
*/ */
public void setScoringFunction(ScoringFunction scoringFunction) { public void setScoringFunction(ScoringFunction scoringFunction) {
this.scoringFunction = scoringFunction; this.scoringFunction = scoringFunction;
} }
public RegretInsertionConcurrent(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem, ExecutorService executorService) { public RegretInsertionConcurrent(JobInsertionCostsCalculator jobInsertionCalculator, VehicleRoutingProblem vehicleRoutingProblem, ExecutorService executorService) {
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); completionService = new ExecutorCompletionService<ScoredJob>(executorService);
logger.debug("initialise " + this); logger.debug("initialise " + this);
} }
@Override @Override
public String toString() { public String toString() {
return "[name=regretInsertion][additionalScorer="+scoringFunction+"]"; return "[name=regretInsertion][additionalScorer=" + scoringFunction + "]";
} }
/** /**
* Runs insertion. * Runs insertion.
* * <p/>
* <p>Before inserting a job, all unassigned jobs are scored according to its best- and secondBest-insertion plus additional scoring variables. * <p>Before inserting a job, all unassigned jobs are scored according to its best- and secondBest-insertion plus additional scoring variables.
* *
* @throws java.lang.RuntimeException if smth went wrong with thread execution * @throws java.lang.RuntimeException if smth went wrong with thread execution
* */
*/ @Override
@Override public Collection<Job> insertUnassignedJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
public Collection<Job> insertUnassignedJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
List<Job> badJobs = new ArrayList<Job>(unassignedJobs.size()); List<Job> badJobs = new ArrayList<Job>(unassignedJobs.size());
List<Job> jobs = new ArrayList<Job>(unassignedJobs); List<Job> jobs = new ArrayList<Job>(unassignedJobs);
@ -96,14 +94,14 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
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>();
ScoredJob bestScoredJob = nextJob(routes, unassignedJobList, badJobList); ScoredJob bestScoredJob = nextJob(routes, unassignedJobList, badJobList);
if(bestScoredJob != null){ if (bestScoredJob != null) {
if(bestScoredJob.isNewRoute()){ if (bestScoredJob.isNewRoute()) {
routes.add(bestScoredJob.getRoute()); routes.add(bestScoredJob.getRoute());
} }
insertJob(bestScoredJob.getJob(),bestScoredJob.getInsertionData(),bestScoredJob.getRoute()); insertJob(bestScoredJob.getJob(), bestScoredJob.getInsertionData(), bestScoredJob.getRoute());
jobs.remove(bestScoredJob.getJob()); jobs.remove(bestScoredJob.getJob());
} }
for(Job j : badJobList) { for (Job j : badJobList) {
jobs.remove(j); jobs.remove(j);
badJobs.add(j); badJobs.add(j);
} }
@ -125,26 +123,23 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
}); });
} }
try{ try {
for(int i=0; i < unassignedJobList.size(); i++){ for (int i = 0; i < unassignedJobList.size(); i++) {
Future<ScoredJob> fsj = completionService.take(); Future<ScoredJob> fsj = completionService.take();
ScoredJob sJob = fsj.get(); ScoredJob sJob = fsj.get();
if(sJob instanceof RegretInsertion.BadJob){ if (sJob instanceof RegretInsertion.BadJob) {
badJobList.add(sJob.getJob()); badJobList.add(sJob.getJob());
continue; continue;
} }
if(bestScoredJob == null){ if (bestScoredJob == null) {
bestScoredJob = sJob; bestScoredJob = sJob;
} } else if (sJob.getScore() > bestScoredJob.getScore()) {
else if(sJob.getScore() > bestScoredJob.getScore()){
bestScoredJob = sJob; bestScoredJob = sJob;
} }
} }
} } catch (InterruptedException e) {
catch(InterruptedException e){
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} } catch (ExecutionException e) {
catch (ExecutionException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -152,9 +147,4 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
} }
} }

View file

@ -11,7 +11,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
package jsprit.core.algorithm.ruin; package jsprit.core.algorithm.ruin;
@ -33,160 +33,158 @@ import java.util.*;
/** /**
* Ruin strategy that ruins current solution randomly. I.e. * Ruin strategy that ruins current solution randomly. I.e.
* customer are removed randomly from current solution. * customer are removed randomly from current solution.
* *
* @author stefan schroeder * @author stefan schroeder
*
*/ */
public final class RuinClusters extends AbstractRuinStrategy implements IterationStartsListener { public final class RuinClusters extends AbstractRuinStrategy implements IterationStartsListener {
@Override @Override
public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
minPts = 1 + random.nextInt(2); minPts = 1 + random.nextInt(2);
epsFactor = 0.5 + random.nextDouble(); epsFactor = 0.5 + random.nextDouble();
} }
public static class JobActivityWrapper implements Clusterable { public static class JobActivityWrapper implements Clusterable {
private TourActivity.JobActivity jobActivity; private TourActivity.JobActivity jobActivity;
public JobActivityWrapper(TourActivity.JobActivity jobActivity) { public JobActivityWrapper(TourActivity.JobActivity jobActivity) {
this.jobActivity = jobActivity; this.jobActivity = jobActivity;
} }
@Override @Override
public double[] getPoint() { public double[] getPoint() {
return new double[]{ jobActivity.getLocation().getCoordinate().getX(), jobActivity.getLocation().getCoordinate().getY() }; return new double[]{jobActivity.getLocation().getCoordinate().getX(), jobActivity.getLocation().getCoordinate().getY()};
} }
public TourActivity.JobActivity getActivity(){ public TourActivity.JobActivity getActivity() {
return jobActivity; return jobActivity;
} }
} }
private Logger logger = LogManager.getLogger(RuinClusters.class); private Logger logger = LogManager.getLogger(RuinClusters.class);
private VehicleRoutingProblem vrp; private VehicleRoutingProblem vrp;
private JobNeighborhoods jobNeighborhoods; private JobNeighborhoods jobNeighborhoods;
private int noClusters = 2; private int noClusters = 2;
private int minPts = 1; private int minPts = 1;
private double epsFactor = 0.8; private double epsFactor = 0.8;
public RuinClusters(VehicleRoutingProblem vrp, final int initialNumberJobsToRemove, JobNeighborhoods jobNeighborhoods) { public RuinClusters(VehicleRoutingProblem vrp, final int initialNumberJobsToRemove, JobNeighborhoods jobNeighborhoods) {
super(vrp); super(vrp);
this.vrp = vrp; this.vrp = vrp;
setRuinShareFactory(new RuinShareFactory() { setRuinShareFactory(new RuinShareFactory() {
@Override @Override
public int createNumberToBeRemoved() { public int createNumberToBeRemoved() {
return initialNumberJobsToRemove; return initialNumberJobsToRemove;
} }
}); });
this.jobNeighborhoods = jobNeighborhoods; this.jobNeighborhoods = jobNeighborhoods;
logger.debug("initialise {}", this); logger.debug("initialise {}", this);
} }
public void setNoClusters(int noClusters) { public void setNoClusters(int noClusters) {
this.noClusters = noClusters; this.noClusters = noClusters;
} }
/** /**
* Removes a fraction of jobs from vehicleRoutes. * Removes a fraction of jobs from vehicleRoutes.
* * <p/>
* <p>The number of jobs is calculated as follows: Math.ceil(vrp.getJobs().values().size() * fractionOfAllNodes2beRuined). * <p>The number of jobs is calculated as follows: Math.ceil(vrp.getJobs().values().size() * fractionOfAllNodes2beRuined).
*/ */
@Override @Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) { public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) {
List<Job> unassignedJobs = new ArrayList<Job>(); List<Job> unassignedJobs = new ArrayList<Job>();
int nOfJobs2BeRemoved = getRuinShareFactory().createNumberToBeRemoved(); int nOfJobs2BeRemoved = getRuinShareFactory().createNumberToBeRemoved();
ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs); ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs);
return unassignedJobs; return unassignedJobs;
} }
/** /**
* Removes nOfJobs2BeRemoved from vehicleRoutes, including targetJob. * Removes nOfJobs2BeRemoved from vehicleRoutes, including targetJob.
*/ */
@Override @Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) {
throw new IllegalStateException("not supported"); throw new IllegalStateException("not supported");
} }
private void ruin(Collection<VehicleRoute> vehicleRoutes, int nOfJobs2BeRemoved, List<Job> unassignedJobs) { private void ruin(Collection<VehicleRoute> vehicleRoutes, int nOfJobs2BeRemoved, List<Job> unassignedJobs) {
if(vrp.getJobs().values().size() == 0) return; if (vrp.getJobs().values().size() == 0) return;
Map<Job,VehicleRoute> mappedRoutes = map(vehicleRoutes); Map<Job, VehicleRoute> mappedRoutes = map(vehicleRoutes);
int toRemove = nOfJobs2BeRemoved; int toRemove = nOfJobs2BeRemoved;
Collection<Job> lastRemoved = new ArrayList<Job>(); Collection<Job> lastRemoved = new ArrayList<Job>();
Set<VehicleRoute> ruined = new HashSet<VehicleRoute>(); Set<VehicleRoute> ruined = new HashSet<VehicleRoute>();
Set<Job> removed = new HashSet<Job>(); Set<Job> removed = new HashSet<Job>();
Set<VehicleRoute> cycleCandidates = new HashSet<VehicleRoute>(); Set<VehicleRoute> cycleCandidates = new HashSet<VehicleRoute>();
while(toRemove > 0) { while (toRemove > 0) {
Job target; Job target;
VehicleRoute targetRoute = null; VehicleRoute targetRoute = null;
if(lastRemoved.isEmpty()){ if (lastRemoved.isEmpty()) {
target = RandomUtils.nextJob(vrp.getJobs().values(), random); target = RandomUtils.nextJob(vrp.getJobs().values(), random);
targetRoute = mappedRoutes.get(target); targetRoute = mappedRoutes.get(target);
} } else {
else{ target = RandomUtils.nextJob(lastRemoved, random);
target = RandomUtils.nextJob(lastRemoved, random); Iterator<Job> neighborIterator = jobNeighborhoods.getNearestNeighborsIterator(nOfJobs2BeRemoved, target);
Iterator<Job> neighborIterator = jobNeighborhoods.getNearestNeighborsIterator(nOfJobs2BeRemoved,target); while (neighborIterator.hasNext()) {
while(neighborIterator.hasNext()){ Job j = neighborIterator.next();
Job j = neighborIterator.next(); if (!removed.contains(j) && !ruined.contains(mappedRoutes.get(j))) {
if(!removed.contains(j) && !ruined.contains(mappedRoutes.get(j))){ targetRoute = mappedRoutes.get(j);
targetRoute = mappedRoutes.get(j); break;
break; }
} }
} lastRemoved.clear();
lastRemoved.clear(); }
} if (targetRoute == null) break;
if(targetRoute == null) break; if (cycleCandidates.contains(targetRoute)) break;
if(cycleCandidates.contains(targetRoute)) break; if (ruined.contains(targetRoute)) {
if(ruined.contains(targetRoute)) { cycleCandidates.add(targetRoute);
cycleCandidates.add(targetRoute); break;
break; }
} DBSCANClusterer dbscan = new DBSCANClusterer(vrp.getTransportCosts());
DBSCANClusterer dbscan = new DBSCANClusterer(vrp.getTransportCosts()); dbscan.setRandom(random);
dbscan.setRandom(random); dbscan.setMinPts(minPts);
dbscan.setMinPts(minPts); dbscan.setEpsFactor(epsFactor);
dbscan.setEpsFactor(epsFactor); List<Job> cluster = dbscan.getRandomCluster(targetRoute);
List<Job> cluster = dbscan.getRandomCluster(targetRoute); for (Job j : cluster) {
for(Job j : cluster){ if (toRemove == 0) break;
if(toRemove == 0) break; if (removeJob(j, vehicleRoutes)) {
if(removeJob(j, vehicleRoutes)) { lastRemoved.add(j);
lastRemoved.add(j); unassignedJobs.add(j);
unassignedJobs.add(j); }
} toRemove--;
toRemove--; }
} ruined.add(targetRoute);
ruined.add(targetRoute); }
} }
}
private List<JobActivityWrapper> wrap(List<TourActivity> activities) { private List<JobActivityWrapper> wrap(List<TourActivity> activities) {
List<JobActivityWrapper> wl = new ArrayList<JobActivityWrapper>(); List<JobActivityWrapper> wl = new ArrayList<JobActivityWrapper>();
for(TourActivity act : activities){ for (TourActivity act : activities) {
wl.add(new JobActivityWrapper((TourActivity.JobActivity) act)); wl.add(new JobActivityWrapper((TourActivity.JobActivity) act));
} }
return wl; return wl;
} }
private Map<Job, VehicleRoute> map(Collection<VehicleRoute> vehicleRoutes) { private Map<Job, VehicleRoute> map(Collection<VehicleRoute> vehicleRoutes) {
Map<Job,VehicleRoute> map = new HashMap<Job, VehicleRoute>(vrp.getJobs().size()); Map<Job, VehicleRoute> map = new HashMap<Job, VehicleRoute>(vrp.getJobs().size());
for(VehicleRoute r : vehicleRoutes){ for (VehicleRoute r : vehicleRoutes) {
for(Job j : r.getTourActivities().getJobs()){ for (Job j : r.getTourActivities().getJobs()) {
map.put(j,r); map.put(j, r);
} }
} }
return map; return map;
} }
@Override @Override
public String toString() { public String toString() {
return "[name=clusterRuin]"; return "[name=clusterRuin]";
} }
} }

View file

@ -25,52 +25,49 @@ import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
/** /**
* Ensures load constraint for inserting ServiceActivity. * Ensures load constraint for inserting ServiceActivity.
* * <p/>
* <p>When using this, you need to use<br> * <p>When using this, you need to use<br>
* *
*
* @author schroeder * @author schroeder
*
*/ */
public class ServiceLoadActivityLevelConstraint implements HardActivityConstraint { public class ServiceLoadActivityLevelConstraint implements HardActivityConstraint {
private RouteAndActivityStateGetter stateManager; private RouteAndActivityStateGetter stateManager;
private Capacity defaultValue; private Capacity defaultValue;
public ServiceLoadActivityLevelConstraint(RouteAndActivityStateGetter stateManager) { public ServiceLoadActivityLevelConstraint(RouteAndActivityStateGetter stateManager) {
super(); super();
this.stateManager = stateManager; this.stateManager = stateManager;
defaultValue = Capacity.Builder.newInstance().build(); defaultValue = Capacity.Builder.newInstance().build();
} }
@Override @Override
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
Capacity futureMaxLoad; Capacity futureMaxLoad;
Capacity prevMaxLoad; Capacity prevMaxLoad;
if(prevAct instanceof Start){ if (prevAct instanceof Start) {
futureMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.MAXLOAD, Capacity.class); futureMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.MAXLOAD, Capacity.class);
if(futureMaxLoad == null) futureMaxLoad = defaultValue; if (futureMaxLoad == null) futureMaxLoad = defaultValue;
prevMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class); prevMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class);
if(prevMaxLoad == null) prevMaxLoad = defaultValue; if (prevMaxLoad == null) prevMaxLoad = defaultValue;
} } else {
else{ futureMaxLoad = stateManager.getActivityState(prevAct, InternalStates.FUTURE_MAXLOAD, Capacity.class);
futureMaxLoad = stateManager.getActivityState(prevAct, InternalStates.FUTURE_MAXLOAD, Capacity.class); if (futureMaxLoad == null) futureMaxLoad = defaultValue;
if(futureMaxLoad == null) futureMaxLoad = defaultValue; prevMaxLoad = stateManager.getActivityState(prevAct, InternalStates.PAST_MAXLOAD, Capacity.class);
prevMaxLoad = stateManager.getActivityState(prevAct, InternalStates.PAST_MAXLOAD, Capacity.class); if (prevMaxLoad == null) prevMaxLoad = defaultValue;
if(prevMaxLoad == null) prevMaxLoad = defaultValue;
} }
if(newAct instanceof PickupService || newAct instanceof ServiceActivity){ if (newAct instanceof PickupService || newAct instanceof ServiceActivity) {
if(!Capacity.addup(newAct.getSize(), futureMaxLoad).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions())){ if (!Capacity.addup(newAct.getSize(), futureMaxLoad).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions())) {
return ConstraintsStatus.NOT_FULFILLED; return ConstraintsStatus.NOT_FULFILLED;
} }
} }
if(newAct instanceof DeliverService){ if (newAct instanceof DeliverService) {
if(!Capacity.addup(Capacity.invert(newAct.getSize()), prevMaxLoad).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions())){ if (!Capacity.addup(Capacity.invert(newAct.getSize()), prevMaxLoad).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions())) {
return ConstraintsStatus.NOT_FULFILLED_BREAK; return ConstraintsStatus.NOT_FULFILLED_BREAK;
} }
} }
return ConstraintsStatus.FULFILLED; return ConstraintsStatus.FULFILLED;
} }
} }

View file

@ -72,7 +72,7 @@ class TimeWindowConstraint implements HardActivityConstraint {
return ConstraintsStatus.NOT_FULFILLED_BREAK; return ConstraintsStatus.NOT_FULFILLED_BREAK;
} }
/* /*
* if the latest operation start-time of new activity is smaller than the earliest start of prev. activity, * if the latest operation start-time of new activity is smaller than the earliest start of prev. activity,
* then * then
* *
* |--- prevAct ---| * |--- prevAct ---|
@ -83,7 +83,7 @@ class TimeWindowConstraint implements HardActivityConstraint {
} }
/* /*
* |--- prevAct ---| * |--- prevAct ---|
* |- earliest arrival of vehicle * |- earliest arrival of vehicle
* |--- nextAct ---| * |--- nextAct ---|
*/ */

View file

@ -79,7 +79,7 @@ public class VehicleDependentTimeWindowConstraints implements HardActivityConstr
return ConstraintsStatus.NOT_FULFILLED_BREAK; return ConstraintsStatus.NOT_FULFILLED_BREAK;
} }
/* /*
* if the latest operation start-time of new activity is smaller than the earliest start of prev. activity, * if the latest operation start-time of new activity is smaller than the earliest start of prev. activity,
* then * then
* *
* |--- prevAct ---| * |--- prevAct ---|
@ -90,7 +90,7 @@ public class VehicleDependentTimeWindowConstraints implements HardActivityConstr
} }
/* /*
* |--- prevAct ---| * |--- prevAct ---|
* |- earliest arrival of vehicle * |- earliest arrival of vehicle
* |--- nextAct ---| * |--- nextAct ---|
*/ */

View file

@ -18,13 +18,6 @@
package jsprit.core.algorithm; package jsprit.core.algorithm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.List;
import jsprit.core.algorithm.box.GreedySchrimpfFactory; import jsprit.core.algorithm.box.GreedySchrimpfFactory;
import jsprit.core.algorithm.box.Jsprit; import jsprit.core.algorithm.box.Jsprit;
import jsprit.core.algorithm.box.Jsprit.Builder; import jsprit.core.algorithm.box.Jsprit.Builder;
@ -53,9 +46,13 @@ import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.reporting.SolutionPrinter; import jsprit.core.reporting.SolutionPrinter;
import jsprit.core.util.Coordinate; import jsprit.core.util.Coordinate;
import jsprit.core.util.Solutions; import jsprit.core.util.Solutions;
import org.junit.Test; import org.junit.Test;
import java.util.Collection;
import java.util.List;
import static org.junit.Assert.*;
public class InitialRoutesTest { public class InitialRoutesTest {
@Test @Test
@ -396,9 +393,9 @@ public class InitialRoutesTest {
} }
@Test @Test
public void whenAllJobsInInitialRoute_itShouldWork(){ public void whenAllJobsInInitialRoute_itShouldWork() {
Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance(0,10)).build(); Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance(0, 10)).build();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build();
VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(v).addService(s).build(); VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(v).addService(s).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addInitialVehicleRoute(iniRoute).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addInitialVehicleRoute(iniRoute).build();
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
@ -406,18 +403,18 @@ public class InitialRoutesTest {
vra.searchSolutions(); vra.searchSolutions();
assertTrue(true); assertTrue(true);
} }
@Test @Test
public void buildWithoutTimeConstraints() { public void buildWithoutTimeConstraints() {
Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(0,10)).addSizeDimension(0, 10).build(); Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(0, 10)).addSizeDimension(0, 10).build();
Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(10,20)).addSizeDimension(0, 12).build(); Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(10, 20)).addSizeDimension(0, 12).build();
VehicleTypeImpl vt = VehicleTypeImpl.Builder.newInstance("vt").addCapacityDimension(0, 15).build(); VehicleTypeImpl vt = VehicleTypeImpl.Builder.newInstance("vt").addCapacityDimension(0, 15).build();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setType(vt).setStartLocation(Location.newInstance(0,0)).build(); VehicleImpl v = VehicleImpl.Builder.newInstance("v").setType(vt).setStartLocation(Location.newInstance(0, 0)).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s1).addJob(s2).addVehicle(v).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s1).addJob(s2).addVehicle(v).build();
Builder algBuilder = Jsprit.Builder.newInstance(vrp).addCoreStateAndConstraintStuff(false); Builder algBuilder = Jsprit.Builder.newInstance(vrp).addCoreStateAndConstraintStuff(false);
// only required constraints // only required constraints
StateManager stateManager = new StateManager(vrp); StateManager stateManager = new StateManager(vrp);
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager); ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
@ -426,16 +423,16 @@ public class InitialRoutesTest {
stateManager.updateLoadStates(); stateManager.updateLoadStates();
stateManager.addStateUpdater(new UpdateEndLocationIfRouteIsOpen()); stateManager.addStateUpdater(new UpdateEndLocationIfRouteIsOpen());
stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager)); stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
algBuilder.setStateAndConstraintManager(stateManager, constraintManager); algBuilder.setStateAndConstraintManager(stateManager, constraintManager);
VehicleRoutingAlgorithm vra = algBuilder.buildAlgorithm(); VehicleRoutingAlgorithm vra = algBuilder.buildAlgorithm();
vra.setMaxIterations(20); vra.setMaxIterations(20);
Collection<VehicleRoutingProblemSolution> searchSolutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> searchSolutions = vra.searchSolutions();
VehicleRoutingProblemSolution bestOf = Solutions.bestOf(searchSolutions); VehicleRoutingProblemSolution bestOf = Solutions.bestOf(searchSolutions);
//ensure 2 routes //ensure 2 routes
assertEquals(2, bestOf.getRoutes().size()); assertEquals(2, bestOf.getRoutes().size());
//ensure no time information in first service of first route //ensure no time information in first service of first route
assertEquals(0, bestOf.getRoutes().iterator().next().getActivities().iterator().next().getArrTime(), 0.001); assertEquals(0, bestOf.getRoutes().iterator().next().getActivities().iterator().next().getArrTime(), 0.001);
} }

View file

@ -118,14 +118,14 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT {
Vehicle bigVehicle = vehicleBuilder.build(); Vehicle bigVehicle = vehicleBuilder.build();
/* /*
* start building the problem * start building the problem
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.setFleetSize(FleetSize.INFINITE); vrpBuilder.setFleetSize(FleetSize.INFINITE);
vrpBuilder.addVehicle(bigVehicle); vrpBuilder.addVehicle(bigVehicle);
/* /*
* create cost-matrix * create cost-matrix
*/ */
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true); VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
/* /*

View file

@ -118,14 +118,14 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndD
Vehicle bigVehicle = vehicleBuilder.build(); Vehicle bigVehicle = vehicleBuilder.build();
/* /*
* start building the problem * start building the problem
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.setFleetSize(FleetSize.INFINITE); vrpBuilder.setFleetSize(FleetSize.INFINITE);
vrpBuilder.addVehicle(bigVehicle); vrpBuilder.addVehicle(bigVehicle);
/* /*
* create cost-matrix * create cost-matrix
*/ */
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true); VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
/* /*

View file

@ -67,10 +67,10 @@ public class RefuseCollection_IT {
vrpBuilder.addVehicle(bigVehicle); vrpBuilder.addVehicle(bigVehicle);
/* /*
* create cost-matrix * create cost-matrix
*/ */
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true); VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
/* /*
* read demand quantities * read demand quantities
*/ */
readDemandQuantitiesAsServices(vrpBuilder); readDemandQuantitiesAsServices(vrpBuilder);

View file

@ -44,7 +44,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));
@ -52,7 +52,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
VehicleImpl vehicle = vehicleBuilder.build(); VehicleImpl vehicle = vehicleBuilder.build();
/* /*
* build shipments at the required locations, each with a capacity-demand of 1. * build shipments at the required locations, each with a capacity-demand of 1.
* 4 shipments * 4 shipments
* 1: (5,7)->(6,9) * 1: (5,7)->(6,9)
* 2: (5,13)->(6,11) * 2: (5,13)->(6,11)

View file

@ -1,256 +1,255 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<problem xmlns="http://www.w3schools.com" <problem xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd"> <problemType>
<problemType> <fleetSize>FINITE</fleetSize>
<fleetSize>FINITE</fleetSize> </problemType>
</problemType> <vehicles>
<vehicles> <vehicle>
<vehicle> <id>v3</id>
<id>v3</id> <typeId>vehType2</typeId>
<typeId>vehType2</typeId> <startLocation>
<startLocation> <id>startLoc</id>
<id>startLoc</id> <coord x="10.0" y="100.0"/>
<coord x="10.0" y="100.0"/> </startLocation>
</startLocation> <endLocation>
<endLocation> <id>endLoc</id>
<id>endLoc</id> <coord x="1000.0" y="2000.0"/>
<coord x="1000.0" y="2000.0"/> </endLocation>
</endLocation> <timeSchedule>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v2</id>
<typeId>vehType2</typeId>
<startLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>false</returnToDepot>
</vehicle>
<vehicle>
<id>v4</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v5</id>
<typeId>vehType3</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType2</id>
<capacity-dimensions>
<dimension index="0">200</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType3</id>
<capacity-dimensions>
<dimension index="0">100</dimension>
<dimension index="1">1000</dimension>
<dimension index="2">10000</dimension>
<dimension index="3">0</dimension>
<dimension index="4">0</dimension>
<dimension index="5">0</dimension>
<dimension index="6">0</dimension>
<dimension index="7">0</dimension>
<dimension index="8">0</dimension>
<dimension index="9">0</dimension>
<dimension index="10">100000</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
<service id="1" type="service">
<location>
<id>j(1,5)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start> <start>0.0</start>
<end>4000.0</end> <end>1000.0</end>
</timeWindow> </timeSchedule>
</timeWindows> <returnToDepot>true</returnToDepot>
</service> </vehicle>
<service id="2" type="service"> <vehicle>
<location> <id>v2</id>
<id>i(3,9)</id> <typeId>vehType2</typeId>
<coord x="10.0" y="10.0"/> <startLocation>
</location> <id>depotLoc</id>
<capacity-dimensions> <coord x="10.0" y="100.0"/>
<dimension index="0">1</dimension> </startLocation>
</capacity-dimensions> <endLocation>
<duration>0.0</duration> <id>depotLoc</id>
<timeWindows> <coord x="10.0" y="100.0"/>
<timeWindow> </endLocation>
<timeSchedule>
<start>0.0</start> <start>0.0</start>
<end>4000.0</end> <end>1000.0</end>
</timeWindow> </timeSchedule>
</timeWindows> <returnToDepot>false</returnToDepot>
</service> </vehicle>
</services> <vehicle>
<shipments> <id>v4</id>
<shipment id="3"> <typeId>vehType2</typeId>
<pickup> <startLocation>
<location> <id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v5</id>
<typeId>vehType3</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType2</id>
<capacity-dimensions>
<dimension index="0">200</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType3</id>
<capacity-dimensions>
<dimension index="0">100</dimension>
<dimension index="1">1000</dimension>
<dimension index="2">10000</dimension>
<dimension index="3">0</dimension>
<dimension index="4">0</dimension>
<dimension index="5">0</dimension>
<dimension index="6">0</dimension>
<dimension index="7">0</dimension>
<dimension index="8">0</dimension>
<dimension index="9">0</dimension>
<dimension index="10">100000</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
<service id="1" type="service">
<location>
<id>j(1,5)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>i(3,9)</id> <id>i(3,9)</id>
<coord x="10.0" y="10.0"/> <coord x="10.0" y="10.0"/>
</location> </location>
<duration>10.0</duration> <capacity-dimensions>
<timeWindows> <dimension index="0">1</dimension>
</capacity-dimensions>
<duration>0.0</duration>
<timeWindows>
<timeWindow> <timeWindow>
<start>1000.0</start> <start>0.0</start>
<end>4000.0</end> <end>4000.0</end>
</timeWindow> </timeWindow>
</timeWindows> </timeWindows>
</pickup> </service>
<delivery> </services>
<location> <shipments>
<id>i(9,9)</id> <shipment id="3">
<coord x="10.0" y="0.0"/> <pickup>
</location> <location>
<duration>100.0</duration> <id>i(3,9)</id>
<timeWindows> <coord x="10.0" y="10.0"/>
<timeWindow> </location>
<start>6000.0</start> <duration>10.0</duration>
<end>10000.0</end> <timeWindows>
</timeWindow> <timeWindow>
</timeWindows> <start>1000.0</start>
</delivery> <end>4000.0</end>
<capacity-dimensions> </timeWindow>
<dimension index="0">10</dimension> </timeWindows>
</capacity-dimensions> </pickup>
</shipment> <delivery>
<shipment id="4"> <location>
<pickup> <id>i(9,9)</id>
<location> <coord x="10.0" y="0.0"/>
<id>[x=10.0][y=10.0]</id> </location>
<coord x="10.0" y="10.0"/> <duration>100.0</duration>
</location> <timeWindows>
<duration>0.0</duration> <timeWindow>
<timeWindows> <start>6000.0</start>
<timeWindow> <end>10000.0</end>
<start>1000.0</start> </timeWindow>
<end>4000.0</end> </timeWindows>
</timeWindow> </delivery>
</timeWindows> <capacity-dimensions>
</pickup> <dimension index="0">10</dimension>
<delivery> </capacity-dimensions>
<location> </shipment>
<id>[x=10.0][y=0.0]</id> <shipment id="4">
<coord x="10.0" y="0.0"/> <pickup>
</location> <location>
<duration>100.0</duration> <id>[x=10.0][y=10.0]</id>
<timeWindows> <coord x="10.0" y="10.0"/>
<timeWindow> </location>
<start>6000.0</start> <duration>0.0</duration>
<end>10000.0</end> <timeWindows>
</timeWindow> <timeWindow>
</timeWindows> <start>1000.0</start>
</delivery> <end>4000.0</end>
<capacity-dimensions> </timeWindow>
<dimension index="0">10</dimension> </timeWindows>
</capacity-dimensions> </pickup>
</shipment> <delivery>
</shipments> <location>
<initialRoutes> <id>[x=10.0][y=0.0]</id>
<route> <coord x="10.0" y="0.0"/>
<driverId>noDriver</driverId> </location>
<vehicleId>v1</vehicleId> <duration>100.0</duration>
<start>10.0</start> <timeWindows>
<act type="pickupShipment"> <timeWindow>
<shipmentId>4</shipmentId> <start>6000.0</start>
<arrTime>0.0</arrTime> <end>10000.0</end>
<endTime>0.0</endTime> </timeWindow>
</act> </timeWindows>
<act type="deliverShipment"> </delivery>
<shipmentId>4</shipmentId> <capacity-dimensions>
<arrTime>0.0</arrTime> <dimension index="0">10</dimension>
<endTime>0.0</endTime> </capacity-dimensions>
</act> </shipment>
<end>0.0</end> </shipments>
</route> <initialRoutes>
</initialRoutes> <route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>10.0</start>
<act type="pickupShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<act type="deliverShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</initialRoutes>
</problem> </problem>

View file

@ -1,91 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<problem xmlns="http://www.w3schools.com" <problem xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd"> <problemType>
<problemType> <fleetSize>INFINITE</fleetSize>
<fleetSize>INFINITE</fleetSize> </problemType>
</problemType> <vehicles>
<vehicles> <vehicle>
<vehicle> <id>v1</id>
<id>v1</id> <typeId>vehType</typeId>
<typeId>vehType</typeId> <startLocation>
<startLocation> <id>loc</id>
<id>loc</id> </startLocation>
</startLocation> <endLocation>
<endLocation> <id>loc</id>
<id>loc</id> </endLocation>
</endLocation> <timeSchedule>
<timeSchedule>
<start>0.0</start>
<end>1.7976931348623157E308</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>1.0</distance>
<time>0.0</time>
</costs>
</type>
</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> <start>0.0</start>
<end>1.7976931348623157E308</end> <end>1.7976931348623157E308</end>
</timeWindow> </timeSchedule>
</timeWindows> <returnToDepot>true</returnToDepot>
</service> </vehicle>
<service id="2" type="service"> </vehicles>
<location> <vehicleTypes>
<id>loc2</id> <type>
</location> <id>vehType</id>
<capacity-dimensions> <capacity-dimensions>
<dimension index="0">1</dimension> <dimension index="0">20</dimension>
</capacity-dimensions> </capacity-dimensions>
<duration>4.0</duration> <costs>
<timeWindows> <fixed>0.0</fixed>
<timeWindow> <distance>1.0</distance>
<start>0.0</start> <time>0.0</time>
<end>1.7976931348623157E308</end> </costs>
</timeWindow> </type>
</timeWindows> </vehicleTypes>
</service> <services>
</services> <service id="1" type="service">
<solutions> <location>
<solution> <id>loc</id>
<cost>10.0</cost> </location>
<routes> <capacity-dimensions>
<route> <dimension index="0">1</dimension>
<driverId>noDriver</driverId> </capacity-dimensions>
<vehicleId>v1</vehicleId> <duration>2.0</duration>
<start>0.0</start> <timeWindows>
<act type="service"> <timeWindow>
<serviceId>1</serviceId> <start>0.0</start>
<arrTime>0.0</arrTime> <end>1.7976931348623157E308</end>
<endTime>0.0</endTime> </timeWindow>
</act> </timeWindows>
<end>0.0</end> </service>
</route> <service id="2" type="service">
</routes> <location>
<unassignedJobs> <id>loc2</id>
<job id="2"/> </location>
</unassignedJobs> <capacity-dimensions>
</solution> <dimension index="0">1</dimension>
</solutions> </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>

View file

@ -382,8 +382,8 @@ public class BicycleMessenger {
String line; String line;
boolean firstLine = true; boolean firstLine = true;
VehicleType messengerType = VehicleTypeImpl.Builder.newInstance("messengerType").addCapacityDimension(0, 15).setCostPerDistance(1).build(); VehicleType messengerType = VehicleTypeImpl.Builder.newInstance("messengerType").addCapacityDimension(0, 15).setCostPerDistance(1).build();
/* /*
* the algo requires some time and space to search for a valid solution. if you ommit a penalty-type, it probably throws an Exception once it cannot insert an envelope anymore * the algo requires some time and space to search for a valid solution. if you ommit a penalty-type, it probably throws an Exception once it cannot insert an envelope anymore
* thus, give it space by defining a penalty/shadow vehicle with higher variable and fixed costs to up the pressure to find solutions without penalty type * thus, give it space by defining a penalty/shadow vehicle with higher variable and fixed costs to up the pressure to find solutions without penalty type
* *
* it is important to give it the same typeId as the type you want to shadow * it is important to give it the same typeId as the type you want to shadow

View file

@ -46,13 +46,13 @@ public class ConfigureAlgorithmInCodeInsteadOfPerXml {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));

View file

@ -59,7 +59,7 @@ public class CostMatrixExample {
/* /*
* Assume the following symmetric distance-matrix * Assume the following symmetric distance-matrix
* from,to,distance * from,to,distance
* 0,1,10.0 * 0,1,10.0
* 0,2,20.0 * 0,2,20.0

View file

@ -49,14 +49,14 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndOpenRoutesExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
vehicleTypeBuilder.setCostPerDistance(1.0); vehicleTypeBuilder.setCostPerDistance(1.0);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* define two vehicles and their start-locations * define two vehicles and their start-locations
* *
* the first two do need to return to depot * the first two do need to return to depot
*/ */

View file

@ -48,8 +48,8 @@ public class MultipleDepotExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* Read cordeau-instance p01, BUT only its services without any vehicles * Read cordeau-instance p01, BUT only its services without any vehicles
*/ */
new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_01.xml"); new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_01.xml");

View file

@ -50,8 +50,8 @@ public class MultipleDepotExample2 {
Examples.createOutputFolder(); Examples.createOutputFolder();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* Read cordeau-instance p01, BUT only its services without any vehicles * Read cordeau-instance p01, BUT only its services without any vehicles
*/ */
new CordeauReader(vrpBuilder).read("input/p08"); new CordeauReader(vrpBuilder).read("input/p08");

View file

@ -45,8 +45,8 @@ public class MultipleDepotWithInitialRoutesExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* Read cordeau-instance p01 * Read cordeau-instance p01
*/ */
new VrpXMLReader(vrpBuilder).read("input/cordeau01.xml"); new VrpXMLReader(vrpBuilder).read("input/cordeau01.xml");

View file

@ -43,14 +43,14 @@ public class PickupAndDeliveryExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101_withoutTWs.xml"); new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101_withoutTWs.xml");

View file

@ -49,12 +49,12 @@ public class PickupAndDeliveryExample2 {
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/pd_christophides_vrpnc1_vcap50.xml"); new VrpXMLReader(vrpBuilder).read("input/pd_christophides_vrpnc1_vcap50.xml");
/* /*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances). * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/ */
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();

View file

@ -41,14 +41,14 @@ public class PickupAndDeliveryOpenExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101_withoutTWs_open.xml"); new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101_withoutTWs_open.xml");

View file

@ -55,7 +55,7 @@ public class RefuseCollectionExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* create vehicle-type and vehicle * create vehicle-type and vehicle
*/ */
VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("vehicle-type").addCapacityDimension(0, 23); VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("vehicle-type").addCapacityDimension(0, 23);
typeBuilder.setCostPerDistance(1.0); typeBuilder.setCostPerDistance(1.0);
@ -67,7 +67,7 @@ public class RefuseCollectionExample {
VehicleImpl bigVehicle = vehicleBuilder.build(); VehicleImpl bigVehicle = vehicleBuilder.build();
/* /*
* start building the problem * start building the problem
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.setFleetSize(FleetSize.INFINITE); vrpBuilder.setFleetSize(FleetSize.INFINITE);

View file

@ -54,7 +54,7 @@ public class RefuseCollectionWithFastMatrixExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* create vehicle-type and vehicle * create vehicle-type and vehicle
*/ */
VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("vehicle-type").addCapacityDimension(0, 23); VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("vehicle-type").addCapacityDimension(0, 23);
typeBuilder.setCostPerDistance(1.0); typeBuilder.setCostPerDistance(1.0);
@ -66,7 +66,7 @@ public class RefuseCollectionWithFastMatrixExample {
VehicleImpl bigVehicle = vehicleBuilder.build(); VehicleImpl bigVehicle = vehicleBuilder.build();
/* /*
* start building the problem * start building the problem
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.setFleetSize(FleetSize.INFINITE); vrpBuilder.setFleetSize(FleetSize.INFINITE);

View file

@ -47,14 +47,14 @@ public class ServicePickupsWithMultipleDepotsExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 8); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 8);
vehicleTypeBuilder.setCostPerDistance(1.0); vehicleTypeBuilder.setCostPerDistance(1.0);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* define two depots, i.e. two vehicle locations ([10,10],[50,50]) and equip them with an infinite number of vehicles of type 'vehicleType' * define two depots, i.e. two vehicle locations ([10,10],[50,50]) and equip them with an infinite number of vehicles of type 'vehicleType'
*/ */
Builder vehicleBuilder1 = VehicleImpl.Builder.newInstance("vehicles@[10,10]"); Builder vehicleBuilder1 = VehicleImpl.Builder.newInstance("vehicles@[10,10]");
vehicleBuilder1.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder1.setStartLocation(Location.newInstance(10, 10));

View file

@ -46,13 +46,13 @@ public class SimpleDepotBoundedPickupAndDeliveryExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));

View file

@ -47,13 +47,13 @@ public class SimpleEnRoutePickupAndDeliveryExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(loc(Coordinate.newInstance(10, 10))); vehicleBuilder.setStartLocation(loc(Coordinate.newInstance(10, 10)));

View file

@ -46,13 +46,13 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(loc(Coordinate.newInstance(10, 10))); vehicleBuilder.setStartLocation(loc(Coordinate.newInstance(10, 10)));

View file

@ -49,13 +49,13 @@ public class SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(loc(Coordinate.newInstance(10, 10))); vehicleBuilder.setStartLocation(loc(Coordinate.newInstance(10, 10)));

View file

@ -52,14 +52,14 @@ public class SimpleExample {
} }
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and one capacity dimension, i.e. weight, and capacity dimension value of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and one capacity dimension, i.e. weight, and capacity dimension value of 2
*/ */
final int WEIGHT_INDEX = 0; final int WEIGHT_INDEX = 0;
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(WEIGHT_INDEX, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(WEIGHT_INDEX, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));

View file

@ -44,14 +44,14 @@ public class SimpleExampleOpenRoutes {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
vehicleTypeBuilder.setFixedCost(100); vehicleTypeBuilder.setFixedCost(100);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));

View file

@ -54,14 +54,14 @@ public class SimpleExampleWithSkills {
} }
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and one capacity dimension, i.e. weight, and capacity dimension value of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and one capacity dimension, i.e. weight, and capacity dimension value of 2
*/ */
final int WEIGHT_INDEX = 0; final int WEIGHT_INDEX = 0;
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(WEIGHT_INDEX, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(WEIGHT_INDEX, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = Builder.newInstance("vehicle"); Builder vehicleBuilder = Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));

View file

@ -49,13 +49,13 @@ public class SimpleVRPWithBackhaulsExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2); VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType").addCapacityDimension(0, 2);
VehicleType vehicleType = vehicleTypeBuilder.build(); VehicleType vehicleType = vehicleTypeBuilder.build();
/* /*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/ */
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10)); vehicleBuilder.setStartLocation(Location.newInstance(10, 10));

View file

@ -40,14 +40,14 @@ public class SolomonExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new SolomonReader(vrpBuilder).read("input/C101_solomon.txt"); new SolomonReader(vrpBuilder).read("input/C101_solomon.txt");

View file

@ -47,14 +47,14 @@ public class SolomonExampleWithSpecifiedVehicleEndLocations {
} }
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_specifiedVehicleEndLocations_c101.xml"); new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_specifiedVehicleEndLocations_c101.xml");

View file

@ -46,14 +46,14 @@ public class SolomonExampleWithSpecifiedVehicleEndLocationsWithoutTWs {
} }
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_c101_withoutTWs_and_specifiedVehicleEndLocations.xml"); new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_c101_withoutTWs_and_specifiedVehicleEndLocations.xml");

View file

@ -40,14 +40,14 @@ public class SolomonOpenExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_open_c101.xml"); new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_open_c101.xml");

View file

@ -39,14 +39,14 @@ public class SolomonR101Example {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
// new SolomonReader(vrpBuilder).read("/Users/schroeder/IdeaProjects/jsprit/jsprit-instances/instances/solomon/R211.txt"); // new SolomonReader(vrpBuilder).read("/Users/schroeder/IdeaProjects/jsprit/jsprit-instances/instances/solomon/R211.txt");
new VrpXMLReader(vrpBuilder).read("output/R211.xml"); new VrpXMLReader(vrpBuilder).read("output/R211.xml");

View file

@ -42,14 +42,14 @@ public class SolomonWithRegretInsertionExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new SolomonReader(vrpBuilder).read("input/C101_solomon.txt"); new SolomonReader(vrpBuilder).read("input/C101_solomon.txt");

View file

@ -55,7 +55,7 @@ public class TransportOfDisabledPeople {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2 * get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
*/ */
VehicleTypeImpl.Builder wheelChairTypeBuilder = VehicleTypeImpl.Builder.newInstance("wheelChairBusType") VehicleTypeImpl.Builder wheelChairTypeBuilder = VehicleTypeImpl.Builder.newInstance("wheelChairBusType")
.addCapacityDimension(WHEELCHAIRSPACE_INDEX, 2) //can transport two people with wheelchair .addCapacityDimension(WHEELCHAIRSPACE_INDEX, 2) //can transport two people with wheelchair
@ -67,7 +67,7 @@ public class TransportOfDisabledPeople {
VehicleType vehicleType_solelypassenger = soleyPassengerTypeBuilder.build(); VehicleType vehicleType_solelypassenger = soleyPassengerTypeBuilder.build();
/* /*
* define two vehicles and their locations. * define two vehicles and their locations.
* *
* this example employs two vehicles. one that has to return to its start-location (vehicle1) and one that has a different * this example employs two vehicles. one that has to return to its start-location (vehicle1) and one that has a different
* end-location. * end-location.

View file

@ -43,14 +43,14 @@ public class VRPWithBackhaulsExample {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101.xml"); new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_solomon_r101.xml");

View file

@ -48,14 +48,14 @@ public class VRPWithBackhaulsExample2 {
Examples.createOutputFolder(); Examples.createOutputFolder();
/* /*
* Build the problem. * Build the problem.
* *
* But define a problem-builder first. * But define a problem-builder first.
*/ */
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/ */
new VrpXMLReader(vrpBuilder).read("input/pd_christophides_vrpnc1_vcap50.xml"); new VrpXMLReader(vrpBuilder).read("input/pd_christophides_vrpnc1_vcap50.xml");