mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
rename core.problem.constraint.HardActivityStateLevelConstraint to HardActivityConstraint
rename core.problem.constraint.HardRouteStateLevelConstraint to HardRouteConstraint
This commit is contained in:
parent
dd2c7625b4
commit
e65d36d784
30 changed files with 467 additions and 382 deletions
|
|
@ -18,7 +18,7 @@ package jsprit.core.algorithm.recreate;
|
|||
|
||||
import jsprit.core.problem.JobActivityFactory;
|
||||
import jsprit.core.problem.constraint.*;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Job;
|
||||
|
|
@ -43,9 +43,9 @@ final class ServiceInsertionCalculator implements JobInsertionCostsCalculator{
|
|||
|
||||
private static final Logger logger = LogManager.getLogger(ServiceInsertionCalculator.class);
|
||||
|
||||
private HardRouteStateLevelConstraint hardRouteLevelConstraint;
|
||||
private HardRouteConstraint hardRouteLevelConstraint;
|
||||
|
||||
private HardActivityStateLevelConstraint hardActivityLevelConstraint;
|
||||
private HardActivityConstraint hardActivityLevelConstraint;
|
||||
|
||||
private SoftRouteConstraint softRouteConstraint;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -18,9 +18,9 @@ package jsprit.core.algorithm.recreate;
|
|||
|
||||
import jsprit.core.algorithm.state.InternalStates;
|
||||
import jsprit.core.problem.JobActivityFactory;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
|
|
@ -57,9 +57,9 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
|||
|
||||
private RouteAndActivityStateGetter stateManager;
|
||||
|
||||
private HardRouteStateLevelConstraint hardRouteLevelConstraint;
|
||||
private HardRouteConstraint hardRouteLevelConstraint;
|
||||
|
||||
private HardActivityStateLevelConstraint hardActivityLevelConstraint;
|
||||
private HardActivityConstraint hardActivityLevelConstraint;
|
||||
|
||||
private ActivityInsertionCostsCalculator activityInsertionCostsCalculator;
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
|||
logger.info("set [solutionMemory="+memorySize+"]");
|
||||
}
|
||||
|
||||
public ServiceInsertionOnRouteLevelCalculator(VehicleRoutingTransportCosts vehicleRoutingCosts, VehicleRoutingActivityCosts costFunc, ActivityInsertionCostsCalculator activityInsertionCostsCalculator, HardRouteStateLevelConstraint hardRouteLevelConstraint, HardActivityStateLevelConstraint hardActivityLevelConstraint) {
|
||||
public ServiceInsertionOnRouteLevelCalculator(VehicleRoutingTransportCosts vehicleRoutingCosts, VehicleRoutingActivityCosts costFunc, ActivityInsertionCostsCalculator activityInsertionCostsCalculator, HardRouteConstraint hardRouteLevelConstraint, HardActivityConstraint hardActivityLevelConstraint) {
|
||||
super();
|
||||
this.transportCosts = vehicleRoutingCosts;
|
||||
this.activityCosts = costFunc;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package jsprit.core.algorithm.recreate;
|
|||
|
||||
import jsprit.core.problem.JobActivityFactory;
|
||||
import jsprit.core.problem.constraint.*;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Job;
|
||||
|
|
@ -43,9 +43,9 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator{
|
|||
|
||||
private static final Logger logger = LogManager.getLogger(ShipmentInsertionCalculator.class);
|
||||
|
||||
private HardRouteStateLevelConstraint hardRouteLevelConstraint;
|
||||
private HardRouteConstraint hardRouteLevelConstraint;
|
||||
|
||||
private HardActivityStateLevelConstraint hardActivityLevelConstraint;
|
||||
private HardActivityConstraint hardActivityLevelConstraint;
|
||||
|
||||
private SoftRouteConstraint softRouteConstraint;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
|
|
@ -36,7 +34,7 @@ import java.util.List;
|
|||
* @author schroeder
|
||||
*
|
||||
*/
|
||||
public class ConstraintManager implements HardActivityStateLevelConstraint, HardRouteStateLevelConstraint, SoftActivityConstraint, SoftRouteConstraint{
|
||||
public class ConstraintManager implements HardActivityConstraint, HardRouteConstraint, SoftActivityConstraint, SoftRouteConstraint{
|
||||
|
||||
public static enum Priority {
|
||||
CRITICAL, HIGH, LOW
|
||||
|
|
@ -76,12 +74,12 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard
|
|||
private void resolveConstraints(Collection<jsprit.core.problem.constraint.Constraint> constraints) {
|
||||
for(jsprit.core.problem.constraint.Constraint c : constraints){
|
||||
boolean constraintTypeKnown = false;
|
||||
if(c instanceof HardActivityStateLevelConstraint) {
|
||||
actLevelConstraintManager.addConstraint((HardActivityStateLevelConstraint) c, Priority.HIGH);
|
||||
if(c instanceof HardActivityConstraint) {
|
||||
actLevelConstraintManager.addConstraint((HardActivityConstraint) c, Priority.HIGH);
|
||||
constraintTypeKnown = true;
|
||||
}
|
||||
if(c instanceof HardRouteStateLevelConstraint) {
|
||||
routeLevelConstraintManager.addConstraint((HardRouteStateLevelConstraint) c);
|
||||
if(c instanceof HardRouteConstraint) {
|
||||
routeLevelConstraintManager.addConstraint((HardRouteConstraint) c);
|
||||
constraintTypeKnown = true;
|
||||
}
|
||||
if(c instanceof SoftRouteConstraint){
|
||||
|
|
@ -125,11 +123,11 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard
|
|||
|
||||
// public void add
|
||||
|
||||
public void addConstraint(HardActivityStateLevelConstraint actLevelConstraint, Priority priority){
|
||||
public void addConstraint(HardActivityConstraint actLevelConstraint, Priority priority){
|
||||
actLevelConstraintManager.addConstraint(actLevelConstraint,priority);
|
||||
}
|
||||
|
||||
public void addConstraint(HardRouteStateLevelConstraint routeLevelConstraint){
|
||||
public void addConstraint(HardRouteConstraint routeLevelConstraint){
|
||||
routeLevelConstraintManager.addConstraint(routeLevelConstraint);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 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.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
|
||||
/**
|
||||
* Hard constraint that evaluates whether a new activity can be inserted between an activity segment (prevAct,nextAct).
|
||||
*/
|
||||
public interface HardActivityConstraint extends HardConstraint{
|
||||
|
||||
/**
|
||||
* Indicates whether a hard activity constraint is fulfilled or not
|
||||
*/
|
||||
static enum ConstraintsStatus {
|
||||
|
||||
NOT_FULFILLED_BREAK, NOT_FULFILLED, FULFILLED
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether newAct can be inserted in between prevAct and nextAct.
|
||||
*
|
||||
* <p>
|
||||
* When you check activities, you need to understand the following:
|
||||
*
|
||||
* Let us assume an existing route;
|
||||
*
|
||||
* start, ..., i-1, i, j, j+1, ..., end
|
||||
*
|
||||
* When inserting a shipment, two activities will be inserted, pickupShipment k_pick and deliverShipment k_deliver,
|
||||
* i.e. jsprit loops through this route (activity sequence) and checks hard and soft constraints and calculates (marginal) insertion costs. For
|
||||
* the activity sequence above, it means:
|
||||
*<p>
|
||||
* start, k_pick, start+1 (prevAct, newAct, nextAct)<br>
|
||||
* ...<br>
|
||||
* i-1, k_pick, i<br>
|
||||
* i, k_pick, j<br>
|
||||
* ...<br>
|
||||
*<p>
|
||||
* accordingly:<br>
|
||||
* start, k_pick, k_delivery (prevAct, newAct, nextAct)<br>
|
||||
* ...<br>
|
||||
* i-1, k_delivery, i<br>
|
||||
* i, k_delivery, j<br>
|
||||
* ...<br>
|
||||
*<p>
|
||||
* You specify a hard activity constraint, you to check whether for example k_pick can be inserted between prevActivity and nextActivity at all.
|
||||
* If so, your hard constraint should return ConstraintsStatus.FULFILLED.<br>
|
||||
* If not, you can return ConstraintsStatus.NOT_FULFILLED or ConstraintsStatus.NOT_FULFILLED_BREAK.<br>
|
||||
*
|
||||
* Latter should be used, if your constraint can never be fulfilled anymore when looping further through your route.
|
||||
*<p>
|
||||
* Since constraint checking at activity level is rather time consuming (you need to do this thousand/millions times),
|
||||
* you can memorize states behind activities to avoid additional loopings through your activity sequence and thus to
|
||||
* check your constraint locally (only by looking at prevAct, newAct, nextAct) in constant time.
|
||||
*
|
||||
* @param iFacts JobInsertionContext provides additional information that might be important when evaluating the insertion of newAct
|
||||
* @param prevAct the previous activity, i.e. the activity before the new activity
|
||||
* @param newAct the new activity to be inserted in between prevAct and nextAct
|
||||
* @param nextAct the next activity, i.e. the activity after the new activity
|
||||
* @param prevActDepTime the departure time at previous activity (prevAct) with the new vehicle (iFacts.getNewVehicle())
|
||||
* @return fulfilled if hard constraint is met, other not fulfilled.
|
||||
*/
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime);
|
||||
|
||||
}
|
||||
|
|
@ -1,42 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.constraint.ConstraintManager.Priority;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.problem.constraint.ConstraintManager.Priority;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
|
||||
class HardActivityLevelConstraintManager implements HardActivityConstraint {
|
||||
|
||||
class HardActivityLevelConstraintManager implements HardActivityStateLevelConstraint {
|
||||
|
||||
private Collection<HardActivityStateLevelConstraint> criticalConstraints = new ArrayList<HardActivityStateLevelConstraint>();
|
||||
private Collection<HardActivityConstraint> criticalConstraints = new ArrayList<HardActivityConstraint>();
|
||||
|
||||
private Collection<HardActivityStateLevelConstraint> highPrioConstraints = new ArrayList<HardActivityStateLevelConstraint>();
|
||||
private Collection<HardActivityConstraint> highPrioConstraints = new ArrayList<HardActivityConstraint>();
|
||||
|
||||
private Collection<HardActivityStateLevelConstraint> lowPrioConstraints = new ArrayList<HardActivityStateLevelConstraint>();
|
||||
private Collection<HardActivityConstraint> lowPrioConstraints = new ArrayList<HardActivityConstraint>();
|
||||
|
||||
public void addConstraint(HardActivityStateLevelConstraint constraint, Priority priority){
|
||||
public void addConstraint(HardActivityConstraint constraint, Priority priority){
|
||||
if(priority.equals(Priority.CRITICAL)){
|
||||
criticalConstraints.add(constraint);
|
||||
}
|
||||
|
|
@ -48,14 +46,14 @@ class HardActivityLevelConstraintManager implements HardActivityStateLevelConstr
|
|||
}
|
||||
}
|
||||
|
||||
Collection<HardActivityStateLevelConstraint> getCriticalConstraints(){ return Collections.unmodifiableCollection(criticalConstraints); }
|
||||
Collection<HardActivityConstraint> getCriticalConstraints(){ return Collections.unmodifiableCollection(criticalConstraints); }
|
||||
|
||||
Collection<HardActivityStateLevelConstraint> getHighPrioConstraints(){ return Collections.unmodifiableCollection(highPrioConstraints); }
|
||||
Collection<HardActivityConstraint> getHighPrioConstraints(){ return Collections.unmodifiableCollection(highPrioConstraints); }
|
||||
|
||||
Collection<HardActivityStateLevelConstraint> getLowPrioConstraints(){ return Collections.unmodifiableCollection(lowPrioConstraints); }
|
||||
Collection<HardActivityConstraint> getLowPrioConstraints(){ return Collections.unmodifiableCollection(lowPrioConstraints); }
|
||||
|
||||
Collection<HardActivityStateLevelConstraint> getAllConstraints(){
|
||||
List<HardActivityStateLevelConstraint> c = new ArrayList<HardActivityStateLevelConstraint>();
|
||||
Collection<HardActivityConstraint> getAllConstraints(){
|
||||
List<HardActivityConstraint> c = new ArrayList<HardActivityConstraint>();
|
||||
c.addAll(criticalConstraints);
|
||||
c.addAll(highPrioConstraints);
|
||||
c.addAll(lowPrioConstraints);
|
||||
|
|
@ -65,7 +63,7 @@ class HardActivityLevelConstraintManager implements HardActivityStateLevelConstr
|
|||
@Override
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
ConstraintsStatus notFulfilled = null;
|
||||
for(HardActivityStateLevelConstraint c : criticalConstraints){
|
||||
for(HardActivityConstraint c : criticalConstraints){
|
||||
ConstraintsStatus status = c.fulfilled(iFacts, prevAct, newAct, nextAct, prevActDepTime);
|
||||
if(status.equals(ConstraintsStatus.NOT_FULFILLED_BREAK)){
|
||||
return status;
|
||||
|
|
@ -78,7 +76,7 @@ class HardActivityLevelConstraintManager implements HardActivityStateLevelConstr
|
|||
}
|
||||
if(notFulfilled != null) return notFulfilled;
|
||||
|
||||
for(HardActivityStateLevelConstraint c : highPrioConstraints){
|
||||
for(HardActivityConstraint c : highPrioConstraints){
|
||||
ConstraintsStatus status = c.fulfilled(iFacts, prevAct, newAct, nextAct, prevActDepTime);
|
||||
if(status.equals(ConstraintsStatus.NOT_FULFILLED_BREAK)){
|
||||
return status;
|
||||
|
|
@ -91,7 +89,7 @@ class HardActivityLevelConstraintManager implements HardActivityStateLevelConstr
|
|||
}
|
||||
if(notFulfilled != null) return notFulfilled;
|
||||
|
||||
for(HardActivityStateLevelConstraint constraint : lowPrioConstraints){
|
||||
for(HardActivityConstraint constraint : lowPrioConstraints){
|
||||
ConstraintsStatus status = constraint.fulfilled(iFacts, prevAct, newAct, nextAct, prevActDepTime);
|
||||
if(status.equals(ConstraintsStatus.NOT_FULFILLED_BREAK) || status.equals(ConstraintsStatus.NOT_FULFILLED)){
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
|
||||
public interface HardActivityStateLevelConstraint extends HardConstraint{
|
||||
|
||||
static enum ConstraintsStatus {
|
||||
|
||||
NOT_FULFILLED_BREAK, NOT_FULFILLED, FULFILLED;
|
||||
|
||||
}
|
||||
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 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.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
|
||||
/**
|
||||
* Hard constraint that evaluates whether a new job (insertionContext.getJob()) can be inserted
|
||||
* existing route (insertionContext.getRoute()).
|
||||
*/
|
||||
public interface HardRouteConstraint extends HardConstraint{
|
||||
|
||||
/**
|
||||
* Returns whether a job can be inserted in route.
|
||||
*
|
||||
* @param insertionContext provides context information about inserting a new job, i.e. the new job (<code>insertionContext.getJob()</code>),
|
||||
* the route where the new job should be inserted (<code>insertionContext.getRoute()</code>), the new vehicle that
|
||||
* should operate the route plus the new job (<code>insertionContext.getNewVehicle()</code>) and the new departure
|
||||
* time at this vehicle's start location (<code>insertionContext.getNewDepartureTime()</code>).
|
||||
* @return true if constraint is met, false otherwise
|
||||
*/
|
||||
public boolean fulfilled(JobInsertionContext insertionContext);
|
||||
|
||||
}
|
||||
|
|
@ -1,43 +1,41 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
|
||||
class HardRouteLevelConstraintManager implements HardRouteConstraint {
|
||||
|
||||
class HardRouteLevelConstraintManager implements HardRouteStateLevelConstraint {
|
||||
|
||||
private Collection<HardRouteStateLevelConstraint> hardConstraints = new ArrayList<HardRouteStateLevelConstraint>();
|
||||
private Collection<HardRouteConstraint> hardConstraints = new ArrayList<HardRouteConstraint>();
|
||||
|
||||
public void addConstraint(HardRouteStateLevelConstraint constraint){
|
||||
public void addConstraint(HardRouteConstraint constraint){
|
||||
hardConstraints.add(constraint);
|
||||
}
|
||||
|
||||
Collection<HardRouteStateLevelConstraint> getConstraints(){ return Collections.unmodifiableCollection(hardConstraints); }
|
||||
Collection<HardRouteConstraint> getConstraints(){ return Collections.unmodifiableCollection(hardConstraints); }
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
for(HardRouteStateLevelConstraint constraint : hardConstraints){
|
||||
for(HardRouteConstraint constraint : hardConstraints){
|
||||
if(!constraint.fulfilled(insertionContext)){
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
|
||||
|
||||
public interface HardRouteStateLevelConstraint extends HardConstraint{
|
||||
|
||||
public boolean fulfilled(JobInsertionContext insertionContext);
|
||||
|
||||
}
|
||||
|
|
@ -1,3 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 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.core.problem.constraint;
|
||||
|
||||
import jsprit.core.algorithm.state.InternalStates;
|
||||
|
|
@ -9,7 +26,7 @@ import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
|||
* SkillConstraint that ensures that only vehicles with according skills can serve route and job to be inserted.
|
||||
*
|
||||
*/
|
||||
public class HardSkillConstraint implements HardRouteStateLevelConstraint{
|
||||
public class HardSkillConstraint implements HardRouteConstraint {
|
||||
|
||||
private static final Skills defaultSkills = Skills.Builder.newInstance().build();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
|||
* @author schroeder
|
||||
*
|
||||
*/
|
||||
public class PickupAndDeliverShipmentLoadActivityLevelConstraint implements HardActivityStateLevelConstraint {
|
||||
public class PickupAndDeliverShipmentLoadActivityLevelConstraint implements HardActivityConstraint {
|
||||
|
||||
private RouteAndActivityStateGetter stateManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.activity.DeliverService;
|
||||
import jsprit.core.problem.solution.route.activity.DeliverShipment;
|
||||
import jsprit.core.problem.solution.route.activity.PickupService;
|
||||
import jsprit.core.problem.solution.route.activity.PickupShipment;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.solution.route.activity.*;
|
||||
|
||||
public class ServiceDeliveriesFirstConstraint implements HardActivityStateLevelConstraint {
|
||||
public class ServiceDeliveriesFirstConstraint implements HardActivityConstraint {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
|
|
@ -34,7 +32,7 @@ import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
|||
* @author schroeder
|
||||
*
|
||||
*/
|
||||
class ServiceLoadActivityLevelConstraint implements HardActivityStateLevelConstraint {
|
||||
class ServiceLoadActivityLevelConstraint implements HardActivityConstraint {
|
||||
|
||||
private RouteAndActivityStateGetter stateManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
|
|
@ -35,7 +33,7 @@ import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
|||
* @author stefan
|
||||
*
|
||||
*/
|
||||
class ServiceLoadRouteLevelConstraint implements HardRouteStateLevelConstraint {
|
||||
class ServiceLoadRouteLevelConstraint implements HardRouteConstraint {
|
||||
|
||||
private RouteAndActivityStateGetter stateManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
|
|
@ -23,7 +21,7 @@ import jsprit.core.problem.solution.route.activity.DeliverShipment;
|
|||
import jsprit.core.problem.solution.route.activity.PickupShipment;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
|
||||
public class ShipmentPickupsFirstConstraint implements HardActivityStateLevelConstraint {
|
||||
public class ShipmentPickupsFirstConstraint implements HardActivityConstraint {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
|
|
@ -32,7 +30,7 @@ import jsprit.core.util.CalculationUtils;
|
|||
* @author stefan
|
||||
*
|
||||
*/
|
||||
class TimeWindowConstraint implements HardActivityStateLevelConstraint {
|
||||
class TimeWindowConstraint implements HardActivityConstraint {
|
||||
|
||||
private RouteAndActivityStateGetter states;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package jsprit.core.problem.constraint;
|
||||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -10,15 +8,15 @@ package jsprit.core.problem.constraint;
|
|||
*
|
||||
* 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.
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import jsprit.core.algorithm.state.InternalStates;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
|
|
@ -34,7 +32,7 @@ import jsprit.core.util.CalculationUtils;
|
|||
* @author stefan
|
||||
*
|
||||
*/
|
||||
public class VehicleDependentTimeWindowConstraints implements HardActivityStateLevelConstraint {
|
||||
public class VehicleDependentTimeWindowConstraints implements HardActivityConstraint {
|
||||
|
||||
private RouteAndActivityStateGetter states;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
|
|
@ -24,8 +22,8 @@ import jsprit.core.problem.AbstractActivity;
|
|||
import jsprit.core.problem.JobActivityFactory;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
|
|
@ -66,7 +64,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
|
||||
};
|
||||
|
||||
HardActivityStateLevelConstraint hardActivityLevelConstraint = new HardActivityStateLevelConstraint() {
|
||||
HardActivityConstraint hardActivityLevelConstraint = new HardActivityConstraint() {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
|
|
@ -74,7 +72,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
}
|
||||
};
|
||||
|
||||
HardRouteStateLevelConstraint hardRouteLevelConstraint = new HardRouteStateLevelConstraint(){
|
||||
HardRouteConstraint hardRouteLevelConstraint = new HardRouteConstraint(){
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
|
|
@ -101,7 +99,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
|
||||
}
|
||||
|
||||
private void createInsertionCalculator(HardRouteStateLevelConstraint hardRouteLevelConstraint) {
|
||||
private void createInsertionCalculator(HardRouteConstraint hardRouteLevelConstraint) {
|
||||
ConstraintManager constraintManager = new ConstraintManager(mock(VehicleRoutingProblem.class), mock(RouteAndActivityStateGetter.class));
|
||||
constraintManager.addConstraint(hardRouteLevelConstraint);
|
||||
insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, constraintManager);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
|
||||
};
|
||||
|
||||
HardActivityStateLevelConstraint hardActivityLevelConstraint = new HardActivityStateLevelConstraint() {
|
||||
HardActivityConstraint hardActivityLevelConstraint = new HardActivityConstraint() {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
|
|
@ -78,7 +78,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
}
|
||||
};
|
||||
|
||||
HardRouteStateLevelConstraint hardRouteLevelConstraint = new HardRouteStateLevelConstraint(){
|
||||
HardRouteConstraint hardRouteLevelConstraint = new HardRouteConstraint(){
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
|
|
@ -103,7 +103,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
|
||||
}
|
||||
|
||||
private void createInsertionCalculator(HardRouteStateLevelConstraint hardRouteLevelConstraint) {
|
||||
private void createInsertionCalculator(HardRouteConstraint hardRouteLevelConstraint) {
|
||||
ConstraintManager constraintManager = new ConstraintManager(mock(VehicleRoutingProblem.class), mock(RouteAndActivityStateGetter.class));
|
||||
constraintManager.addConstraint(hardRouteLevelConstraint);
|
||||
insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, constraintManager);
|
||||
|
|
@ -160,7 +160,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
VehicleRoute route = VehicleRoute.emptyRoute();
|
||||
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
|
||||
new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route);
|
||||
createInsertionCalculator(new HardRouteStateLevelConstraint() {
|
||||
createInsertionCalculator(new HardRouteConstraint() {
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package jsprit.core.algorithm.state;
|
|||
|
||||
import jsprit.core.problem.Capacity;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.constraint.PickupAndDeliverShipmentLoadActivityLevelConstraint;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
|
|
|
|||
|
|
@ -137,9 +137,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getStart(), newAct, serviceRoute.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getStart(), newAct, serviceRoute.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -154,9 +154,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -171,9 +171,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -191,9 +191,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getStart(), newAct, serviceRoute.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getStart(), newAct, serviceRoute.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -208,9 +208,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -225,9 +225,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -305,9 +305,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
PickupService newAct = new PickupService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -321,9 +321,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
PickupService newAct = new PickupService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -337,9 +337,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
PickupService newAct = new PickupService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -356,9 +356,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
PickupService newAct = new PickupService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -372,9 +372,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
PickupService newAct = new PickupService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -388,9 +388,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
PickupService newAct = new PickupService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -408,9 +408,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
DeliverService newAct = new DeliverService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -424,9 +424,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
DeliverService newAct = new DeliverService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getStart(), newAct, pickup_delivery_route.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -440,9 +440,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
DeliverService newAct = new DeliverService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -456,9 +456,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
DeliverService newAct = new DeliverService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(0), newAct, pickup_delivery_route.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -472,9 +472,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
DeliverService newAct = new DeliverService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -488,9 +488,9 @@ public class LoadConstraintTest {
|
|||
JobInsertionContext context = new JobInsertionContext(pickup_delivery_route,s,pickup_delivery_route.getVehicle(),null,0.);
|
||||
DeliverService newAct = new DeliverService(s);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, pickup_delivery_route.getActivities().get(1), newAct, pickup_delivery_route.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -505,9 +505,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -522,9 +522,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED, status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -542,9 +542,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getStart(), newAct, serviceRoute.getActivities().get(0), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getStart(), newAct, serviceRoute.getActivities().get(0), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -559,9 +559,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(0), newAct, serviceRoute.getActivities().get(1), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -576,9 +576,9 @@ public class LoadConstraintTest {
|
|||
ServiceActivity newAct = mock(ServiceActivity.class);
|
||||
when(newAct.getSize()).thenReturn(newSize);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context, serviceRoute.getActivities().get(1), newAct, serviceRoute.getEnd(), 0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, status);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -612,9 +612,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -629,9 +629,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -646,9 +646,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -663,9 +663,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -680,9 +680,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -697,9 +697,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -714,9 +714,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -731,9 +731,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -748,9 +748,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -765,9 +765,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
PickupShipment newAct = new PickupShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -786,9 +786,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -803,9 +803,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getStart(),newAct,shipment_route.getActivities().get(0),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -820,9 +820,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -837,9 +837,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(0),newAct,shipment_route.getActivities().get(1),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -854,9 +854,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -871,9 +871,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(1),newAct,shipment_route.getActivities().get(2),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -888,9 +888,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -905,9 +905,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(2),newAct,shipment_route.getActivities().get(3),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -922,9 +922,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -939,9 +939,9 @@ pickup(s1) pickup(s2) delivery(s2) deliver(s1)
|
|||
|
||||
DeliverShipment newAct = new DeliverShipment(s);
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint loadConstraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
HardActivityConstraint.ConstraintsStatus status = loadConstraint.fulfilled(context,shipment_route.getActivities().get(3),newAct,shipment_route.getEnd(),0.);
|
||||
|
||||
assertEquals(HardActivityStateLevelConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK,status);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 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.core.problem.constraint;
|
||||
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
|
|
@ -19,7 +36,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class SkillConstraintTest {
|
||||
|
||||
private HardRouteStateLevelConstraint skillConstraint;
|
||||
private HardRouteConstraint skillConstraint;
|
||||
|
||||
private VehicleRoute route;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* 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
|
||||
* 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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.constraint;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class TestConstraintManager {
|
||||
|
||||
|
|
@ -35,7 +32,7 @@ public class TestConstraintManager {
|
|||
public void whenGettingConstraintsViaConstructor_theyShouldBeResolvedCorrectly(){
|
||||
List<Constraint> constraints = new ArrayList<Constraint>();
|
||||
constraints.add(new ServiceDeliveriesFirstConstraint());
|
||||
constraints.add(mock(HardRouteStateLevelConstraint.class));
|
||||
constraints.add(mock(HardRouteConstraint.class));
|
||||
ConstraintManager cManager = new ConstraintManager(mock(VehicleRoutingProblem.class),mock(RouteAndActivityStateGetter.class),constraints);
|
||||
assertEquals(2,cManager.getConstraints().size());
|
||||
}
|
||||
|
|
@ -86,7 +83,7 @@ public class TestConstraintManager {
|
|||
assertEquals(0,man.getConstraints().size());
|
||||
man.addConstraint(c1);
|
||||
man.addConstraint(c2);
|
||||
assertEquals(2,man.getConstraints().size());
|
||||
assertEquals(2, man.getConstraints().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 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.core.problem.constraint;
|
||||
|
||||
import jsprit.core.algorithm.state.InternalStates;
|
||||
|
|
@ -143,10 +160,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertTrue(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertTrue(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -158,10 +175,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -173,13 +190,13 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
/*
|
||||
driverTime = 10 + 10 + 30 + 20 + 30 = 100
|
||||
*/
|
||||
// System.out.println("latest act1 " + stateManager.getActivityState());
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 20.);
|
||||
assertTrue(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 20.);
|
||||
assertTrue(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -195,10 +212,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
driverTime = 10 + 10 + 31 + 21 + 30 = 102
|
||||
*/
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 20.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 20.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -213,11 +230,11 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v2,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -232,10 +249,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v3,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -250,10 +267,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v4,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -268,10 +285,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v6,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 30.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 30.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -286,10 +303,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v6,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(0), serviceAct, route.getActivities().get(1), 10.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(0), serviceAct, route.getActivities().get(1), 10.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -304,10 +321,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v6,route.getDriver(),0.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertTrue(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
|
||||
assertTrue(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -320,10 +337,10 @@ public class VehicleDependentTimeWindowTest {
|
|||
|
||||
JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v5,route.getDriver(),60.);
|
||||
|
||||
HardActivityStateLevelConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
|
||||
|
||||
HardActivityStateLevelConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 90.);
|
||||
assertFalse(status.equals(HardActivityStateLevelConstraint.ConstraintsStatus.FULFILLED));
|
||||
HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 90.);
|
||||
assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import jsprit.core.algorithm.state.StateManager;
|
|||
import jsprit.core.algorithm.state.StateUpdater;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -93,7 +93,7 @@ public class AdditionalDistanceConstraintExample {
|
|||
}
|
||||
}
|
||||
|
||||
static class DistanceConstraint implements HardActivityStateLevelConstraint {
|
||||
static class DistanceConstraint implements HardActivityConstraint {
|
||||
|
||||
private final StateManager stateManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import jsprit.core.problem.VehicleRoutingProblem;
|
|||
import jsprit.core.problem.VehicleRoutingProblem.Builder;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.job.Job;
|
||||
|
|
@ -83,7 +83,7 @@ public class BicycleMessenger {
|
|||
* @author stefan
|
||||
*
|
||||
*/
|
||||
static class ThreeTimesLessThanBestDirectRouteConstraint implements HardActivityStateLevelConstraint {
|
||||
static class ThreeTimesLessThanBestDirectRouteConstraint implements HardActivityConstraint {
|
||||
|
||||
private final VehicleRoutingTransportCosts routingCosts;
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ public class BicycleMessenger {
|
|||
* @author schroeder
|
||||
*
|
||||
*/
|
||||
static class IgnoreMessengerThatCanNeverMeetTimeRequirements implements HardRouteStateLevelConstraint {
|
||||
static class IgnoreMessengerThatCanNeverMeetTimeRequirements implements HardRouteConstraint {
|
||||
|
||||
private final Map<String,Double> bestMessengers;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
|
|||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -130,7 +130,7 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstrain
|
|||
*
|
||||
* switch off the geoConstraints to see the impact of this constraint on routes, or just exchange v1 and v2 to reverse the geo-constraint.
|
||||
*/
|
||||
HardRouteStateLevelConstraint geoClusterConstraint = new HardRouteStateLevelConstraint() {
|
||||
HardRouteConstraint geoClusterConstraint = new HardRouteConstraint() {
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import jsprit.core.algorithm.state.StateManager;
|
|||
import jsprit.core.problem.Capacity;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityConstraint;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -39,6 +39,8 @@ import jsprit.core.util.Solutions;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
//import jsprit.core.problem.constraint.HardActivityStateLevelConstraint; //v1.3.1
|
||||
|
||||
//import jsprit.core.problem.solution.route.state.StateFactory; //v1.3.1
|
||||
|
||||
public class MultipleProductsWithLoadConstraintExample {
|
||||
|
|
@ -47,7 +49,8 @@ public class MultipleProductsWithLoadConstraintExample {
|
|||
|
||||
static final int APPLES_DIMENSION_INDEX = 1;
|
||||
|
||||
static class BananasFirst implements HardActivityStateLevelConstraint {
|
||||
// static class BananasFirst implements HardActivityStateLevelConstraint { //v1.3.1
|
||||
static class BananasFirst implements HardActivityConstraint {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext jobInsertionContext, TourActivity prevActivity, TourActivity newActivity, TourActivity nextActivity, double departureTimeAtPrevActivity) {
|
||||
|
|
@ -65,7 +68,8 @@ public class MultipleProductsWithLoadConstraintExample {
|
|||
}
|
||||
}
|
||||
|
||||
static class NoBananasANDApplesConstraint implements HardActivityStateLevelConstraint {
|
||||
//static class NoBananasANDApplesConstraint implements HardActivityStateLevelConstraint { //v1.3.1
|
||||
static class NoBananasANDApplesConstraint implements HardActivityConstraint {
|
||||
|
||||
private StateManager stateManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
|
|||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -143,7 +143,7 @@ public class TransportOfDisabledPeople {
|
|||
*
|
||||
* wheelchair-bus can only pickup passenger where x<15
|
||||
*/
|
||||
HardRouteStateLevelConstraint wheelchair_bus_passenger_pickup_constraint = new HardRouteStateLevelConstraint() {
|
||||
HardRouteConstraint wheelchair_bus_passenger_pickup_constraint = new HardRouteConstraint() {
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue