Package jsprit.core.algorithm

Examples of jsprit.core.algorithm.SearchStrategy


  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


   
    when(select.selectSolution(null)).thenReturn(newSol);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
    SearchStrategyModule mod = new SearchStrategyModule() {
     
      @Override
      public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
        runs.add(1);
        return vrpSolution;
      }

      @Override
      public String getName() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public void addModuleListener(
          SearchStrategyModuleListener moduleListener) {
        // TODO Auto-generated method stub
       
      }
    };
    strat.addModule(mod);
    strat.run(vrp, null);
   
    assertEquals(runs.size(), 1);
  }
View Full Code Here

   
    when(select.selectSolution(null)).thenReturn(newSol);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
   
    SearchStrategyModule mod = new SearchStrategyModule() {
     
      @Override
      public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
        runs.add(1);
        return vrpSolution;
      }

      @Override
      public String getName() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public void addModuleListener(
          SearchStrategyModuleListener moduleListener) {
        // TODO Auto-generated method stub
       
      }
    };
    SearchStrategyModule mod2 = new SearchStrategyModule() {
     
      @Override
      public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
        runs.add(1);
        return vrpSolution;
      }

      @Override
      public String getName() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public void addModuleListener(
          SearchStrategyModuleListener moduleListener) {
        // TODO Auto-generated method stub
       
      }
    };
    strat.addModule(mod);
    strat.addModule(mod2);
    strat.run(vrp, null);
   
    assertEquals(runs.size(), 2);
  }
View Full Code Here

   
    int N = new Random().nextInt(1000);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
   
    for(int i=0;i<N;i++){
      SearchStrategyModule mod = new SearchStrategyModule() {

        @Override
        public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
          runs.add(1);
          return vrpSolution;
        }

        @Override
        public String getName() {
          // TODO Auto-generated method stub
          return null;
        }

        @Override
        public void addModuleListener(
            SearchStrategyModuleListener moduleListener) {
          // TODO Auto-generated method stub
         
        }
      };
      strat.addModule(mod);
    }
    strat.run(vrp, null);
    assertEquals(runs.size(), N);
  }
View Full Code Here

   
    int N = new Random().nextInt(1000);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
   
    for(int i=0;i<N;i++){
      SearchStrategyModule mod = new SearchStrategyModule() {

        @Override
        public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
          runs.add(1);
          return vrpSolution;
        }

        @Override
        public String getName() {
          // TODO Auto-generated method stub
          return null;
        }

        @Override
        public void addModuleListener(
            SearchStrategyModuleListener moduleListener) {
          // TODO Auto-generated method stub
         
        }
      };
      strat.addModule(mod);
    }
    strat.run(vrp, null);
    assertEquals(runs.size(), N);
  }
View Full Code Here

public class SearchStrategyManagerTest {

  @Test
  public void StrategyManagerInAction_addingStrategy_IsSuccessful(){
    SearchStrategyManager manager = new SearchStrategyManager();
    SearchStrategy strat1 = mock(SearchStrategy.class);
    SearchStrategy strat2 = mock(SearchStrategy.class);
    manager.addStrategy(strat1, 0.5);
    manager.addStrategy(strat2, 0.5);
    assertTrue(true);
  }
View Full Code Here

  }
 
  @Test(expected=IllegalStateException.class)
  public void StrategyManagerInAction_probabilityIsHigherThanOne_throwsException(){
    SearchStrategyManager manager = new SearchStrategyManager();
    SearchStrategy strat = mock(SearchStrategy.class);
    manager.addStrategy(strat, 1.5);
    assertTrue(false);
  }
View Full Code Here

  }
 
  @Test(expected=IllegalStateException.class)
  public void StrategyManagerInAction_probabilityIsLowerThanZero_throwsException(){
    SearchStrategyManager manager = new SearchStrategyManager();
    SearchStrategy strat = mock(SearchStrategy.class);
    manager.addStrategy(strat, -1.0);
    assertTrue(false);
  }
View Full Code Here

  }
 
  @Test(expected = IllegalStateException.class)
  public void StrategyManagerInAction_addingSeveralStratsLeadsToAProbHigherThanOne_throwsException(){
    SearchStrategyManager manager = new SearchStrategyManager();
    SearchStrategy mockedStrat1 = mock(SearchStrategy.class);
    SearchStrategy mockedStrat2 = mock(SearchStrategy.class);
   
    manager.addStrategy(mockedStrat1, 0.5);
    manager.addStrategy(mockedStrat2, 0.6);
  }
View Full Code Here

  }
 
  @Test
  public void whenRandomDices_0point1_returnsStrategy1(){
    SearchStrategyManager managerUnderTest = new SearchStrategyManager();
    SearchStrategy mockedStrategy1 = mock(SearchStrategy.class);
    SearchStrategy mockedStrategy2 = mock(SearchStrategy.class);
    managerUnderTest.addStrategy(mockedStrategy1, 0.2);
    managerUnderTest.addStrategy(mockedStrategy2, 0.8);
   
    Random mockedRandom = mock(Random.class);
    managerUnderTest.setRandom(mockedRandom);
View Full Code Here

TOP

Related Classes of jsprit.core.algorithm.SearchStrategy

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.