Package jsprit.core.problem

Examples of jsprit.core.problem.Capacity$Builder


    @Test
    public void whenShipmentRouteAndDeliveryOfNewShipmentShouldNotFitInBetweenAct4AndEnd(){
        stateManager.informInsertionStarts(Arrays.asList(shipment_route), Collections.<Job>emptyList());
        Shipment s = mock(Shipment.class);
        Capacity newSize = Capacity.Builder.newInstance().addDimension(0,21).build();
        when(s.getSize()).thenReturn(newSize);

        JobInsertionContext context = new JobInsertionContext(shipment_route,s,shipment_route.getVehicle(),null,0.);

        DeliverShipment newAct = new DeliverShipment(s);
View Full Code Here


            this.stateManager = stateManager;
        }

        @Override
        public ConstraintsStatus fulfilled(JobInsertionContext jobInsertionContext, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double departureTimeAtPrevAct) {
            Capacity loadAtPrevAct = getLoadAtPreviousAct(prevAct);

            if( isPickup(newAct) ){
                if( ( isApplePickup(newAct) && hasBananasInVehicle(loadAtPrevAct) ) ||
                        ( isBananaPickup(newAct) && hasApplesInVehicle(loadAtPrevAct) ) ){
                    return ConstraintsStatus.NOT_FULFILLED;
View Full Code Here

            return newAct.getName().equals("deliverShipment");
        }

        private Capacity getLoadAtPreviousAct(TourActivity prevAct) {
//            Capacity prevLoad = stateManager.getActivityState(prevAct, StateFactory.LOAD, Capacity.class); //v1.3.1
            Capacity prevLoad = stateManager.getActivityState(prevAct, InternalStates.LOAD, Capacity.class); //1.3.2-SNAPSHOT & upcoming release v1.4
            if(prevLoad != null) return prevLoad;
            else return Capacity.Builder.newInstance().build();
        }
View Full Code Here

    vehicle = mock(Vehicle.class);
    when(vehicle.getType()).thenReturn(type);
   
    route = mock(VehicleRoute.class);
   
    Capacity currentLoad = Capacity.Builder.newInstance().addDimension(0, 1).addDimension(1, 1).addDimension(2, 1).build();
    stateGetter = mock(RouteAndActivityStateGetter.class);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_BEGINNING, Capacity.class)).thenReturn(currentLoad);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_END, Capacity.class)).thenReturn(currentLoad);
    when(stateGetter.getRouteState(route, InternalStates.MAXLOAD, Capacity.class)).thenReturn(currentLoad);
View Full Code Here

  @Test
  public void whenAddingAServiceAndNewVehicleDoesNotHaveTheCapacity_itShouldReturnFalse(){
    Service service = mock(Service.class);
    when(service.getSize()).thenReturn(Capacity.Builder.newInstance().addDimension(0, 2).build());
   
    Capacity atBeginning = Capacity.Builder.newInstance().addDimension(0, 1).addDimension(1, 2).addDimension(2, 1).build();
    Capacity atEnd = Capacity.Builder.newInstance().addDimension(0, 0).addDimension(1, 0).addDimension(2, 0).build();
   
    RouteAndActivityStateGetter stateGetter = mock(RouteAndActivityStateGetter.class);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_BEGINNING, Capacity.class)).thenReturn(atBeginning);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_END, Capacity.class)).thenReturn(atEnd);
    when(stateGetter.getRouteState(route, InternalStates.MAXLOAD, Capacity.class)).thenReturn(atBeginning);
View Full Code Here

  @Test
  public void whenAddingADeliveryAndNewVehicleDoesNotHaveTheCapacity_itShouldReturnFalse(){
    Service service = mock(Delivery.class);
    when(service.getSize()).thenReturn(Capacity.Builder.newInstance().addDimension(0, 2).build());
   
    Capacity atBeginning = Capacity.Builder.newInstance().addDimension(0, 1).addDimension(1, 2).addDimension(2, 1).build();
    Capacity atEnd = Capacity.Builder.newInstance().addDimension(0, 0).addDimension(1, 0).addDimension(2, 0).build();
   
    RouteAndActivityStateGetter stateGetter = mock(RouteAndActivityStateGetter.class);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_BEGINNING, Capacity.class)).thenReturn(atBeginning);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_END, Capacity.class)).thenReturn(atEnd);
    when(stateGetter.getRouteState(route, InternalStates.MAXLOAD, Capacity.class)).thenReturn(atBeginning);
View Full Code Here

  @Test
  public void whenAddingAPickupAndNewVehicleDoesNotHaveTheCapacity_itShouldReturnFalse(){
    Pickup service = mock(Pickup.class);
    when(service.getSize()).thenReturn(Capacity.Builder.newInstance().addDimension(0, 2).build());
   
    Capacity atBeginning = Capacity.Builder.newInstance().addDimension(0, 1).addDimension(1, 2).addDimension(2, 1).build();
    Capacity atEnd = Capacity.Builder.newInstance().addDimension(0, 0).addDimension(1, 0).addDimension(2, 0).build();
   
    RouteAndActivityStateGetter stateGetter = mock(RouteAndActivityStateGetter.class);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_BEGINNING, Capacity.class)).thenReturn(atBeginning);
    when(stateGetter.getRouteState(route, InternalStates.LOAD_AT_END, Capacity.class)).thenReturn(atEnd);
    when(stateGetter.getRouteState(route, InternalStates.MAXLOAD, Capacity.class)).thenReturn(atBeginning);
View Full Code Here

  @Override
  public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
    if(!(newAct instanceof PickupShipment) && !(newAct instanceof DeliverShipment)){
      return ConstraintsStatus.FULFILLED;
    }
    Capacity loadAtPrevAct;
    if(prevAct instanceof Start){
      loadAtPrevAct = stateManager.getRouteState(iFacts.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class);
            if(loadAtPrevAct == null) loadAtPrevAct = defaultValue;
    }
    else{
View Full Code Here

        defaultValue = Capacity.Builder.newInstance().build();
  }

  @Override
  public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
    Capacity futureMaxLoad;
    Capacity prevMaxLoad;
    if(prevAct instanceof Start){
      futureMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.MAXLOAD, Capacity.class);
            if(futureMaxLoad == null) futureMaxLoad = defaultValue;
      prevMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class);
            if(prevMaxLoad == null) prevMaxLoad = defaultValue;
View Full Code Here

      }
      else if(counter <= (nOfCustomers+nOfDepots+nOfDepots)){
        Coordinate depotCoord = makeCoord(tokens[1].trim(),tokens[2].trim());
        List<Builder> vBuilders = vehiclesAtDepot.get(depotCounter);
//        int cap = 0;
        Capacity cap = Capacity.Builder.newInstance().build();
        double latestArrTime = 0.0;
        Coordinate coord = null;
        String typeId = null;
        for(Builder vBuilder : vBuilders){
          vBuilder.setStartLocationCoordinate(depotCoord);
View Full Code Here

TOP

Related Classes of jsprit.core.problem.Capacity$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.