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

remove deprecated code for next development iteration, i.e. release

1.3.0
This commit is contained in:
oblonski 2014-05-16 06:27:49 +02:00
parent 3afae5de91
commit 3771c8494d
56 changed files with 173 additions and 1602 deletions

View file

@ -1,391 +0,0 @@
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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/>.
******************************************************************************/
package jsprit.analysis.toolbox;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Delivery;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Locations;
import org.apache.log4j.Logger;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataItem;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
/**
* A plotter to plot vehicle-routing-solution and routes respectively.
*
* @author stefan schroeder
*
*/
@Deprecated
public class SolutionPlotter {
private static class NoLocationFoundException extends Exception{
/**
*
*/
private static final long serialVersionUID = 1L;
}
private static Logger log = Logger.getLogger(SolutionPlotter.class);
/**
* Plots the {@link VehicleRoutingProblem} to png-file.
* @param vrp
* @param pngFile target path with filename.
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
*/
@Deprecated
public static void plotVrpAsPNG(VehicleRoutingProblem vrp, String pngFile, String title){
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
log.info("plot routes to " + filename);
XYSeriesCollection problem;
Map<XYDataItem,String> labels = new HashMap<XYDataItem, String>();
try {
problem = makeVrpSeries(vrp, labels);
} catch (NoLocationFoundException e) {
log.warn("cannot plot vrp, since coord is missing");
return;
}
XYPlot plot = createPlot(problem, labels);
JFreeChart chart = new JFreeChart(title, plot);
save(chart,filename);
}
/**
* Retrieves the problem from routes, and plots it along with the routes to pngFile.
*
* @param routes
* @param locations indicating the locations for the tour-activities.
* @param pngFile target path with filename.
* @param plotTitle
* @see VehicleRoute
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
*/
@Deprecated
public static void plotRoutesAsPNG(Collection<VehicleRoute> routes, Locations locations, String pngFile, String title) {
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
log.info("plot routes to " + filename);
XYSeriesCollection problem;
Map<XYDataItem,String> labels = new HashMap<XYDataItem, String>();
try {
problem = makeVrpSeries(routes, labels);
} catch (NoLocationFoundException e) {
log.warn("cannot plot vrp, since coord is missing");
return;
}
XYSeriesCollection solutionColl = makeSolutionSeries(routes,locations);
XYPlot plot = createPlot(problem, solutionColl, labels);
JFreeChart chart = new JFreeChart(title, plot);
save(chart,filename);
}
/**
* Plots problem and solution to pngFile.
*
* <p>This can only plot if vehicles and jobs have locationIds and coordinates (@see Coordinate). Otherwise a warning message is logged
* and method returns but does not plot.
*
* @param vrp
* @param solution
* @param pngFile target path with filename.
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
*/
@Deprecated
public static void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
log.info("plot solution to " + filename);
XYSeriesCollection problem;
XYSeriesCollection solutionColl;
Map<XYDataItem,String> labels = new HashMap<XYDataItem, String>();
try {
problem = makeVrpSeries(vrp, labels);
solutionColl = makeSolutionSeries(vrp, solution);
} catch (NoLocationFoundException e) {
log.warn("cannot plot vrp, since coord is missing");
return;
}
XYPlot plot = createPlot(problem, solutionColl, labels);
JFreeChart chart = new JFreeChart(title, plot);
save(chart,filename);
}
private static XYPlot createPlot(final XYSeriesCollection problem, final Map<XYDataItem, String> labels) {
XYPlot plot = new XYPlot();
plot.setBackgroundPaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.WHITE);
plot.setDomainGridlinePaint(Color.WHITE);
XYItemRenderer problemRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only
// problemRenderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() {
//
// @Override
// public String generateLabel(XYDataset arg0, int arg1, int arg2) {
// XYDataItem item = problem.getSeries(arg1).getDataItem(arg2);
// return labels.get(item);
// }
// });
problemRenderer.setBaseItemLabelsVisible(true);
problemRenderer.setBaseItemLabelPaint(Color.BLACK);
NumberAxis xAxis = new NumberAxis();
xAxis.setRangeWithMargins(problem.getDomainBounds(true));
NumberAxis yAxis = new NumberAxis();
yAxis.setRangeWithMargins(problem.getRangeBounds(false));
plot.setDataset(0, problem);
plot.setRenderer(0, problemRenderer);
plot.setDomainAxis(0, xAxis);
plot.setRangeAxis(0, yAxis);
return plot;
}
private static XYPlot createPlot(final XYSeriesCollection problem, XYSeriesCollection solutionColl, final Map<XYDataItem, String> labels) {
XYPlot plot = new XYPlot();
plot.setBackgroundPaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.WHITE);
plot.setDomainGridlinePaint(Color.WHITE);
XYItemRenderer problemRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only
// problemRenderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() {
//
// @Override
// public String generateLabel(XYDataset arg0, int arg1, int arg2) {
// XYDataItem item = problem.getSeries(arg1).getDataItem(arg2);
// return labels.get(item);
// }
// });
problemRenderer.setBaseItemLabelsVisible(true);
problemRenderer.setBaseItemLabelPaint(Color.BLACK);
NumberAxis xAxis = new NumberAxis();
xAxis.setRangeWithMargins(problem.getDomainBounds(true));
NumberAxis yAxis = new NumberAxis();
yAxis.setRangeWithMargins(problem.getRangeBounds(true));
plot.setDataset(0, problem);
plot.setRenderer(0, problemRenderer);
plot.setDomainAxis(0, xAxis);
plot.setRangeAxis(0, yAxis);
XYItemRenderer solutionRenderer = new XYLineAndShapeRenderer(true, false); // Lines only
// for(int i=0;i<solutionColl.getSeriesCount();i++){
// XYSeries s = solutionColl.getSeries(i);
// XYDataItem firstCustomer = s.getDataItem(1);
// solutionRenderer.addAnnotation(new XYShapeAnnotation( new Ellipse2D.Double(firstCustomer.getXValue()-0.7, firstCustomer.getYValue()-0.7, 1.5, 1.5), new BasicStroke(1.0f), Color.RED));
// }
plot.setDataset(1, solutionColl);
plot.setRenderer(1, solutionRenderer);
plot.setDomainAxis(1, xAxis);
plot.setRangeAxis(1, yAxis);
return plot;
}
private static void save(JFreeChart chart, String pngFile) {
try {
ChartUtilities.saveChartAsPNG(new File(pngFile), chart, 1000, 600);
} catch (IOException e) {
log.error("cannot plot");
log.error(e);
e.printStackTrace();
}
}
private static XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) throws NoLocationFoundException{
Locations locations = retrieveLocations(vrp);
XYSeriesCollection coll = new XYSeriesCollection();
int counter = 1;
for(VehicleRoute route : solution.getRoutes()){
if(route.isEmpty()) continue;
XYSeries series = new XYSeries(counter, false, true);
Coordinate startCoord = locations.getCoord(route.getStart().getLocationId());
series.add(startCoord.getX(), startCoord.getY());
for(TourActivity act : route.getTourActivities().getActivities()){
Coordinate coord = locations.getCoord(act.getLocationId());
series.add(coord.getX(), coord.getY());
}
Coordinate endCoord = locations.getCoord(route.getEnd().getLocationId());
series.add(endCoord.getX(), endCoord.getY());
coll.addSeries(series);
counter++;
}
return coll;
}
private static XYSeriesCollection makeSolutionSeries(Collection<VehicleRoute> routes, Locations locations){
XYSeriesCollection coll = new XYSeriesCollection();
int counter = 1;
for(VehicleRoute route : routes){
if(route.isEmpty()) continue;
XYSeries series = new XYSeries(counter, false, true);
Coordinate startCoord = locations.getCoord(route.getStart().getLocationId());
series.add(startCoord.getX(), startCoord.getY());
for(TourActivity act : route.getTourActivities().getActivities()){
Coordinate coord = locations.getCoord(act.getLocationId());
series.add(coord.getX(), coord.getY());
}
Coordinate endCoord = locations.getCoord(route.getEnd().getLocationId());
series.add(endCoord.getX(), endCoord.getY());
coll.addSeries(series);
counter++;
}
return coll;
}
private static XYSeriesCollection makeVrpSeries(Collection<Vehicle> vehicles, Collection<Job> services, Map<XYDataItem, String> labels) throws NoLocationFoundException{
XYSeriesCollection coll = new XYSeriesCollection();
XYSeries vehicleSeries = new XYSeries("depot", false, true);
for(Vehicle v : vehicles){
Coordinate coord = v.getStartLocationCoordinate();
if(coord == null) throw new NoLocationFoundException();
vehicleSeries.add(coord.getX(),coord.getY());
}
coll.addSeries(vehicleSeries);
XYSeries serviceSeries = new XYSeries("service", false, true);
XYSeries pickupSeries = new XYSeries("pickup", false, true);
XYSeries deliverySeries = new XYSeries("delivery", false, true);
for(Job job : services){
if(job instanceof Pickup){
Pickup service = (Pickup)job;
Coordinate coord = service.getCoord();
XYDataItem dataItem = new XYDataItem(coord.getX(), coord.getY());
pickupSeries.add(dataItem);
labels.put(dataItem, String.valueOf(service.getCapacityDemand()));
}
else if(job instanceof Delivery){
Delivery service = (Delivery)job;
Coordinate coord = service.getCoord();
XYDataItem dataItem = new XYDataItem(coord.getX(), coord.getY());
deliverySeries.add(dataItem);
labels.put(dataItem, String.valueOf(service.getCapacityDemand()));
}
else if(job instanceof Service){
Service service = (Service)job;
Coordinate coord = service.getCoord();
XYDataItem dataItem = new XYDataItem(coord.getX(), coord.getY());
serviceSeries.add(dataItem);
labels.put(dataItem, String.valueOf(service.getCapacityDemand()));
}
else{
throw new IllegalStateException("job instanceof " + job.getClass().toString() + ". this is not supported.");
}
}
if(!serviceSeries.isEmpty()) coll.addSeries(serviceSeries);
if(!pickupSeries.isEmpty()) coll.addSeries(pickupSeries);
if(!deliverySeries.isEmpty()) coll.addSeries(deliverySeries);
return coll;
}
private static XYSeriesCollection makeVrpSeries(Collection<VehicleRoute> routes, Map<XYDataItem, String> labels) throws NoLocationFoundException{
Set<Vehicle> vehicles = new HashSet<Vehicle>();
Set<Job> jobs = new HashSet<Job>();
for(VehicleRoute route : routes){
vehicles.add(route.getVehicle());
jobs.addAll(route.getTourActivities().getJobs());
}
return makeVrpSeries(vehicles, jobs, labels);
}
private static XYSeriesCollection makeVrpSeries(VehicleRoutingProblem vrp, Map<XYDataItem, String> labels) throws NoLocationFoundException{
return makeVrpSeries(vrp.getVehicles(), vrp.getJobs().values(), labels);
}
private static Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException {
final Map<String, Coordinate> locs = new HashMap<String, Coordinate>();
for(Vehicle v : vrp.getVehicles()){
String startLocationId = v.getStartLocationId();
if(startLocationId == null) throw new NoLocationFoundException();
Coordinate coord = v.getStartLocationCoordinate();
if(coord == null) throw new NoLocationFoundException();
locs.put(startLocationId, coord);
}
for(Job j : vrp.getJobs().values()){
if(j instanceof Service){
String locationId = ((Service) j).getLocationId();
if(locationId == null) throw new NoLocationFoundException();
Coordinate coord = ((Service) j).getCoord();
if(coord == null) throw new NoLocationFoundException();
locs.put(locationId, coord);
}
else{
throw new IllegalStateException("job is not a service. this is not supported yet.");
}
}
return new Locations() {
@Override
public Coordinate getCoord(String id) {
return locs.get(id);
}
};
}
}

