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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue