Package jsprit.core.problem.solution

Examples of jsprit.core.problem.solution.SolutionCostCalculator


    super();
    this.stateManager = stateManager;
  }

  public SolutionCostCalculator createCalculator(){
    return new SolutionCostCalculator() {

      @Override
      public double getCosts(VehicleRoutingProblemSolution solution) {
        double c = 0.0;
                for(VehicleRoute r : solution.getRoutes()){
View Full Code Here


            activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_ARRIVED;
        }
        stateManager.addStateUpdater(new UpdateActivityTimes(vrp.getTransportCosts(),activityPolicy));
        stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager, activityPolicy));

    SolutionCostCalculator costCalculator;
    if(solutionCostCalculator==null) costCalculator = getDefaultCostCalculator(stateManager);
    else costCalculator = solutionCostCalculator;
   
    //construct initial solution creator
    AlgorithmStartsListener createInitialSolution = createInitialSolution(config,vrp,vehicleFleetManager,stateManager,algorithmListeners,definedClasses,executorService,nuOfThreads,costCalculator, constraintManager, addDefaultCostCalculators);
View Full Code Here

     */
    /*
     * but before define how a generated solution is evaluated
     * here: the VariablePlusFixed.... comes out of the box and it does what its name suggests
     */
    SolutionCostCalculator solutionCostCalculator = new VariablePlusFixedSolutionCostCalculatorFactory(stateManager).createCalculator();
   
    SearchStrategy firstStrategy = new SearchStrategy(new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
    firstStrategy.addModule(new RuinAndRecreateModule("randomRuinAndBestInsertion", iStrategy, randomRuin));
   
    SearchStrategy secondStrategy = new SearchStrategy(new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
View Full Code Here

        RuinStrategy radial = new RadialRuinStrategyFactory( 0.3, new AvgServiceAndShipmentDistance(vrp.getTransportCosts())).createStrategy(vrp);
        RuinStrategy random = new RandomRuinStrategyFactory(0.5).createStrategy(vrp);


        SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {

            @Override
            public double getCosts(VehicleRoutingProblemSolution solution) {
                double costs = 0.0;
                for(VehicleRoute route : solution.getRoutes()){
View Full Code Here

 
  @Test(expected=IllegalStateException.class)
  public void whenANullModule_IsAdded_throwException(){
    SolutionSelector select = mock(SolutionSelector.class);
    SolutionAcceptor accept = mock(SolutionAcceptor.class);
    SolutionCostCalculator calc = mock(SolutionCostCalculator.class);
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
    strat.addModule(null);
   
  }
View Full Code Here

 
  @Test
  public void whenStratRunsWithOneModule_runItOnes(){
    SolutionSelector select = mock(SolutionSelector.class);
    SolutionAcceptor accept = mock(SolutionAcceptor.class);
    SolutionCostCalculator calc = mock(SolutionCostCalculator.class);
   
    final VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
    final VehicleRoutingProblemSolution newSol = mock(VehicleRoutingProblemSolution.class);
   
    when(select.selectSolution(null)).thenReturn(newSol);
View Full Code Here

    InsertionStrategy bestInsertion = new BestInsertionBuilder(vrp, fleetManager, stateManager, cManager).build();
   
    RuinStrategy radial = new RadialRuinStrategyFactory(0.15, new AvgServiceDistance(vrp.getTransportCosts())).createStrategy(vrp);
    RuinStrategy random = new RandomRuinStrategyFactory(0.25).createStrategy(vrp);
   
    SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
     
      @Override
      public double getCosts(VehicleRoutingProblemSolution solution) {
        double costs = 0.0;
        for(VehicleRoute route : solution.getRoutes()){
View Full Code Here

 
  @Test
  public void whenStratRunsWithTwoModule_runItTwice(){
    SolutionSelector select = mock(SolutionSelector.class);
    SolutionAcceptor accept = mock(SolutionAcceptor.class);
    SolutionCostCalculator calc = mock(SolutionCostCalculator.class);
   
    final VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
    final VehicleRoutingProblemSolution newSol = mock(VehicleRoutingProblemSolution.class);
   
    when(select.selectSolution(null)).thenReturn(newSol);
View Full Code Here

 
  @Test
  public void whenStratRunsWithNModule_runItNTimes(){
    SolutionSelector select = mock(SolutionSelector.class);
    SolutionAcceptor accept = mock(SolutionAcceptor.class);
    SolutionCostCalculator calc = mock(SolutionCostCalculator.class);
   
    final VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
    final VehicleRoutingProblemSolution newSol = mock(VehicleRoutingProblemSolution.class);
   
    when(select.selectSolution(null)).thenReturn(newSol);
View Full Code Here

 
  @Test(expected=IllegalStateException.class)
  public void whenSelectorDeliversNullSolution_throwException(){
    SolutionSelector select = mock(SolutionSelector.class);
    SolutionAcceptor accept = mock(SolutionAcceptor.class);
    SolutionCostCalculator calc = mock(SolutionCostCalculator.class);
   
    final VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
   
    when(select.selectSolution(null)).thenReturn(null);
   
View Full Code Here

TOP

Related Classes of jsprit.core.problem.solution.SolutionCostCalculator

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.