View file

@ -140,39 +140,4 @@ public class SolutionPrinter {
return new Jobs(nServices,nShipments);
}
// /**
// * Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE.
// *
// * <p>CONCISE prints total-costs and #vehicles.
// * <p>VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator)
// * is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs.
// *
// * @param solution
// * @param level
// *
// * @deprecated is not going to work anymore
// */
// @Deprecated
// public static void print(VehicleRoutingProblemSolution solution, Print level){
// if(level.equals(Print.CONCISE)){
// print(solution);
// }
// else{
// print(solution);
// System.out.println("routes");
// int routeCount = 1;
// for(VehicleRoute route : solution.getRoutes()){
// System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]");
// if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){
// DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator();
// System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() +
// "][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]");
// }
// routeCount++;
// }
// }
//
//
// }
}

View file

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Collection;
import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
import jsprit.core.algorithm.acceptor.SolutionAcceptor;
import jsprit.core.algorithm.listener.AlgorithmEndsListener;
import jsprit.core.algorithm.listener.AlgorithmStartsListener;
import jsprit.core.algorithm.listener.IterationEndsListener;
@ -29,7 +28,6 @@ import jsprit.core.algorithm.listener.SearchStrategyListener;
import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListener;
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners;
import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
import jsprit.core.algorithm.termination.PrematureAlgorithmTermination;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
@ -121,20 +119,10 @@ public class VehicleRoutingAlgorithm {
}
/**
* Sets premature break.
* Sets premature termination.
*
* <p>This breaks the algorithm prematurely after the assigned number of iterations without improvement (see input parameter).
* Improvement is what {@link SolutionAcceptor} understands about improvement. Or to put it in other words, the algo breaks prematurely after
* the assigned number of iterations without solution-acceptance.
*
* @deprecated use setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(int nuIterationsWithoutImprovement));
* @param nuIterationsWithoutImprovement
* @param prematureAlgorithmTermination
*/
@Deprecated
public void setPrematureBreak(int nuIterationsWithoutImprovement){
prematureAlgorithmTermination = new IterationWithoutImprovementTermination(nuIterationsWithoutImprovement);
}
public void setPrematureAlgorithmTermination(PrematureAlgorithmTermination prematureAlgorithmTermination){
this.prematureAlgorithmTermination = prematureAlgorithmTermination;
}

View file

