@@ -0,0 +1,2277 @@
+package algorithms;%0A%0Aimport basics.route.DeliverShipment;%0Aimport basics.route.PickupShipment;%0Aimport basics.route.Start;%0Aimport basics.route.TourActivity;%0A%0Aclass HardPickupAndDeliveryShipmentActivityLevelConstraint implements HardActivityLevelConstraint %7B%0A%09%0A%09private StateManager stateManager;%0A%09%0A%09private boolean backhaul = false;%0A%09%0A%09public HardPickupAndDeliveryShipmentActivityLevelConstraint(StateManager stateManager) %7B%0A%09%09super();%0A%09%09this.stateManager = stateManager;%0A%09%7D%0A%0A%09public HardPickupAndDeliveryShipmentActivityLevelConstraint(StateManager stateManager, boolean backhaul) %7B%0A%09%09super();%0A%09%09this.stateManager = stateManager;%0A%09%09this.backhaul = backhaul;%0A%09%7D%0A%09%0A%09@Override%0A%09public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) %7B%0A%09%09if(!(newAct instanceof PickupShipment) && !(newAct instanceof DeliverShipment))%7B%0A%09%09%09return ConstraintsStatus.FULFILLED;%0A%09%09%7D%0A%09%09if(backhaul)%7B%0A//%09%09%09if(newAct instanceof PickupShipment && nextAct instanceof DeliverShipment)%7B return false; %7D%0A%09%09%09if(newAct instanceof DeliverShipment && prevAct instanceof PickupShipment)%7B return ConstraintsStatus.NOT_FULFILLED; %7D%0A%09%09%7D%0A%09%09int loadAtPrevAct;%0A//%09%09int futurePicks;%0A//%09%09int pastDeliveries;%0A%09%09if(prevAct instanceof Start)%7B%0A%09%09%09loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING).toDouble();%0A//%09%09%09futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateTypes.LOAD).toDouble();%0A//%09%09%09pastDeliveries = 0;%0A%09%09%7D%0A%09%09else%7B%0A%09%09%09loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateFactory.LOAD).toDouble();%0A//%09%09%09futurePicks = (int) stateManager.getActivityState(prevAct, StateTypes.FUTURE_PICKS).toDouble();%0A//%09%09%09pastDeliveries = (int) stateManager.getActivityState(prevAct, StateTypes.PAST_DELIVERIES).toDouble();%0A%09%09%7D%0A%09%09if(newAct instanceof PickupShipment)%7B%0A%09%09%09if(loadAtPrevAct + newAct.getCapacityDemand() %3E iFacts.getNewVehicle().getCapacity())%7B%0A%09%09%09%09return ConstraintsStatus.NOT_FULFILLED;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09if(newAct instanceof DeliverShipment)%7B%0A%09%09%09if(loadAtPrevAct + Math.abs(newAct.getCapacityDemand()) %3E iFacts.getNewVehicle().getCapacity())%7B%0A%09%09%09%09return ConstraintsStatus.NOT_FULFILLED_BREAK;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D%0A%09%09return ConstraintsStatus.FULFILLED;%0A%09%7D%0A%09%0A%09%09%0A%7D

refine contraint