Package jsprit.core.algorithm.selector

Examples of jsprit.core.algorithm.selector.SolutionSelector


    SearchStrategyManager searchStratManager = new SearchStrategyManager();
    List<HierarchicalConfiguration> strategyConfigs = config.configurationsAt("strategy.searchStrategies.searchStrategy");
    for(HierarchicalConfiguration strategyConfig : strategyConfigs){
      String name = getName(strategyConfig);
      SolutionAcceptor acceptor = getAcceptor(strategyConfig,vrp,algorithmListeners,definedClasses,solutionMemory);
      SolutionSelector selector = getSelector(strategyConfig,vrp,algorithmListeners,definedClasses);
     
      SearchStrategy strategy = new SearchStrategy(selector, acceptor, costCalculator);
      strategy.setName(name);
      List<HierarchicalConfiguration> modulesConfig = strategyConfig.configurationsAt("modules.module");
      for(HierarchicalConfiguration moduleConfig : modulesConfig){
View Full Code Here


    if(selectorName == null) throw new IllegalStateException("no solutionSelector defined. define either \"selectRandomly\" or \"selectBest\"");
    String selectorId = strategyConfig.getString("selector[@id]");
    if(selectorId == null) selectorId="noId";
    ModKey modKey = makeKey(selectorName,selectorId);
    SelectorKey selectorKey = new SelectorKey(modKey);
    SolutionSelector definedSelector = definedSelectors.get(selectorKey);
    if(definedSelector != null) {
      return definedSelector;
    }
    if(selectorName.equals("selectRandomly")){
      SelectRandomly selector = SelectRandomly.getInstance();
View Full Code Here

public class SearchStrategyTest {
 
  @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);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
    SearchStrategyModule mod = new SearchStrategyModule() {
View Full Code Here

    assertEquals(runs.size(), 1);
  }
 
  @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);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
    SearchStrategy strat = new SearchStrategy(select, accept, calc);
   
View Full Code Here

    ModKey key = new ModKey(acceptorName,acceptorId);
    AcceptorKey accKey = new AcceptorKey(key);
    SolutionAcceptor acceptor =  new GreedyAcceptance(1);
   
    SelectorKey selKey = new SelectorKey(new ModKey(selectorName,selectorId));
    SolutionSelector selector = new SelectBest();
   
    typedMap.put(accKey, acceptor);
    typedMap.put(selKey, selector);
   
    assertEquals(acceptor,typedMap.get(accKey));
View Full Code Here

    ModKey key = new ModKey(acceptorName,acceptorId);
    AcceptorKey accKey = new AcceptorKey(key);
    SolutionAcceptor acceptor =  new GreedyAcceptance(1);
   
    SelectorKey selKey = new SelectorKey(new ModKey(selectorName,selectorId));
    SolutionSelector selector = new SelectBest();
   
    AcceptorKey accKey2 = new AcceptorKey(new ModKey(acceptorName2,acceptorId2));
    SolutionAcceptor acceptor2 =  new GreedyAcceptance(1);
   
    typedMap.put(accKey, acceptor);
View Full Code Here

    assertEquals(runs.size(), 2);
  }
 
  @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);
   
    int N = new Random().nextInt(1000);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
View Full Code Here

    assertEquals(runs.size(), N);
  }
 
  @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);
   
    int N = new Random().nextInt(1000);
   
    final Collection<Integer> runs = new ArrayList<Integer>();
   
View Full Code Here

TOP

Related Classes of jsprit.core.algorithm.selector.SolutionSelector

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.