Package jsprit.core.algorithm

Examples of jsprit.core.algorithm.SearchStrategyManager


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


    assertTrue(true);
  }
 
  @Test(expected=IllegalStateException.class)
  public void StrategyManagerInAction_strategyIsNull_throwsException(){
    SearchStrategyManager manager = new SearchStrategyManager();
    manager.addStrategy(null, 1.0);
    assertTrue(false);
  }
View Full Code Here

    assertTrue(false);
  }
 
  @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

    assertTrue(false);
  }
 
  @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

    assertTrue(false);
  }
 
  @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

    manager.addStrategy(mockedStrat2, 0.6);
  }
 
  @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);
    stub(mockedRandom.nextDouble()).toReturn(0.1);
   
    assertThat(managerUnderTest.getRandomStrategy(), is(mockedStrategy1));
   
  }
View Full Code Here

   
  }
 
  @Test
  public void whenRandomDices_0point5_returnsStrategy2(){
    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);
    when(mockedRandom.nextDouble()).thenReturn(0.5);
   
    assertThat(managerUnderTest.getRandomStrategy(), is(mockedStrategy2));
   
  }
View Full Code Here

   
  }
 
  @Test
  public void whenRandomDices_0point0_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);
    when(mockedRandom.nextDouble()).thenReturn(0.0);
   
    assertThat(managerUnderTest.getRandomStrategy(), is(mockedStrategy1));
   
  }
View Full Code Here

   
  }
 
  @Test(expected=IllegalStateException.class)
  public void whenRandomIsNull_throwException(){
    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 = null;
    managerUnderTest.setRandom(mockedRandom);
    managerUnderTest.getRandomStrategy();
   
  }
View Full Code Here

TOP

Related Classes of jsprit.core.algorithm.SearchStrategyManager

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.