Package jsprit.core.problem

Examples of jsprit.core.problem.Capacity


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

  @Override
  public boolean fulfilled(JobInsertionContext insertionContext) {
    Capacity maxLoadAtRoute = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.MAXLOAD, Capacity.class);
    if(maxLoadAtRoute == null) maxLoadAtRoute = defaultValue;
        Capacity capacityDimensions = insertionContext.getNewVehicle().getType().getCapacityDimensions();
    if(!maxLoadAtRoute.isLessOrEqual(capacityDimensions)){
      return false;
    }
    if(insertionContext.getJob() instanceof Delivery){
      Capacity loadAtDepot = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class);
      if(loadAtDepot == null) loadAtDepot = defaultValue;
            if(!Capacity.addup(loadAtDepot, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)){
        return false;
      }
    }
    else if(insertionContext.getJob() instanceof Pickup || insertionContext.getJob() instanceof Service){
      Capacity loadAtEnd = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.LOAD_AT_END, Capacity.class);
      if(loadAtEnd == null) loadAtEnd = defaultValue;
            if(!Capacity.addup(loadAtEnd, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)){
        return false;
      }
    }
View Full Code Here



    @Test
    public void loadAtEndShouldBe15(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity routeState = stateManager.getRouteState(serviceRoute, InternalStates.LOAD_AT_END, Capacity.class);
        assertEquals(15,routeState.get(0));
    }
View Full Code Here

    }

    @Test
    public void loadAtBeginningShouldBe0(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity routeState = stateManager.getRouteState(serviceRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.class);
        assertEquals(0,routeState.get(0));
    }
View Full Code Here

    }

    @Test
    public void loadAtAct1ShouldBe10(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity atAct1 = stateManager.getActivityState(serviceRoute.getActivities().get(0), InternalStates.LOAD, Capacity.class);
        assertEquals(10,atAct1.get(0));
    }
View Full Code Here

    }

    @Test
    public void loadAtAct2ShouldBe15(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity atAct2 = stateManager.getActivityState(serviceRoute.getActivities().get(1), InternalStates.LOAD, Capacity.class);
        assertEquals(15,atAct2.get(0));
    }
View Full Code Here

    }

    @Test
    public void futureMaxLoatAtAct1ShouldBe15(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity atAct1 = stateManager.getActivityState(serviceRoute.getActivities().get(0), InternalStates.FUTURE_MAXLOAD, Capacity.class);
        assertEquals(15,atAct1.get(0));
    }
View Full Code Here

    }

    @Test
    public void futureMaxLoatAtAct2ShouldBe15(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity atAct2 = stateManager.getActivityState(serviceRoute.getActivities().get(1), InternalStates.FUTURE_MAXLOAD, Capacity.class);
        assertEquals(15,atAct2.get(0));
    }
View Full Code Here

    }

    @Test
    public void pastMaxLoatAtAct1ShouldBe0(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity atAct1 = stateManager.getActivityState(serviceRoute.getActivities().get(0), InternalStates.PAST_MAXLOAD, Capacity.class);
        assertEquals(10,atAct1.get(0));
    }
View Full Code Here

    }

    @Test
    public void pastMaxLoatAtAct2ShouldBe10(){
        stateManager.informInsertionStarts(Arrays.asList(serviceRoute), Collections.<Job>emptyList());
        Capacity atAct2 = stateManager.getActivityState(serviceRoute.getActivities().get(1), InternalStates.PAST_MAXLOAD, Capacity.class);
        assertEquals(15,atAct2.get(0));
    }
View Full Code Here

    pickup 10 and deliver 5
     */
    @Test
    public void when_pdroute_loadAtEndShouldBe10(){
        stateManager.informInsertionStarts(Arrays.asList(pickup_delivery_route), Collections.<Job>emptyList());
        Capacity routeState = stateManager.getRouteState(pickup_delivery_route, InternalStates.LOAD_AT_END, Capacity.class);
        assertEquals(10,routeState.get(0));
    }
View Full Code Here

TOP

Related Classes of jsprit.core.problem.Capacity

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.