@ -40,8 +40,9 @@ public class AlgorithmConfigXmlReader {
/**
* @param schemaValidation the schemaValidation to set
*/
public void setSchemaValidation(boolean schemaValidation) {
public AlgorithmConfigXmlReader setSchemaValidation(boolean schemaValidation) {
this.schemaValidation = schemaValidation;
return this;
}
public AlgorithmConfigXmlReader(AlgorithmConfig algorithmConfig){

View file

@ -397,11 +397,6 @@ public class VehicleRoutingAlgorithms {
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0, null);
}
@Deprecated
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, final XMLConfiguration config){
return createAlgo(vrp,config,0, null);
}
/**
* Read and creates a {@link VehicleRoutingAlgorithm} from an url.
*

View file

@ -44,7 +44,6 @@ import jsprit.core.problem.solution.route.activity.ReverseActivityVisitor;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
import jsprit.core.problem.solution.route.state.StateFactory;
import jsprit.core.problem.solution.route.state.StateFactory.State;
import jsprit.core.problem.solution.route.state.StateFactory.StateId;
/**
@ -114,17 +113,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
private boolean updateTWs = false;
/**
* @deprecated use <code>StateManager(VehicleRoutingTransportCosts tpcosts)</code> instead.
* @param vrp
*/
@Deprecated
public StateManager(VehicleRoutingProblem vrp) {
super();
this.routingCosts = vrp.getTransportCosts();
addDefaultStates();
}
private void addDefaultStates() {
defaultActivityStates_.put(StateFactory.LOAD, Capacity.Builder.newInstance().build());
defaultActivityStates_.put(StateFactory.COSTS, 0.);
@ -171,16 +159,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
return null;
}
/**
* @deprecated use the generic methode <code>addDefaultRouteState(StateId stateId, Class<T> type, T defaultState)</code> instead.
* @param stateId
* @param defaultState
*/
@Deprecated
public void addDefaultRouteState(StateId stateId, State defaultState){
addDefaultRouteState(stateId, State.class, defaultState);
}
/**
* Generic method to add a default route state.
*
@ -197,16 +175,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
defaultRouteStates_.put(stateId, type.cast(defaultState));
}
/**
* @deprecated use generic method <code>addDefaultActivityState(StateId stateId, Class<T> type, T defaultState)</code>
* @param stateId
* @param defaultState
*/
@Deprecated
public void addDefaultActivityState(StateId stateId, State defaultState){
addDefaultActivityState(stateId, State.class, defaultState);
}
/**
* Generic method to add default activity state.
*
@ -229,23 +197,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
problemStates_.clear();
}
/**
* @Deprecated use generic method instead <code>getActivityState(TourActivity act, StateId stateId, Class<T> type)</code>
*/
@Deprecated
@Override
public State getActivityState(TourActivity act, StateId stateId) {
if(!activityStates_.containsKey(act)){
return getDefaultTypedActivityState(act,stateId,State.class);
}
States_ actStates = activityStates_.get(act);
State state = actStates.getState(stateId, State.class);
if(state == null){
return getDefaultTypedActivityState(act,stateId,State.class);
}
return state;
}
/**
* Returns activity state of type 'type'.
*
@ -305,18 +256,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
return null;
}
/**
*
* @param act
* @param stateId
* @param state
* @deprecated use generic method <code>putTypedActivityState(TourActivity act, StateId stateId, Class<T> type, T state)</code> instead
*/
@Deprecated
public void putActivityState(TourActivity act, StateId stateId, State state){
putTypedActivityState(act, stateId, State.class, state);
}
/**
* Generic method to memorize state 'state' of type 'type' of act and stateId.
*
@ -336,11 +275,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
putInternalTypedActivityState(act, stateId, type, state);
}
@Deprecated
void putInternalActivityState(TourActivity act, StateId stateId, State state){
putInternalTypedActivityState(act, stateId, State.class, state);
}
<T> void putInternalTypedActivityState(TourActivity act, StateId stateId, Class<T> type, T state){
if(!activityStates_.containsKey(act)){
activityStates_.put(act, new States_());
@ -349,11 +283,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
actStates.putState(stateId, type, state);
}
@Deprecated
void putInternalRouteState(VehicleRoute route, StateId stateId, State state){
putTypedInternalRouteState(route, stateId, State.class, state);
}
<T> void putTypedInternalRouteState(VehicleRoute route, StateId stateId, Class<T> type, T state){
if(!vehicleRouteStates_.containsKey(route)){
vehicleRouteStates_.put(route, new States_());
@ -362,11 +291,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
routeStates.putState(stateId, type, state);
}
@Deprecated
public void putRouteState(VehicleRoute route, StateId stateId, State state){
putTypedRouteState(route, stateId, State.class, state);
}
/**
* Generic method to memorize state 'state' of type 'type' of route and stateId.
*
@ -386,20 +310,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
putTypedInternalRouteState(route, stateId, type, state);
}
@Deprecated
@Override
public State getRouteState(VehicleRoute route, StateId stateId) {
if(!vehicleRouteStates_.containsKey(route)){
return getDefaultTypedRouteState(stateId,State.class);
}
States_ routeStates = vehicleRouteStates_.get(route);
State state = routeStates.getState(stateId,State.class);
if(state == null){
return getDefaultTypedRouteState(stateId, State.class);
}
return state;
}
/**
* Adds state updater.
*

View file

@ -42,7 +42,6 @@ import jsprit.core.problem.vehicle.VehicleTypeKey;
import jsprit.core.util.Coordinate;
import jsprit.core.util.CrowFlyCosts;
import jsprit.core.util.Locations;
import jsprit.core.util.Neighborhood;
import org.apache.log4j.Logger;
@ -64,20 +63,6 @@ import org.apache.log4j.Logger;
*/
public class VehicleRoutingProblem {
/**
* Overall problem constraints.
*
* <p>DELIVERIES_FIRST corresponds to the vehicle routing problem with back hauls, i.e. before a vehicle is not entirely unloaded, no pickup can be made.
*
* @deprecated define and add constraint directly with .addConstraint(...) - since constraints are too diverse to put them in an enum
* @author stefan
*
*/
@Deprecated
public enum Constraint {
DELIVERIES_FIRST
}
/**
* Builder to build the routing-problem.
*
@ -109,49 +94,27 @@ public class VehicleRoutingProblem {
};
private Map<String,Job> jobs;
private Map<String,Job> jobs = new HashMap<String, Job>();
private Map<String,Job> tentativeJobs = new HashMap<String,Job>();
private Set<String> jobsInInitialRoutes = new HashSet<String>();
private Collection<Service> services;
private Collection<Service> services = new ArrayList<Service>();
private Map<String, Coordinate> coordinates;
private Map<String, Coordinate> coordinates = new HashMap<String, Coordinate>();
private Map<String, Coordinate> tentative_coordinates = new HashMap<String, Coordinate>();
private FleetSize fleetSize = FleetSize.INFINITE;
/**
* @deprecated is not going to be used anymore
*/
private FleetComposition fleetComposition = FleetComposition.HOMOGENEOUS;
private Collection<VehicleType> vehicleTypes;
private Collection<VehicleType> vehicleTypes = new ArrayList<VehicleType>();
private Collection<VehicleRoute> initialRoutes = new ArrayList<VehicleRoute>();
private Set<Vehicle> uniqueVehicles = new HashSet<Vehicle>();
/**
* @deprecated is not going to be used anymore
*/
private Collection<Constraint> problemConstraints;
private Collection<jsprit.core.problem.constraint.Constraint> constraints;
/**
* by default all locations are neighbors
* @deprecated is not going to be used anymore
*/
private Neighborhood neighborhood = new Neighborhood() {
@Override
public boolean areNeighbors(String location1, String location2) {
return true;
}
};
private Collection<jsprit.core.problem.constraint.Constraint> constraints = new ArrayList<jsprit.core.problem.constraint.Constraint>();
private boolean addPenaltyVehicles = false;
@ -159,20 +122,6 @@ public class VehicleRoutingProblem {
private Double penaltyFixedCosts = null;
/**
* @deprecated use static method .newInstance() instead
*/
@Deprecated
public Builder() {
jobs = new HashMap<String, Job>();
new ArrayList<Vehicle>();
coordinates = new HashMap<String, Coordinate>();
vehicleTypes = new ArrayList<VehicleType>();
services = new ArrayList<Service>();
problemConstraints = new ArrayList<VehicleRoutingProblem.Constraint>();
constraints = new ArrayList<jsprit.core.problem.constraint.Constraint>();
}
/**
* Create a location (i.e. coordinate) and returns the key of the location which is Coordinate.toString().
*
@ -517,43 +466,15 @@ public class VehicleRoutingProblem {
return Collections.unmodifiableCollection(tentativeJobs.values());
}
/**
* Gets an unmodifiable collection of already added services.
*
* @return collection of services
* @deprecated use .getAddedJobs() instead
*/
@Deprecated
public Collection<Service> getAddedServices(){
return Collections.unmodifiableCollection(services);
}
/**
* Sets the fleetComposition.
*
* <p>FleetComposition is either FleetComposition.HETEROGENEOUS or FleetComposition.HOMOGENEOUS
*
* @deprecated has no effect
* @param fleetComposition
* @return
*/
@Deprecated
public Builder setFleetComposition(FleetComposition fleetComposition){
this.fleetComposition = fleetComposition;
return this;
}
/**
* Adds a service to jobList.
*
* <p>If jobList already contains service, a warning message is printed, and the existing job will be overwritten.
*
* @deprecated use addJob(...) instead
* @param service
* @return
*/
@Deprecated
public Builder addService(Service service){
private Builder addService(Service service){
coordinates.put(service.getLocationId(), service.getCoord());
if(jobs.containsKey(service.getId())){ logger.warn("service " + service + " already in job list. overrides existing job."); }
jobs.put(service.getId(),service);
@ -561,41 +482,7 @@ public class VehicleRoutingProblem {
return this;
}
/**
* Adds a vehicleType.
*
* @deprecated use add vehicle instead
* @param type
* @return builder
*/
@Deprecated
public Builder addVehicleType(VehicleType type){
vehicleTypes.add(type);
return this;
}
/**
* Sets the neighborhood.
*
* @deprecated use HardRoute- or ActivityLevelConstraint instead
* @param neighborhood
* @return
*/
@Deprecated
public Builder setNeighborhood(Neighborhood neighborhood){
this.neighborhood = neighborhood;
return this;
}
/**
*
* @deprecated use .addConstraint(new ServiceDeliveriesFirstConstraint())
* @param constraint
*/
@Deprecated
public void addProblemConstraint(Constraint constraint){
if(!problemConstraints.contains(constraint)) problemConstraints.add(constraint);
}
}
/**
@ -664,33 +551,14 @@ public class VehicleRoutingProblem {
private final Locations locations;
/**
* @deprecated not used anymore
*/
private Neighborhood neighborhood;
/**
* An enum that indicates fleetSizeComposition. By default, it is HOMOGENOUS.
* @deprecated
*/
private FleetComposition fleetComposition;
/**
* @deprecated
*/
private Collection<Constraint> problemConstraints;
private VehicleRoutingProblem(Builder builder) {
this.jobs = builder.jobs;
this.fleetComposition = builder.fleetComposition;
this.fleetSize = builder.fleetSize;
this.vehicles=builder.uniqueVehicles;
this.vehicleTypes = builder.vehicleTypes;
this.initialVehicleRoutes = builder.initialRoutes;
this.transportCosts = builder.transportCosts;
this.activityCosts = builder.activityCosts;
this.neighborhood = builder.neighborhood;
this.problemConstraints = builder.problemConstraints;
this.constraints = builder.constraints;
this.locations = builder.getLocations();
logger.info("initialise " + this);
@ -777,36 +645,4 @@ public class VehicleRoutingProblem {
return locations;
}
/**
* Returns fleet-composition.
*
* @return fleetComposition which is either FleetComposition.HETEROGENEOUS or FleetComposition.HOMOGENEOUS
* @deprecated it is not used and thus has no effect
*/
@Deprecated
public FleetComposition getFleetComposition() {
return fleetComposition;
}
/**
* @deprecated see builder.setNeighborhood(...). addConstraint(...) instead.
* @return the neighborhood
*/
@Deprecated
public Neighborhood getNeighborhood() {
return neighborhood;
}
/**
* Returns unmodifiable collection of problem-constraints.
*
* @deprecated use .getConstraints() and builder.add
* @return
*/
@Deprecated
public Collection<Constraint> getProblemConstraints(){
return Collections.unmodifiableCollection(problemConstraints);
}
}

View file

@ -6,7 +6,6 @@ import java.util.Collections;
import java.util.List;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.Constraint;
import jsprit.core.problem.misc.JobInsertionContext;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
@ -19,7 +18,6 @@ import org.apache.log4j.Logger;
* @author schroeder
*
*/
@SuppressWarnings("deprecation")
public class ConstraintManager implements HardActivityStateLevelConstraint, HardRouteStateLevelConstraint, SoftActivityConstraint, SoftRouteConstraint{
public static enum Priority {
@ -91,9 +89,6 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard
public void addLoadConstraint(){
if(!loadConstraintsSet){
if(vrp.getProblemConstraints().contains(Constraint.DELIVERIES_FIRST)){
addConstraint(new ServiceDeliveriesFirstConstraint(),Priority.HIGH);
}
addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL);
addConstraint(new ServiceLoadRouteLevelConstraint(stateManager));
addConstraint(new ServiceLoadActivityLevelConstraint(stateManager),Priority.LOW);

View file

@ -27,7 +27,6 @@ import java.util.Map;
import java.util.Set;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetComposition;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.driver.Driver;
import jsprit.core.problem.driver.DriverImpl;
@ -56,8 +55,6 @@ import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@SuppressWarnings("deprecation")
public class VrpXMLReader{
public interface ServiceBuilderFactory {
@ -69,15 +66,15 @@ public class VrpXMLReader{
@Override
public jsprit.core.problem.job.Service.Builder createBuilder(String serviceType, String id, Integer size) {
if(serviceType.equals("pickup")){
if(size != null) return Pickup.Builder.newInstance(id, size);
if(size != null) return Pickup.Builder.newInstance(id).addSizeDimension(0, size);
else return Pickup.Builder.newInstance(id);
}
else if(serviceType.equals("delivery")){
if(size != null) return Delivery.Builder.newInstance(id, size);
if(size != null) return Delivery.Builder.newInstance(id).addSizeDimension(0, size);
else return Delivery.Builder.newInstance(id);
}
else{
if(size != null) return Service.Builder.newInstance(id, size);
if(size != null) return Service.Builder.newInstance(id).addSizeDimension(0, size);
else return Service.Builder.newInstance(id);
}
@ -367,14 +364,6 @@ public class VrpXMLReader{
if(fleetSize == null) vrpBuilder.setFleetSize(FleetSize.INFINITE);
else if(fleetSize.toUpperCase().equals(FleetSize.INFINITE.toString())) vrpBuilder.setFleetSize(FleetSize.INFINITE);
else vrpBuilder.setFleetSize(FleetSize.FINITE);
String fleetComposition = vrpProblem.getString("problemType.fleetComposition");
if(fleetComposition == null) vrpBuilder.setFleetComposition(FleetComposition.HOMOGENEOUS);
else if(fleetComposition.toUpperCase().equals(FleetComposition.HETEROGENEOUS.toString())){
vrpBuilder.setFleetComposition(FleetComposition.HETEROGENEOUS);
}
else vrpBuilder.setFleetComposition(FleetComposition.HOMOGENEOUS);
}
private void readShipments(XMLConfiguration config){
@ -394,7 +383,7 @@ public class VrpXMLReader{
Shipment.Builder builder;
if(capacityString != null){
builder = Shipment.Builder.newInstance(id, Integer.parseInt(capacityString));
builder = Shipment.Builder.newInstance(id).addSizeDimension(0, Integer.parseInt(capacityString));
}
else {
builder = Shipment.Builder.newInstance(id);
@ -563,7 +552,7 @@ public class VrpXMLReader{
VehicleTypeImpl.Builder typeBuilder;
if(capacityString != null){
typeBuilder = VehicleTypeImpl.Builder.newInstance(typeId, Integer.parseInt(capacityString));
typeBuilder = VehicleTypeImpl.Builder.newInstance(typeId).addCapacityDimension(0, Integer.parseInt(capacityString));
}
else {
typeBuilder = VehicleTypeImpl.Builder.newInstance(typeId);

View file

@ -268,10 +268,8 @@ public class VrpXMLWriter {
}
}
@SuppressWarnings("deprecation")
private void writeProblemType(XMLConfiguration xmlConfig){
xmlConfig.setProperty("problemType.fleetSize", vrp.getFleetSize());
xmlConfig.setProperty("problemType.fleetComposition", vrp.getFleetComposition());
}
private void writeVehiclesAndTheirTypes(XMLConfiguration xmlConfig) {

View file

@ -27,23 +27,6 @@ public class Delivery extends Service{
public static class Builder extends Service.Builder {
/**
* Returns a new instance of Delivery.Builder
*
* @param id
* @param size
* @return builder
* @throws IllegalArgumentException if size < 0 or id is null
* @deprecated use <code>.newInstance(String id)</code> instead, and add a capacity dimension
* with dimensionIndex='your index' and and dimsionValue=size to the returned builder
*/
@Deprecated
public static Builder newInstance(String id, int size){
Builder builder = new Builder(id,size);
builder.addSizeDimension(0, size);
return builder;
}
/**
* Returns a new instance of builder that builds a delivery.
*

View file

@ -34,17 +34,6 @@ public interface Job {
*/
public String getId();
/**
* Returns capacity (demand) of job.
*
* <p>It determines how much capacity this job consumes of vehicle/transport unit.
*
* @deprecated use <code>.getCapacity()</code> instead
* @return
*/
@Deprecated
public int getCapacityDemand();
/**
* Returns size, i.e. capacity-demand, of this job which can consist of an arbitrary number of capacity dimensions.
*

View file

@ -27,23 +27,6 @@ public class Pickup extends Service {
public static class Builder extends Service.Builder {
/**
* Returns a new instance of Pickup.Builder
*
* @param id
* @param size
* @return builder
* @throws IllegalArgumentException if size < 0 or id is null
* @deprecated use <code>.newInstance(String id)</code> instead, and add a capacity dimension
* with dimensionIndex='your index' and and dimsionValue=size to the returned builder
*/
@Deprecated
public static Builder newInstance(String id, int size){
Builder builder = new Builder(id,size);
builder.addSizeDimension(0, size);
return builder;
}
/**
* Returns a new instance of builder that builds a pickup.
*

View file

@ -41,25 +41,6 @@ public class Service implements Job {
*/
public static class Builder {
/**
* Returns a new instance of service-builder.
*
* <p>Note that if you use this builder, size is assigned to capacity-dimension with index=0.
*
* @param id of service
* @param size of capacity-demand
* @return builder
* @throws IllegalArgumentException if size < 0 or id is null
* @deprecated use <code>.newInstance(String id)</code> instead, and add a capacity dimension
* with dimensionIndex='your index' and and dimsionValue=size to the returned builder
*/
@Deprecated
public static Builder newInstance(String id, int size){
Builder builder = new Builder(id,size);
builder.addSizeDimension(0, size);
return builder;
}
/**
* Returns a new instance of builder that builds a service.
*
@ -267,17 +248,6 @@ public class Service implements Job {
return timeWindow;
}
/**
* @Deprecated use <code>.getCapacity()</code> instead. if you still use this method, it returns the
* capacity dimension with index=0.
*
*/
@Override
@Deprecated
public int getCapacityDemand() {
return size.get(0);
}
/**
* @return the name
*/

View file

@ -54,24 +54,11 @@ public class Shipment implements Job{
private Capacity capacity;
/**
* Returns a new instance of this builder.
*
* <p>Note that if you use this builder, size is assigned to capacity-dimension with index=0.
* Returns new instance of this builder.
*
* @param id
* @param size
* @return builder
* @throws IllegalArgumentException if size < 0 or id is null
* @deprecated use <code>.newInstance(String id)</code> instead, and add a capacity dimension
* with dimensionIndex='your index' and and dimsionValue=size to the returned builder
* @return
*/
@Deprecated
public static Builder newInstance(String id, int size){
Builder builder = new Builder(id,size);
builder.addSizeDimension(0, size);
return builder;
}
public static Builder newInstance(String id){
return new Builder(id);
}
@ -90,6 +77,7 @@ public class Shipment implements Job{
}
Builder(String id){
if(id == null) throw new IllegalArgumentException("id must not be null");
this.id = id;
}
@ -289,16 +277,6 @@ public class Shipment implements Job{
return id;
}
/**
* @Deprecated use <code>.getCapacity()</code> instead. if you still use this method, it returns the
* capacity dimension with index=0.
*/
@Deprecated
@Override
public int getCapacityDemand() {
return capacity.get(0);
}
/**
* Returns the pickup-location.
*

View file

@ -58,20 +58,6 @@ public class VehicleRoute {
return new VehicleRoute(route);
}
/**
* Returns a newInstance of {@link VehicleRoute}.
*
* @param tour
* @param driver
* @param vehicle
* @return VehicleRoute
* @deprecated use VehicleRoute.Builder instead
*/
@Deprecated
public static VehicleRoute newInstance(TourActivities tour, Driver driver, Vehicle vehicle) {
return new VehicleRoute(tour,driver,vehicle);
}
/**
* Returns an empty route.
*
@ -356,16 +342,6 @@ public class VehicleRoute {
this.driver = route.getDriver();
}
@Deprecated
private VehicleRoute(TourActivities tour, Driver driver, Vehicle vehicle) {
super();
verify(tour, driver, vehicle);
this.tourActivities = tour;
this.vehicle = vehicle;
this.driver = driver;
setStartAndEnd(vehicle, vehicle.getEarliestDeparture());
}
/**
* Constructs route.
*
@ -379,22 +355,6 @@ public class VehicleRoute {
this.end = builder.end;
}
/**
*
* @param tour
* @param driver
* @param vehicle
* @deprecated verification is a task of VehicleRoute.Builder
*/
@Deprecated
private void verify(TourActivities tour, Driver driver, Vehicle vehicle) {
if(tour == null || driver == null || vehicle == null) throw new IllegalStateException("null is not allowed for tour, driver or vehicle. use emptyRoute. use Tour.emptyTour, DriverImpl.noDriver() and VehicleImpl.noVehicle() instead." +
"\n\tor make it easier and use VehicleRoute.emptyRoute()");
if(!tour.isEmpty() && vehicle instanceof NoVehicle){
throw new IllegalStateException("if tour is not empty. there must be a vehicle for this tour, but there is no vehicle.");
}
}
/**
* Returns an unmodifiable list of activities on this route (without start/end).
*
@ -450,29 +410,6 @@ public class VehicleRoute {
this.vehicle = vehicle;
setStartAndEnd(vehicle, vehicleDepTime);
}
/**
* Sets the vehicle and its departureTime from <code>vehicle.getStartLocationId()</code>.
*
* <p>This implies the following:<br>
* if start and end are null, new start and end activities are created.<br>
* <p>startActivity is initialized with the start-location of the specified vehicle (<code>vehicle.getStartLocationId()</code>). the time-window of this activity is initialized
* such that [<code>startActivity.getTheoreticalEarliestOperationStartTime()</code> = <code>vehicle.getEarliestDeparture()</code>][<code>startActivity.getTheoreticalLatestOperationStartTime()</code> = <code>vehicle.getLatestArrival()</code>]
* <p>endActivity is initialized with the end-location of the specified vehicle (<code>vehicle.getEndLocationId()</code>). The time-window of the
* endActivity is initialized such that [<code>endActivity.getTheoreticalEarliestOperationStartTime()</code> = <code>vehicle.getEarliestDeparture()</code>][<code>endActivity.getTheoreticalLatestOperationStartTime()</code> = <code>vehicle.getLatestArrival()</code>]
* <p>startActivity.endTime (<code>startActivity.getEndTime()</code>) is set to max{<code>vehicle.getEarliestDeparture()</code>, <code>vehicleDepTime</code>}.
* thus, <code>vehicle.getEarliestDeparture()</code> is a physical constraint that has to be met.
*
* @param vehicle
* @param vehicleDepTime
* @deprecated use .setVehicleAndDepartureTime(Vehicle vehicle, double vehicleDepTime) instead
*/
@Deprecated
public void setVehicle(Vehicle vehicle, double vehicleDepTime){
this.vehicle = vehicle;
setStartAndEnd(vehicle, vehicleDepTime);
}
private void setStartAndEnd(Vehicle vehicle, double vehicleDepTime) {
if(!(vehicle instanceof NoVehicle)){
if(start == null && end == null){
@ -490,19 +427,6 @@ public class VehicleRoute {
}
/**
* Sets departureTime of this route, i.e. the time the vehicle departs from its start-location.
*
* @param vehicleDepTime
* @deprecated use .setVehicleAndDepartureTime(...) instead (vehicle requires departureTime and the other way around, and earliestDepartureTime
* of a vehicle is a physical constraint of the vehicle and cannot be broken. Using this method might break this constraint.)
*/
@Deprecated
public void setDepartureTime(double vehicleDepTime){
if(start == null) throw new IllegalStateException("cannot set departureTime without having a vehicle on this route. use setVehicle(vehicle,departureTime) instead.");
start.setEndTime(vehicleDepTime);
}
/**
* Returns the departureTime of this vehicle in this route.
*

View file

@ -26,15 +26,6 @@ public final class DeliverService implements DeliveryActivity{
capacity = deliveryActivity.getSize();
}
/**
* @deprecated use <code>getCapacity()</code> instead
*/
@Deprecated
@Override
public int getCapacityDemand() {
return delivery.getCapacityDemand()*-1;
}
@Override
public String getName() {
return delivery.getType();

View file

@ -32,15 +32,6 @@ public final class DeliverShipment implements DeliveryActivity{
return shipment;
}
/**
* @deprecated use <code>getCapacity()</code> instead
*/
@Deprecated
@Override
public int getCapacityDemand() {
return shipment.getCapacityDemand()*-1;
}
@Override
public String getName() {
return "deliverShipment";

View file

@ -133,11 +133,6 @@ public final class End implements TourActivity {
}
@Override
public int getCapacityDemand() {
return 0;
}
@Override
public TourActivity duplicate() {
return new End(this);

View file

@ -82,16 +82,6 @@ public final class PickupService implements PickupActivity{
return pickup;
}
/**
* @deprecated use <code>getCapacity()</code> instead
*
*/
@Override
@Deprecated
public int getCapacityDemand() {
return pickup.getCapacityDemand();
}
public String toString() {
return "[type="+getName()+"][locationId=" + getLocationId()
+ "][size=" + getSize().toString()

View file

@ -28,15 +28,6 @@ public final class PickupShipment implements PickupActivity{
return shipment;
}
/**
* @deprecated use <code>getCapacity()</code> instead
*/
@Deprecated
@Override
public int getCapacityDemand() {
return shipment.getCapacityDemand();
}
@Override
public String getName() {
return "pickupShipment";

View file

@ -119,15 +119,6 @@ public class ServiceActivity implements JobActivity{
return service.getTimeWindow().getEnd();
}
/**
* @deprecated use <code>getCapacity()</code> instead
*/
@Override
@Deprecated
public int getCapacityDemand() {
return service.getCapacityDemand();
}
@Override
public double getOperationTime() {
return service.getServiceDuration();

View file

@ -17,7 +17,6 @@
package jsprit.core.problem.solution.route.activity;
import jsprit.core.problem.Capacity;
import jsprit.core.util.Coordinate;
public final class Start implements TourActivity {
@ -38,8 +37,6 @@ public final class Start implements TourActivity {
private String locationId;
private Coordinate coordinate;
private double theoretical_earliestOperationStartTime;
private double theoretical_latestOperationStartTime;
@ -64,16 +61,6 @@ public final class Start implements TourActivity {
endTime = start.getEndTime();
}
@Deprecated
Coordinate getCoordinate() {
return coordinate;
}
@Deprecated
void setCoordinate(Coordinate coordinate) {
this.coordinate = coordinate;
}
public double getTheoreticalEarliestOperationStartTime() {
return theoretical_earliestOperationStartTime;
}
@ -136,11 +123,6 @@ public final class Start implements TourActivity {
this.endTime = endTime;
}
@Override
public int getCapacityDemand() {
return 0;
}
@Override
public TourActivity duplicate() {
return new Start(this);

View file

@ -48,16 +48,6 @@ public interface TourActivity {
}
/**
* Returns the capacity-demand of that activity, in terms of what needs to be loaded or unloaded at
* this activity.
*
* @return int
* @deprecated use <code>getCapacity()</code> instead
*/
@Deprecated
public int getCapacityDemand();
/**
* Returns the name of this activity.
*

View file

@ -18,17 +18,10 @@ package jsprit.core.problem.solution.route.state;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.solution.route.state.StateFactory.State;
import jsprit.core.problem.solution.route.state.StateFactory.StateId;
public interface RouteAndActivityStateGetter {
@Deprecated
public State getActivityState(TourActivity act, StateId stateId);
@Deprecated
public State getRouteState(VehicleRoute route, StateId stateId);
public <T> T getActivityState(TourActivity act, StateId stateId, Class<T> type);
public <T> T getRouteState(VehicleRoute route, StateId stateId, Class<T> type);

View file

@ -79,22 +79,6 @@ class InfiniteVehicles implements VehicleFleetManager{
return types.values();
}
/**
* @deprecated use getAvailableVehicles(Vehicle withoutThisType) instead
*/
@Override
@Deprecated
public Collection<Vehicle> getAvailableVehicles(String withoutThisType, String locationId) {
Collection<Vehicle> vehicles = new ArrayList<Vehicle>();
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType, locationId,locationId, 0., 0.);
for(VehicleTypeKey key : types.keySet()){
if(!key.equals(thisKey)){
vehicles.add(types.get(key));
}
}
return vehicles;
}
@Override
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
Collection<Vehicle> vehicles = new ArrayList<Vehicle>();

View file

@ -45,15 +45,6 @@ public class PenaltyVehicleType implements VehicleType{
return type.getTypeId();
}
/**
* @deprecated use <code>getCapacityDimensions()</code> instead
*/
@Deprecated
@Override
public int getCapacity() {
return type.getCapacity();
}
@Override
public VehicleCostParams getVehicleCostParams() {
return type.getVehicleCostParams();

View file

@ -41,28 +41,6 @@ public interface Vehicle {
*/
public abstract double getLatestArrival();
/**
* Returns the location-id of the this vehicle which should be the start-location of this vehicle.
*
* <p> Consequently, it should be the end-location of this vehicle, if returnToDepot is true.
*
* @return location-id of this vehicle
* @deprecated use getStartLocationId() instead
*/
@Deprecated
public abstract String getLocationId();
/**
* Returns the coordinate of this vehicle which should be the coordinate of the start-location of this vehicle.
*
* <p> Consequently, it should be the coordinate of the end-location, if returnToDepot is true.
*
* @return coordinate of this vehicle
* @deprecated use getStartLocationCoordinate() instead
*/
@Deprecated
public abstract Coordinate getCoord();
/**
* Returns the {@link VehicleType} of this vehicle.
*
@ -77,17 +55,6 @@ public interface Vehicle {
*/
public abstract String getId();
/**
* Returns the capacity of this vehicle.
*
* @return capacity
* @deprecated use .getType().getCapacityDimensions() - if you still use this method,
* but set capacity-dimensions via <code>VehicleTypeImpl.Builder.newInstance(...).addCapacityDimension(...)</code> then this method returns the
* dimension with index=0.
*/
@Deprecated
public abstract int getCapacity();
/**
* Returns true if vehicle returns to depot, false otherwise.
*

View file

@ -63,16 +63,6 @@ public interface VehicleFleetManager {
*/
public abstract Collection<Vehicle> getAvailableVehicles();
/**
*
* @param withoutThisType
* @param locationId
* @return
* @deprecated use .getAvailableVehicles(Vehicle without) instead. this might ignore withoutType and returns all available vehicles
*/
@Deprecated
public Collection<Vehicle> getAvailableVehicles(String withoutThisType, String locationId);
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType);
}

View file

@ -173,38 +173,6 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
return vehicles;
}
/**
* Returns a collection of available vehicles without vehicles with typeId 'withoutThisType' and locationId 'withThisLocation'.
*
* <p>If there is no vehicle with a certain type and location anymore, it looks up whether a penalty vehicle has been specified with
* this type and location. If so, it returns this penalty vehicle. If not, no vehicle with this type and location is returned.
*
* @param typeId to specify the typeId that should not be the returned collection
* @param locationId to specify the locationId that should not be in the returned collection
* @return collection of available vehicles without the vehicles that have the typeId 'withoutThisType' AND the locationId 'withThisLocation'.
* @deprecated use .getAvailableVehicles(Vehicle without) instead - this might ignore withoutThisType and returns all available vehicles
*/
@Override
@Deprecated
public Collection<Vehicle> getAvailableVehicles(String withoutThisType, String withThisLocationId) {
List<Vehicle> vehicles = new ArrayList<Vehicle>();
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType, withThisLocationId, withThisLocationId, 0., 0.);
for(VehicleTypeKey key : typeMapOfAvailableVehicles.keySet()){
if(key.equals(thisKey)) continue;
if(!typeMapOfAvailableVehicles.get(key).isEmpty()){
vehicles.add(typeMapOfAvailableVehicles.get(key).getVehicle());
}
else{
if(penaltyVehicles.containsKey(key)){
vehicles.add(penaltyVehicles.get(key));
}
}
}
return vehicles;
}
@Override
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
List<Vehicle> vehicles = new ArrayList<Vehicle>();

View file

@ -30,16 +30,6 @@ import org.apache.log4j.Logger;
public class VehicleImpl implements Vehicle {
/**
* @deprecated use createNoVehicle() instead.
*
* @return
*/
@Deprecated
public static NoVehicle noVehicle(){
return createNoVehicle();
}
/**
* Extension of {@link VehicleImpl} representing an unspecified vehicle with the id 'noVehicle'
* (to avoid null).
@ -49,13 +39,8 @@ public class VehicleImpl implements Vehicle {
*/
public static class NoVehicle extends VehicleImpl {
@SuppressWarnings("deprecation")
public NoVehicle() {
super(Builder.newInstance("noVehicle").setType(VehicleTypeImpl.newInstance(null, 0, null)));
}
public int getCapacity(){
return 0;
super(Builder.newInstance("noVehicle").setType(VehicleTypeImpl.Builder.newInstance("noType").build()));
}
}
@ -129,38 +114,6 @@ public class VehicleImpl implements Vehicle {
return this;
}
/**
* Sets location-id of the vehicle which should be its start-location.
*
* <p>If returnToDepot is true, it is also its end-location.
*
* @param id
* @return this builder
* @deprecated use setStartLocationId(..) instead
*/
@Deprecated
public Builder setLocationId(String id){
this.locationId = id;
this.startLocationId = id;
return this;
}
/**
* Sets coordinate of the vehicle which should be the coordinate of start-location.
*
* <p>If returnToDepot is true, it is also the coordinate of the end-location.
*
* @param coord
* @return this builder
* @deprecated use setStartLocationCoordinate(...) instead
*/
@Deprecated
public Builder setLocationCoord(Coordinate coord){
this.locationCoord = coord;
this.startLocationCoord = coord;
return this;
}
/**
* Sets the start-location of this vehicle.
*
@ -334,14 +287,6 @@ public class VehicleImpl implements Vehicle {
return "[id="+id+"][type="+type+"][locationId="+locationId+"][coord=" + coord + "][isReturnToDepot=" + isReturnToDepot() + "]";
}
/**
* @deprecated use getStartLocationCoordinate() instead
*/
@Deprecated
public Coordinate getCoord() {
return coord;
}
@Override
public double getEarliestDeparture() {
return earliestDeparture;
@ -352,15 +297,6 @@ public class VehicleImpl implements Vehicle {
return latestArrival;
}
/**
* @deprecated use getStartLocationId() instead
*/
@Deprecated
@Override
public String getLocationId() {
return locationId;
}
@Override
public VehicleType getType() {
return type;
@ -371,12 +307,6 @@ public class VehicleImpl implements Vehicle {
return id;
}
@Override
@Deprecated
public int getCapacity() {
return type.getCapacity();
}
public boolean isReturnToDepot() {
return returnToDepot;
}

View file

@ -34,19 +34,6 @@ public interface VehicleType {
*/
public String getTypeId();
/**
* Returns capacity.
*
* <p>In future versions there will be a capacity-object with an arbitrary number of capacity dimensions. (stefan,11.01.14)
*
*
* @deprecated use <code>.getCapacityDimensions()</code> - if you still use it, but set CapacityDimensions rather
* than setCapacity(...) it will return the capacity.dimension with index=0
* @return cap
*/
@Deprecated
public int getCapacity();
/**
* Returns capacity dimensions.
*

View file

@ -66,32 +66,11 @@ public class VehicleTypeImpl implements VehicleType {
*/
public static class Builder{
/**
* Returns a new instance.
*
* <p>Input parameters are id and capacity. Note that two vehicle-types are equal
* if they have the same vehicleId.
*
* @param id
* @param capacity
* @return the vehicleType builder
* @throws IllegalStateException if capacity is smaller than zero or id is null
* @deprecated use <code>newInstance(String id)</code> instead
*/
@Deprecated
public static VehicleTypeImpl.Builder newInstance(String id, int capacity){
if(capacity < 0) throw new IllegalStateException("capacity cannot be smaller than zero");
if(id == null) throw new IllegalStateException("typeId must be null");
Builder builder = new Builder(id,capacity);
builder.addCapacityDimension(0, capacity);
return builder;
}
public static VehicleTypeImpl.Builder newInstance(String id) {
if(id==null) throw new IllegalStateException();
return new Builder(id);
}
private String id;
private int capacity = 0;
private double maxVelo = Double.MAX_VALUE;
@ -108,20 +87,7 @@ public class VehicleTypeImpl implements VehicleType {
private boolean dimensionAdded = false;
/**
* Constructs the builder.
*
* @param id
* @param capacity
*/
@Deprecated
private Builder(String id, int capacity) {
super();
this.id = id;
this.capacity = capacity;
}
public Builder(String id) {
private Builder(String id) {
this.id = id;
}
@ -272,15 +238,6 @@ public class VehicleTypeImpl implements VehicleType {
private final double maxVelocity;
/**
* @deprecated use builder instead
*/
@Deprecated
public static VehicleTypeImpl newInstance(String typeId, int capacity, VehicleTypeImpl.VehicleCostParams para){
return new VehicleTypeImpl(typeId, capacity, para);
}
/**
* priv constructor constructing vehicle-type
*
@ -294,23 +251,6 @@ public class VehicleTypeImpl implements VehicleType {
capacityDimensions = builder.capacityDimensions;
}
/**
* @deprecated use Builder.newInstance(...) instead.
*
* @param typeId
* @param capacity
* @param vehicleCostParams
*/
@Deprecated
public VehicleTypeImpl(String typeId, int capacity,VehicleTypeImpl.VehicleCostParams vehicleCostParams) {
super();
this.typeId = typeId;
this.capacity = capacity;
this.vehicleCostParams = vehicleCostParams;
this.capacityDimensions = Capacity.Builder.newInstance().addDimension(0, capacity).build();
this.maxVelocity = Double.MAX_VALUE;
}
/* (non-Javadoc)
* @see basics.route.VehicleType#getTypeId()
*/
@ -319,15 +259,6 @@ public class VehicleTypeImpl implements VehicleType {
return typeId;
}
/* (non-Javadoc)
* @see basics.route.VehicleType#getCapacity()
*/
@Override
@Deprecated
public int getCapacity() {
return capacityDimensions.get(0);
}
/* (non-Javadoc)
* @see basics.route.VehicleType#getVehicleCostParams()
*/

View file

@ -140,39 +140,4 @@ public class SolutionPrinter {
return new Jobs(nServices,nShipments);
}
// /**
// * Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE.
// *
// * <p>CONCISE prints total-costs and #vehicles.
// * <p>VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator)
// * is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs.
// *
// * @param solution
// * @param level
// *
// * @deprecated is not going to work anymore
// */
// @Deprecated
// public static void print(VehicleRoutingProblemSolution solution, Print level){
// if(level.equals(Print.CONCISE)){
// print(solution);
// }
// else{
// print(solution);
// System.out.println("routes");
// int routeCount = 1;
// for(VehicleRoute route : solution.getRoutes()){
// System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]");
// if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){
// DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator();
// System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() +
// "][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]");
// }
// routeCount++;
// }
// }
//
//
// }
}

View file

@ -23,23 +23,6 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
public class Solutions {
/**
*
* @deprecated use bestOf instead.
* @param solutions
* @return
*/
@Deprecated
public static VehicleRoutingProblemSolution getBest(Collection<VehicleRoutingProblemSolution> solutions){
VehicleRoutingProblemSolution best = null;
for(VehicleRoutingProblemSolution s : solutions){
if(best == null) best = s;
else if(s.getCost() < best.getCost()) best = s;
}
return best;
}
public static VehicleRoutingProblemSolution bestOf(Collection<VehicleRoutingProblemSolution> solutions){
VehicleRoutingProblemSolution best = null;
for(VehicleRoutingProblemSolution s : solutions){

View file

@ -17,7 +17,7 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="fleetComposition">
<xs:element name="fleetComposition" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="HOMOGENEOUS" />

View file

@ -27,7 +27,6 @@ import jsprit.core.algorithm.SearchStrategyModule;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
import jsprit.core.algorithm.acceptor.SolutionAcceptor;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.ModKey;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.AcceptorKey;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.RuinStrategyKey;
@ -45,14 +44,13 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.junit.Before;
import org.junit.Test;
public class TestAlgorithmReader {
XMLConfiguration config;
AlgorithmConfig config;
VehicleRoutingProblem vrp;
@ -60,7 +58,8 @@ public class TestAlgorithmReader {
@Before
public void doBefore() throws ConfigurationException{
config = new XMLConfiguration("src/test/resources/testConfig.xml");
config = new AlgorithmConfig();
new AlgorithmConfigXmlReader(config).setSchemaValidation(false).read("src/test/resources/testConfig.xml");
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
solutions = new ArrayList<VehicleRoutingProblemSolution>();
new VrpXMLReader(vrpBuilder,solutions).read("src/test/resources/finiteVrp.xml");
@ -216,33 +215,27 @@ public class TestAlgorithmReader {
}
@SuppressWarnings("deprecation")
@Test
public void initialiseConstructionAlgoCorrectly(){
VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
assertTrue(true);
}
@Test
public void whenCreatingAlgorithm_nOfStrategiesIsCorrect(){
@SuppressWarnings("deprecation")
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
assertEquals(3, algo.getSearchStrategyManager().getStrategies().size());
}
@Test
public void whenCreatingAlgorithm_nOfIterationsIsReadCorrectly(){
@SuppressWarnings("deprecation")
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
assertEquals(10, algo.getNuOfIterations());
}
@Test
public void whenCreatingAlgorithm_nOfStrategyModulesIsCorrect(){
@SuppressWarnings("deprecation")
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
int nOfModules = 0;
for(SearchStrategy strat : algo.getSearchStrategyManager().getStrategies()){
nOfModules += strat.getSearchStrategyModules().size();

View file

@ -14,28 +14,6 @@ import org.junit.Test;
public class StateManagerTest {
@SuppressWarnings("deprecation")
@Test
public void whenInternalRouteStateIsSet_itMustBeSetCorrectly(){
VehicleRoute route = mock(VehicleRoute.class);
StateManager stateManager = new StateManager(mock(VehicleRoutingTransportCosts.class));
StateId id = StateFactory.createId("myState");
State state = StateFactory.createState(1.);
stateManager.putInternalRouteState(route, id, state);
assertEquals(1.,stateManager.getRouteState(route, id).toDouble(),0.01);
}
@SuppressWarnings("deprecation")
@Test
public void whenRouteStateIsSet_itMustBeSetCorrectly(){
VehicleRoute route = mock(VehicleRoute.class);
StateManager stateManager = new StateManager(mock(VehicleRoutingTransportCosts.class));
StateId id = StateFactory.createId("myState");
State state = StateFactory.createState(1.);
stateManager.putRouteState(route, id, state);
assertEquals(1.,stateManager.getRouteState(route, id).toDouble(),0.01);
}
@Test
public void whenRouteStateIsSetWithGenericMethod_itMustBeSetCorrectly(){
VehicleRoute route = mock(VehicleRoute.class);
@ -78,30 +56,6 @@ public class StateManagerTest {
assertEquals(500, getCap.get(0));
}
@SuppressWarnings("deprecation")
@Test
public void whenInternalActivityStateIsSet_itMustBeSetCorrectly(){
TourActivity activity = mock(TourActivity.class);
StateManager stateManager = new StateManager(mock(VehicleRoutingTransportCosts.class));
StateId id = StateFactory.createId("myState");
State state = StateFactory.createState(1.);
stateManager.putInternalActivityState(activity, id, state);
assertEquals(1.,stateManager.getActivityState(activity, id).toDouble(),0.01);
}
@SuppressWarnings("deprecation")
@Test
public void whenActivityStateIsSet_itMustBeSetCorrectly(){
TourActivity activity = mock(TourActivity.class);
StateManager stateManager = new StateManager(mock(VehicleRoutingTransportCosts.class));
StateId id = StateFactory.createId("myState");
State state = StateFactory.createState(1.);
stateManager.putActivityState(activity, id, state);
assertEquals(1.,stateManager.getActivityState(activity, id).toDouble(),0.01);
}
@Test
public void whenActivityStateIsSetWithGenericMethod_itMustBeSetCorrectly(){
TourActivity activity = mock(TourActivity.class);

View file

@ -63,14 +63,12 @@ public class VrpXMLReaderTest {
assertTrue(idsInCollection(Arrays.asList("v1","v2"),vrp.getVehicles()));
}
@SuppressWarnings("deprecation")
@Test
public void whenReadingVrp_vehiclesAreReadCorrectly2(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Vehicle v1 = getVehicle("v1",vrp.getVehicles());
assertEquals(20,v1.getCapacity());
assertEquals(20,v1.getType().getCapacityDimensions().get(0));
assertEquals(100.0,v1.getStartLocationCoordinate().getX(),0.01);
assertEquals(0.0,v1.getEarliestDeparture(),0.01);
@ -141,14 +139,12 @@ public class VrpXMLReaderTest {
assertEquals(2,shipCounter);
}
@SuppressWarnings("deprecation")
@Test
public void whenReadingServices_capOfService1IsReadCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Service s1 = (Service) vrp.getJobs().get("1");
assertEquals(1,s1.getCapacityDemand());
assertEquals(1,s1.getSize().get(0));
}
@ -303,14 +299,12 @@ public class VrpXMLReaderTest {
assertEquals("startLoc",v.getStartLocationId());
}
@SuppressWarnings("deprecation")
@Test
public void whenReadingJobs_capOfShipment3IsReadCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
assertEquals(10,s.getCapacityDemand());
assertEquals(10,s.getSize().get(0));
}

View file

@ -35,7 +35,6 @@ import jsprit.core.util.Coordinate;
import org.junit.Before;
import org.junit.Test;
@SuppressWarnings("deprecation")
public class VrpXMLWriterTest {
private String infileName;
@ -50,7 +49,7 @@ public class VrpXMLWriterTest {
public void whenWritingInfiniteVrp_itWritesCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
builder.setFleetSize(FleetSize.INFINITE);
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
Vehicle vehicle = VehicleImpl.Builder.newInstance("myVehicle").setStartLocationId("loc").setType(type).build();
builder.addVehicle(vehicle);
VehicleRoutingProblem vrp = builder.build();
@ -61,8 +60,8 @@ public class VrpXMLWriterTest {
public void whenWritingFiniteVrp_itWritesCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
builder.setFleetSize(FleetSize.FINITE);
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
@ -75,8 +74,8 @@ public class VrpXMLWriterTest {
public void t(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
builder.setFleetSize(FleetSize.FINITE);
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
@ -92,8 +91,8 @@ public class VrpXMLWriterTest {
public void whenWritingServices_itWritesThemCorrectly(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
@ -101,8 +100,8 @@ public class VrpXMLWriterTest {
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -127,7 +126,7 @@ public class VrpXMLWriterTest {
.addSizeDimension(0, 20)
.addSizeDimension(1, 200)
.setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -149,17 +148,17 @@ public class VrpXMLWriterTest {
public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationIdsOfS1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Shipment s1 = Shipment.Builder.newInstance("1", 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@ -180,17 +179,17 @@ public class VrpXMLWriterTest {
public void whenWritingShipments_readingThemAgainMustReturnTheWrittenPickupTimeWindowsOfS1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Shipment s1 = Shipment.Builder.newInstance("1", 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@ -212,17 +211,17 @@ public class VrpXMLWriterTest {
public void whenWritingShipments_readingThemAgainMustReturnTheWrittenDeliveryTimeWindowsOfS1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Shipment s1 = Shipment.Builder.newInstance("1", 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@ -243,17 +242,17 @@ public class VrpXMLWriterTest {
public void whenWritingShipments_readingThemAgainMustReturnTheWrittenDeliveryServiceTimeOfS1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Shipment s1 = Shipment.Builder.newInstance("1", 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@ -274,17 +273,17 @@ public class VrpXMLWriterTest {
public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationIdOfS1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Shipment s1 = Shipment.Builder.newInstance("1", 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@ -303,17 +302,17 @@ public class VrpXMLWriterTest {
public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationCoordOfS1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Shipment s1 = Shipment.Builder.newInstance("1", 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@ -343,7 +342,7 @@ public class VrpXMLWriterTest {
.addSizeDimension(2, 100)
.build();
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
@ -366,16 +365,16 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleV1_itsStartLocationMustBeWrittenCorrectly(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -394,16 +393,16 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleV1_itDoesNotReturnToDepotMustBeWrittenCorrectly(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -420,16 +419,16 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleV1_readingAgainAssignsCorrectType(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -446,16 +445,16 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleV2_readingAgainAssignsCorrectType(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build();
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -466,7 +465,7 @@ public class VrpXMLWriterTest {
Vehicle v = getVehicle("v2",readVrp.getVehicles());
assertEquals("vehType2",v.getType().getTypeId());
assertEquals(200,v.getType().getCapacity());
assertEquals(200,v.getType().getCapacityDimensions().get(0));
}
@ -474,8 +473,8 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleV2_readingItsLocationsAgainReturnsCorrectLocations(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("startLoc").setStartLocationCoordinate(Coordinate.newInstance(1, 2))
.setEndLocationId("endLoc").setEndLocationCoordinate(Coordinate.newInstance(4, 5)).setType(type2).build();
@ -483,8 +482,8 @@ public class VrpXMLWriterTest {
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -502,8 +501,8 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleV2_readingItsLocationsCoordsAgainReturnsCorrectLocationsCoords(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2").addCapacityDimension(0, 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("startLoc").setStartLocationCoordinate(Coordinate.newInstance(1, 2))
.setEndLocationId("endLoc").setEndLocationCoordinate(Coordinate.newInstance(4, 5)).setType(type2).build();
@ -511,8 +510,8 @@ public class VrpXMLWriterTest {
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
Service s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
@ -533,7 +532,7 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleWithSeveralCapacityDimensions_itShouldBeWrittenAndRereadCorrectly(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type", 200)
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type")
.addCapacityDimension(0, 100)
.addCapacityDimension(1, 1000)
.addCapacityDimension(2, 10000)
@ -561,7 +560,7 @@ public class VrpXMLWriterTest {
public void whenWritingVehicleWithSeveralCapacityDimensions_itShouldBeWrittenAndRereadCorrectlyV2(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type", 200)
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type")
.addCapacityDimension(0, 100)
.addCapacityDimension(1, 1000)
.addCapacityDimension(10, 10000)

View file

@ -6,10 +6,9 @@ import org.junit.Test;
public class DeliveryTest {
@SuppressWarnings("deprecation")
@Test(expected=IllegalStateException.class)
public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){
Delivery.Builder.newInstance("p", 0).build();
Delivery.Builder.newInstance("p").build();
}
@Test
@ -32,12 +31,10 @@ public class DeliveryTest {
assertEquals(0,one.getSize().get(0));
}
@SuppressWarnings("deprecation")
@Test
public void whenPickupIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
Delivery one = (Delivery)Delivery.Builder.newInstance("s",1).setLocationId("foofoo")
Delivery one = (Delivery)Delivery.Builder.newInstance("s").addSizeDimension(0, 1).setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacityDemand());
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(1,one.getSize().get(0));
}

View file

@ -6,10 +6,9 @@ import org.junit.Test;
public class PickupTest {
@SuppressWarnings("deprecation")
@Test(expected=IllegalStateException.class)
public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){
Pickup.Builder.newInstance("p", 0).build();
Pickup.Builder.newInstance("p").build();
}
@Test
@ -32,12 +31,10 @@ public class PickupTest {
assertEquals(0,one.getSize().get(0));
}
@SuppressWarnings("deprecation")
@Test
public void whenPickupIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
Pickup one = (Pickup)Pickup.Builder.newInstance("s",1).setLocationId("foofoo")
Pickup one = (Pickup)Pickup.Builder.newInstance("s").addSizeDimension(0, 1).setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacityDemand());
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(1,one.getSize().get(0));
}

View file

@ -30,21 +30,20 @@ import jsprit.core.util.Coordinate;
import org.junit.Test;
@SuppressWarnings("deprecation")
public class ServiceTest {
@Test
public void whenTwoServicesHaveTheSameId_theirReferencesShouldBeUnEqual(){
Service one = Service.Builder.newInstance("service", 10).setLocationId("foo").build();
Service two = Service.Builder.newInstance("service", 10).setLocationId("fo").build();
Service one = Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("foo").build();
Service two = Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("fo").build();
assertTrue(one != two);
}
@Test
public void whenTwoServicesHaveTheSameId_theyShouldBeEqual(){
Service one = Service.Builder.newInstance("service", 10).setLocationId("foo").build();
Service two = Service.Builder.newInstance("service", 10).setLocationId("fo").build();
Service one = Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("foo").build();
Service two = Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("fo").build();
assertTrue(one.equals(two));
}
@ -52,8 +51,8 @@ public class ServiceTest {
@Test
public void noName(){
Set<Service> serviceSet = new HashSet<Service>();
Service one = Service.Builder.newInstance("service", 10).setLocationId("foo").build();
Service two = Service.Builder.newInstance("service", 10).setLocationId("fo").build();
Service one = Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("foo").build();
Service two = Service.Builder.newInstance("service").addSizeDimension(0, 10).setLocationId("fo").build();
serviceSet.add(one);
// assertTrue(serviceSet.contains(two));
serviceSet.remove(two);
@ -85,35 +84,34 @@ public class ServiceTest {
@Test
public void whenShipmentIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
Service one = Service.Builder.newInstance("s",1).setLocationId("foofoo")
Service one = Service.Builder.newInstance("s").addSizeDimension(0, 1).setLocationId("foofoo")
.build();
assertEquals(1,one.getCapacityDemand());
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(1,one.getSize().get(0));
}
@Test
public void whenCallingForNewInstanceOfBuilder_itShouldReturnBuilderCorrectly(){
Service.Builder builder = Service.Builder.newInstance("s", 0);
Service.Builder builder = Service.Builder.newInstance("s");
assertNotNull(builder);
assertTrue(builder instanceof Service.Builder);
}
@Test
public void whenSettingNoType_itShouldReturn_service(){
Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").build();
Service s = Service.Builder.newInstance("s").setLocationId("loc").build();
assertEquals("service",s.getType());
}
@Test
public void whenSettingLocation_itShouldBeSetCorrectly(){
Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").build();
Service s = Service.Builder.newInstance("s").setLocationId("loc").build();
assertEquals("loc",s.getLocationId());
}
@Test
public void whenSettingLocationCoord_itShouldBeSetCorrectly(){
Service s = Service.Builder.newInstance("s", 0).setCoord(Coordinate.newInstance(1, 2)).build();
Service s = Service.Builder.newInstance("s").setCoord(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,s.getCoord().getX(),0.01);
assertEquals(2.0,s.getCoord().getY(),0.01);
}
@ -121,30 +119,30 @@ public class ServiceTest {
@Test(expected=IllegalStateException.class)
public void whenSettingNeitherLocationIdNorCoord_throwsException(){
@SuppressWarnings("unused")
Service s = Service.Builder.newInstance("s", 0).build();
Service s = Service.Builder.newInstance("s").build();
}
@Test(expected=IllegalArgumentException.class)
public void whenServiceTimeSmallerZero_throwIllegalStateException(){
@SuppressWarnings("unused")
Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setServiceTime(-1).build();
Service s = Service.Builder.newInstance("s").setLocationId("loc").setServiceTime(-1).build();
}
@Test
public void whenSettingServiceTime_itShouldBeSetCorrectly(){
Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setServiceTime(1).build();
Service s = Service.Builder.newInstance("s").setLocationId("loc").setServiceTime(1).build();
assertEquals(1.0,s.getServiceDuration(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenTimeWindowIsNull_throwException(){
@SuppressWarnings("unused")
Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setTimeWindow(null).build();
Service s = Service.Builder.newInstance("s").setLocationId("loc").setTimeWindow(null).build();
}
@Test
public void whenSettingTimeWindow_itShouldBeSetCorrectly(){
Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setTimeWindow(TimeWindow.newInstance(1.0, 2.0)).build();
Service s = Service.Builder.newInstance("s").setLocationId("loc").setTimeWindow(TimeWindow.newInstance(1.0, 2.0)).build();
assertEquals(1.0,s.getTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getTimeWindow().getEnd(),0.01);
}

View file

@ -8,14 +8,13 @@ import jsprit.core.util.Coordinate;
import org.junit.Test;
@SuppressWarnings("deprecation")
public class ShipmentTest {
@Test
public void whenTwoShipmentsHaveTheSameId_theyReferencesShouldBeUnEqual(){
Shipment one = Shipment.Builder.newInstance("s", 10).setPickupLocation("foo").
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
Shipment two = Shipment.Builder.newInstance("s", 10).setPickupLocation("foo").
Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertTrue(one != two);
@ -23,9 +22,9 @@ public class ShipmentTest {
@Test
public void whenTwoShipmentsHaveTheSameId_theyShouldBeEqual(){
Shipment one = Shipment.Builder.newInstance("s", 10).setPickupLocation("foo").
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
Shipment two = Shipment.Builder.newInstance("s", 10).setPickupLocation("foo").
Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertTrue(one.equals(two));
@ -33,15 +32,15 @@ public class ShipmentTest {
@Test
public void whenShipmentIsInstantiatedWithASizeOf10_theSizeShouldBe10(){
Shipment one = Shipment.Builder.newInstance("s", 10).setPickupLocation("foo").
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertEquals(10,one.getCapacityDemand());
assertEquals(10,one.getSize().get(0));
}
@Test(expected=IllegalArgumentException.class)
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException(){
@SuppressWarnings("unused")
Shipment one = Shipment.Builder.newInstance("s", -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
}
@Test(expected=IllegalArgumentException.class)
@ -53,42 +52,42 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenIdIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
Shipment one = Shipment.Builder.newInstance(null, 10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
}
@Test
public void whenCallingForANewBuilderInstance_itShouldReturnBuilderCorrectly(){
Shipment.Builder builder = Shipment.Builder.newInstance("s", 0);
Shipment.Builder builder = Shipment.Builder.newInstance("s");
assertNotNull(builder);
}
@Test(expected=IllegalStateException.class)
public void whenNeitherPickupLocationIdNorPickupCoord_itThrowsException(){
@SuppressWarnings("unused")
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").build();
}
@Test(expected=IllegalStateException.class)
public void whenNeitherDeliveryLocationIdNorDeliveryCoord_itThrowsException(){
@SuppressWarnings("unused")
Shipment s = Shipment.Builder.newInstance("s", 0).setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").build();
}
@Test
public void whenPickupLocationIdIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals("pickLoc",s.getPickupLocation());
}
@Test(expected=IllegalArgumentException.class)
public void whenPickupLocationIsNull_itThrowsException(){
@SuppressWarnings("unused")
Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setPickupLocation(null);
Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocation(null);
}
@Test
public void whenPickupCoordIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,s.getPickupCoord().getX(),0.01);
assertEquals(2.0,s.getPickupCoord().getY(),0.01);
}
@ -96,24 +95,24 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenPickupCoordIsNull_itThrowsException(){
@SuppressWarnings("unused")
Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setPickupCoord(null);
Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupCoord(null);
}
@Test
public void whenDeliveryLocationIdIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals("delLoc",s.getDeliveryLocation());
}
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryLocationIsNull_itThrowsException(){
@SuppressWarnings("unused")
Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setDeliveryLocation(null);
Shipment.Builder builder = Shipment.Builder.newInstance("s").setDeliveryLocation(null);
}
@Test
public void whenDeliveryCoordIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,s.getDeliveryCoord().getX(),0.01);
assertEquals(2.0,s.getDeliveryCoord().getY(),0.01);
}
@ -121,48 +120,48 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryCoordIsNull_itThrowsException(){
@SuppressWarnings("unused")
Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setDeliveryCoord(null);
Shipment.Builder builder = Shipment.Builder.newInstance("s").setDeliveryCoord(null);
}
@Test
public void whenPickupServiceTimeIsNotSet_itShouldBeZero(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(0.0,s.getPickupServiceTime(),0.01);
}
@Test
public void whenDeliveryServiceTimeIsNotSet_itShouldBeZero(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(0.0,s.getDeliveryServiceTime(),0.01);
}
@Test
public void whenPickupServiceTimeIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setPickupServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(2.0,s.getPickupServiceTime(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenPickupServiceIsSmallerThanZero_itShouldThrowException(){
@SuppressWarnings("unused")
Shipment s = Shipment.Builder.newInstance("s", 0).setPickupServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
}
@Test
public void whenDeliveryServiceTimeIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(2.0,s.getDeliveryServiceTime(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryServiceIsSmallerThanZero_itShouldThrowException(){
@SuppressWarnings("unused")
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
}
@Test
public void whenPickupTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(0.0,s.getPickupTimeWindow().getStart(),0.01);
assertEquals(Double.MAX_VALUE,s.getPickupTimeWindow().getEnd(),0.01);
}
@ -170,19 +169,19 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenPickupTimeWindowIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
Shipment s = Shipment.Builder.newInstance("s", 0).setPickupTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
}
@Test
public void whenPickupTimeWindowIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(1.0,s.getPickupTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getPickupTimeWindow().getEnd(),0.01);
}
@Test
public void whenDeliveryTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(0.0,s.getDeliveryTimeWindow().getStart(),0.01);
assertEquals(Double.MAX_VALUE,s.getDeliveryTimeWindow().getEnd(),0.01);
}
@ -190,12 +189,12 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryTimeWindowIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
}
@Test
public void whenDeliveryTimeWindowIsSet_itShouldBeDoneCorrectly(){
Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
assertEquals(1.0,s.getDeliveryTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getDeliveryTimeWindow().getEnd(),0.01);
}
@ -227,9 +226,8 @@ public class ShipmentTest {
@Test
public void whenShipmentIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
Shipment one = Shipment.Builder.newInstance("s",1).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
.setDeliveryLocation("foofoo").build();
assertEquals(1,one.getCapacityDemand());
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(1,one.getSize().get(0));
}

View file

@ -28,12 +28,6 @@ public class DeliverServiceTest {
assertEquals(-1000,deliver.getSize().get(2));
}
@SuppressWarnings("deprecation")
@Test
public void whenCallingCapacityDemand_itShouldReturnCapDimWithIndex0(){
assertEquals(-10,deliver.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
assertEquals(1.,deliver.getTheoreticalEarliestOperationStartTime(),0.01);

View file

@ -30,12 +30,6 @@ public class DeliverShipmentTest {
assertEquals(-1000,deliver.getSize().get(2));
}
@SuppressWarnings("deprecation")
@Test
public void whenCallingCapacityDemand_itShouldReturnCapDimWithIndex0(){
assertEquals(-10,deliver.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
assertEquals(3.,deliver.getTheoreticalEarliestOperationStartTime(),0.01);

View file

@ -13,12 +13,6 @@ public class EndTest {
assertEquals(0,end.getSize().get(0));
}
@Test
public void whenCallingCapacityDemand_itShouldReturnEmptyCapacity(){
End end = End.newInstance("loc", 0., 0.);
assertEquals(0,end.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
End end = End.newInstance("loc", 1., 2.);

View file

@ -28,11 +28,6 @@ public class PickupServiceTest {
assertEquals(1000,pickup.getSize().get(2));
}
@SuppressWarnings("deprecation")
@Test
public void whenCallingCapacityDemand_itShouldReturnCapDimWithIndex0(){
assertEquals(10,pickup.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){

View file

@ -30,12 +30,6 @@ public class PickupShipmentTest {
assertEquals(1000,pickup.getSize().get(2));
}
@SuppressWarnings("deprecation")
@Test
public void whenCallingCapacityDemand_itShouldReturnCapDimWithIndex0(){
assertEquals(10,pickup.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
assertEquals(1.,pickup.getTheoreticalEarliestOperationStartTime(),0.01);

View file

@ -48,12 +48,6 @@ public class ServiceActivityTest {
}
@SuppressWarnings("deprecation")
@Test
public void whenCallingCapacityDemand_itShouldReturnCapDimWithIndex0(){
assertEquals(10,serviceActivity.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
assertEquals(1.,serviceActivity.getTheoreticalEarliestOperationStartTime(),0.01);

View file

@ -12,12 +12,6 @@ public class StartTest {
assertEquals(0,start.getSize().get(0));
}
@Test
public void whenCallingCapacityDemand_itShouldReturnEmptyCapacity(){
Start start = Start.newInstance("loc", 0., 0.);
assertEquals(0,start.getCapacityDemand());
}
@Test
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
Start start = Start.newInstance("loc", 1., 2.);

View file

@ -1,35 +1,18 @@
package jsprit.core.problem.vehicle;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
import jsprit.core.util.Coordinate;
import org.junit.Test;
@SuppressWarnings("deprecation") // still tests whether deprecated methods work correctly - if deprecated methods are removed entirely, shift to setStartLocationId(..) and setStartLocationCoordinate()
public class VehicleImplTest {
@Test
public void whenSettingTypeWithBuilder_typeShouldBeSet(){
VehicleType type = mock(VehicleType.class);
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build();
assertEquals(type,v.getType());
}
@Test(expected=IllegalStateException.class)
public void whenTypeIsNull_itThrowsIllegalStateException(){
@SuppressWarnings("unused")
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(null).build();
}
@Test
public void whenTypeIsNotSet_defaultTypeIsSet(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationId("loc").build();
assertEquals("default",v.getType().getTypeId());
assertEquals(0,v.getType().getCapacity());
}
@Test(expected=IllegalStateException.class)
public void whenVehicleIsBuiltWithoutSettingNeitherLocationNorCoord_itThrowsAnIllegalStateException(){
@ -37,58 +20,52 @@ public class VehicleImplTest {
Vehicle v = VehicleImpl.Builder.newInstance("v").build();
}
@Test
public void whenVehicleIsBuiltAndReturnToDepotFlagIsNotSet_itShouldReturnToDepot(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationId("loc").build();
assertTrue(v.isReturnToDepot());
}
@Test
public void whenVehicleIsBuiltToReturnToDepot_itShouldReturnToDepot(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(true).setLocationId("loc").build();
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(true).setStartLocationId("loc").build();
assertTrue(v.isReturnToDepot());
}
@Test
public void whenVehicleIsBuiltToNotReturnToDepot_itShouldNotReturnToDepot(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(false).setLocationId("loc").build();
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(false).setStartLocationId("loc").build();
assertFalse(v.isReturnToDepot());
}
@Test
public void whenVehicleIsBuiltWithLocation_itShouldHvTheCorrectLocation(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationId("loc").build();
assertEquals("loc",v.getLocationId());
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
assertEquals("loc",v.getStartLocationId());
}
@Test
public void whenVehicleIsBuiltWithCoord_itShouldHvTheCorrectCoord(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationCoord(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,v.getCoord().getX(),0.01);
assertEquals(2.0,v.getCoord().getY(),0.01);
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,v.getStartLocationCoordinate().getX(),0.01);
assertEquals(2.0,v.getStartLocationCoordinate().getY(),0.01);
}
@Test
public void whenVehicleIsBuiltAndEarliestStartIsNotSet_itShouldSetTheDefaultOfZero(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationCoord(Coordinate.newInstance(1, 2)).build();
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
assertEquals(0.0,v.getEarliestDeparture(),0.01);
}
@Test
public void whenVehicleIsBuiltAndEarliestStartSet_itShouldBeSetCorrectly(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setEarliestStart(10.0).setLocationCoord(Coordinate.newInstance(1, 2)).build();
Vehicle v = VehicleImpl.Builder.newInstance("v").setEarliestStart(10.0).setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
assertEquals(10.0,v.getEarliestDeparture(),0.01);
}
@Test
public void whenVehicleIsBuiltAndLatestArrivalIsNotSet_itShouldSetDefaultOfDoubleMaxValue(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationCoord(Coordinate.newInstance(1, 2)).build();
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
assertEquals(Double.MAX_VALUE,v.getLatestArrival(),0.01);
}
@Test
public void whenVehicleIsBuiltAndLatestArrivalIsSet_itShouldBeSetCorrectly(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setLatestArrival(30.0).setLocationCoord(Coordinate.newInstance(1, 2)).build();
Vehicle v = VehicleImpl.Builder.newInstance("v").setLatestArrival(30.0).setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
assertEquals(30.0,v.getLatestArrival(),0.01);
}
@ -102,7 +79,6 @@ public class VehicleImplTest {
@Test
public void whenStartLocationIsSet_itIsDoneCorrectly(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").build();
assertEquals("startLoc", v.getLocationId());
assertEquals("startLoc", v.getStartLocationId());
}
@ -117,9 +93,6 @@ public class VehicleImplTest {
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0, v.getStartLocationCoordinate().getX(),0.01);
assertEquals(2.0, v.getStartLocationCoordinate().getY(),0.01);
assertEquals(1.0, v.getCoord().getX(),0.01);
assertEquals(2.0, v.getCoord().getY(),0.01);
}
@Test

View file

@ -6,7 +6,6 @@ import org.junit.Test;
public class VehicleTypeImplTest {
@Test(expected=IllegalArgumentException.class)
public void whenTypeHasNegativeCapacityVal_throwIllegalStateExpception(){
@SuppressWarnings("unused")
@ -44,47 +43,34 @@ public class VehicleTypeImplTest {
assertEquals(0,type.getCapacityDimensions().get(0));
}
@SuppressWarnings("deprecation")
@Test
public void whenTypeIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("t",20).build();
assertEquals(20,type.getCapacity());
assertEquals(20,type.getCapacityDimensions().get(0));
}
@SuppressWarnings("deprecation")
@Test
public void whenCallingStaticNewBuilderInstance_itShouldReturnNewBuilderInstance(){
VehicleTypeImpl.Builder builder = VehicleTypeImpl.Builder.newInstance("foo", 0);
VehicleTypeImpl.Builder builder = VehicleTypeImpl.Builder.newInstance("foo");
assertNotNull(builder);
}
@SuppressWarnings("deprecation")
@Test
public void whenBuildingTypeJustByCallingNewInstance_typeIdMustBeCorrect(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("foo", 0).build();
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("foo").build();
assertEquals("foo",type.getTypeId());
}
@SuppressWarnings("deprecation")
@Test
public void whenBuildingTypeJustByCallingNewInstance_capMustBeCorrect(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("foo", 0).build();
assertEquals(0,type.getCapacity());
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("foo").build();
assertEquals(0,type.getCapacityDimensions().get(0));
}
@SuppressWarnings("deprecation")
@Test(expected=IllegalStateException.class)
@Test(expected=IllegalArgumentException.class)
public void whenBuildingTypeWithCapSmallerThanZero_throwIllegalStateException(){
@SuppressWarnings("unused")
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("foo", -10).build();
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("foo").addCapacityDimension(0, -10).build();
}
@SuppressWarnings("deprecation")
@Test(expected=IllegalStateException.class)
public void whenBuildingTypeWithNullId_throwIllegalStateException(){
@SuppressWarnings("unused")
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance(null, 10).build();
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance(null).addCapacityDimension(0, 10).build();
}

View file

@ -194,7 +194,9 @@
</timeWindow>
</timeWindows>
</delivery>
<capacity-demand>10</capacity-demand>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
<shipment id="4">

View file

@ -3,7 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>FINITE</fleetSize>
<fleetComposition>HETEROGENEOUS</fleetComposition>
</problemType>
<vehicles>
<vehicle>
@ -41,7 +40,7 @@
<returnToDepot>false</returnToDepot>
</vehicle>
<vehicle>
<id>v4</id>
<id>v3</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
@ -58,7 +57,7 @@
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v3</id>
<id>v4</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>

View file

@ -3,7 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>INFINITE</fleetSize>
<fleetComposition>HOMOGENEOUS</fleetComposition>
</problemType>
<vehicles>
<vehicle>