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

deprecate vrpBuilder.addService(...) and remove public logger in

VehicleRoutingProblem
This commit is contained in:
Stefan Schroeder 2013-11-26 10:23:24 +01:00
parent a85b0fc395
commit cdde92da22
2 changed files with 12 additions and 12 deletions

View file

@ -25,7 +25,9 @@ import java.util.Map;
import jsprit.core.problem.cost.VehicleRoutingActivityCosts; import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
import jsprit.core.problem.cost.VehicleRoutingTransportCosts; import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
import jsprit.core.problem.driver.Driver; import jsprit.core.problem.driver.Driver;
import jsprit.core.problem.job.Delivery;
import jsprit.core.problem.job.Job; import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Service; import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment; import jsprit.core.problem.job.Shipment;
import jsprit.core.problem.solution.route.activity.TourActivity; import jsprit.core.problem.solution.route.activity.TourActivity;
@ -233,9 +235,11 @@ public class VehicleRoutingProblem {
* *
* <p>If jobList already contains service, a warning message is printed, and the existing job will be overwritten. * <p>If jobList already contains service, a warning message is printed, and the existing job will be overwritten.
* *
* @deprecated use addJob(...) instead
* @param service * @param service
* @return * @return
*/ */
@Deprecated
public Builder addService(Service service){ public Builder addService(Service service){
coordinates.put(service.getLocationId(), service.getCoord()); coordinates.put(service.getLocationId(), service.getCoord());
if(jobs.containsKey(service.getId())){ logger.warn("service " + service + " already in job list. overrides existing job."); } if(jobs.containsKey(service.getId())){ logger.warn("service " + service + " already in job list. overrides existing job."); }
@ -257,16 +261,13 @@ public class VehicleRoutingProblem {
if(jobs.containsKey(job.getId())) throw new IllegalStateException("jobList already contains a job with id " + job.getId() + ". make sure you use unique ids for your jobs (i.e. service and shipments)"); if(jobs.containsKey(job.getId())) throw new IllegalStateException("jobList already contains a job with id " + job.getId() + ". make sure you use unique ids for your jobs (i.e. service and shipments)");
if(job instanceof Service) { if(job instanceof Service) {
addService((Service) job); addService((Service) job);
return this;
} }
else if(job instanceof Shipment){ else if(job instanceof Shipment){
addShipment((Shipment)job); addShipment((Shipment)job);
return this;
} }
else{ throw new IllegalStateException("job must be either a service or a shipment");
// if(jobs.containsKey(job.getId())){ logger.warn("job " + job + " already in job list. overrides existing job."); }
// coordinates.put(job.getLocationId(), job.getCoord());
// jobs.put(job.getId(),job);
}
return this;
} }
@ -339,7 +340,7 @@ public class VehicleRoutingProblem {
* @return {@link VehicleRoutingProblem} * @return {@link VehicleRoutingProblem}
*/ */
public VehicleRoutingProblem build() { public VehicleRoutingProblem build() {
log.info("build problem ..."); logger.info("build problem ...");
if(transportCosts == null){ if(transportCosts == null){
logger.warn("set routing costs crowFlyDistance."); logger.warn("set routing costs crowFlyDistance.");
transportCosts = new CrowFlyCosts(getLocations()); transportCosts = new CrowFlyCosts(getLocations());
@ -422,8 +423,6 @@ public class VehicleRoutingProblem {
HETEROGENEOUS, HOMOGENEOUS; HETEROGENEOUS, HOMOGENEOUS;
} }
public static Logger log = Logger.getLogger(VehicleRoutingProblem.class);
private static Logger logger = Logger.getLogger(VehicleRoutingProblem.class); private static Logger logger = Logger.getLogger(VehicleRoutingProblem.class);
private VehicleRoutingTransportCosts transportCosts; private VehicleRoutingTransportCosts transportCosts;
@ -467,7 +466,7 @@ public class VehicleRoutingProblem {
this.activityCosts = builder.activityCosts; this.activityCosts = builder.activityCosts;
this.neighborhood = builder.neighborhood; this.neighborhood = builder.neighborhood;
this.problemConstraints = builder.problemConstraints; this.problemConstraints = builder.problemConstraints;
log.info("initialise " + this); logger.info("initialise " + this);
} }
@Override @Override

View file

@ -79,7 +79,8 @@ public class SimpleVRPWithBackhaulsExample {
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addVehicle(vehicle); vrpBuilder.addVehicle(vehicle);
vrpBuilder.addService(pickup1).addService(pickup2).addService(delivery1).addService(delivery2);
vrpBuilder.addJob(pickup1).addJob(pickup2).addJob(delivery1).addJob(delivery2);
// //
vrpBuilder.addProblemConstraint(Constraint.DELIVERIES_FIRST); vrpBuilder.addProblemConstraint(Constraint.DELIVERIES_FIRST);