Examples of VehicleRoutingProblemSolution


Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

   * @return discoveredSolution
     * @throws java.lang.IllegalStateException if selector cannot select any solution
     */
  @SuppressWarnings("UnusedParameters")
    public DiscoveredSolution run(VehicleRoutingProblem vrp, Collection<VehicleRoutingProblemSolution> solutions){
    VehicleRoutingProblemSolution solution = solutionSelector.selectSolution(solutions);
    if(solution == null) throw new IllegalStateException(getErrMsg());
    VehicleRoutingProblemSolution lastSolution = VehicleRoutingProblemSolution.copyOf(solution);
    for(SearchStrategyModule module : searchStrategyModules){
            lastSolution = module.runAndGetSolution(lastSolution);
    }
    double costs = solutionCostCalculator.getCosts(lastSolution);
    lastSolution.setCost(costs);
    boolean solutionAccepted = solutionAcceptor.acceptSolution(solutions, lastSolution);
    return new DiscoveredSolution(lastSolution, solutionAccepted, getName());
  }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    boolean solutionAccepted = false;
    if (solutions.size() < solutionMemory) {
      solutions.add(newSolution);
      solutionAccepted = true;
    } else {
      VehicleRoutingProblemSolution worst = null;
      double threshold = getThreshold(currentIteration);
      for(VehicleRoutingProblemSolution solutionInMemory : solutions){
        if(worst == null) worst = solutionInMemory;
        else if(solutionInMemory.getCost() > worst.getCost()) worst = solutionInMemory;
      }
            if(worst == null){
                solutions.add(newSolution);
                solutionAccepted = true;
            }
      else if(newSolution.getCost() < worst.getCost() + threshold){
        solutions.remove(worst);
        solutions.add(newSolution);
        solutionAccepted = true;
      }
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    boolean solutionAccepted = false;
    if (solutions.size() < solutionMemory) {
      solutions.add(newSolution);
      solutionAccepted = true;
    } else {
      VehicleRoutingProblemSolution worst = null;
      double threshold = getThreshold(currentIteration);
      for(VehicleRoutingProblemSolution solutionInMemory : solutions){
        if(worst == null) worst = solutionInMemory;
        else if(solutionInMemory.getCost() > worst.getCost()) worst = solutionInMemory;
      }
      if(newSolution.getRoutes().size() < worst.getRoutes().size()){
        solutions.remove(worst);
        solutions.add(newSolution);
        solutionAccepted = true;
      }
      else if(newSolution.getRoutes().size() == worst.getRoutes().size() && newSolution.getCost() < worst.getCost() + threshold){
        solutions.remove(worst);
        solutions.add(newSolution);
        solutionAccepted = true;
      }
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    boolean solutionAccepted = false;
    if (solutions.size() < solutionMemory) {
      solutions.add(newSolution);
      solutionAccepted = true;
    } else {
      VehicleRoutingProblemSolution worstSolution = null;
      for (VehicleRoutingProblemSolution s : solutions) {
        if (worstSolution == null) worstSolution = s;
        else if (s.getCost() > worstSolution.getCost()) worstSolution = s;
      }
      if(newSolution.getCost() < worstSolution.getCost()){
        solutions.remove(worstSolution);
        solutions.add(newSolution);
        solutionAccepted = true;
      }
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    boolean solutionAccepted = false;
    if (solutions.size() < solutionMemory) {
      solutions.add(newSolution);
      solutionAccepted = true;
    } else {
      VehicleRoutingProblemSolution worstSolution = null;
      for (VehicleRoutingProblemSolution s : solutions) {
        if (worstSolution == null) worstSolution = s;
        else if (s.getRoutes().size() > worstSolution.getRoutes().size()) worstSolution = s;
      }
      if(newSolution.getRoutes().size() < worstSolution.getRoutes().size()){
        solutions.remove(worstSolution);
        solutions.add(newSolution);
        solutionAccepted = true;
      }
      else if(newSolution.getRoutes().size() == worstSolution.getRoutes().size() && newSolution.getCost() < worstSolution.getCost()){
        solutions.remove(worstSolution);
        solutions.add(newSolution);
        solutionAccepted = true;
      }
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

  }
 
  @Override
  public VehicleRoutingProblemSolution selectSolution(Collection<VehicleRoutingProblemSolution> solutions) {
    double minCost = Double.MAX_VALUE;
    VehicleRoutingProblemSolution bestSolution = null;
    for(VehicleRoutingProblemSolution sol : solutions){
      if(bestSolution == null){
        bestSolution = sol;
        minCost = sol.getCost();
      }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    return new AlgorithmStartsListener() {

      @Override
      public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) {
        InsertionInitialSolutionFactory insertionInitialSolutionFactory = new InsertionInitialSolutionFactory(finalInsertionStrategy, solutionCostCalculator);
        VehicleRoutingProblemSolution vrpSol = insertionInitialSolutionFactory.createSolution(vrp);
        solutions.add(vrpSol);
      }
    };

View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

                .addService(s1).addPickup(shipment1).addDelivery(shipment1).addService(s2).build();

        VehicleRoute route2 = VehicleRoute.Builder.newInstance(vehicle).setJobActivityFactory(vrp.getJobActivityFactory())
                .addService(s3).addPickup(shipment2).addDelivery(shipment2).addService(s4).build();

        solution = new VehicleRoutingProblemSolution(Arrays.asList(route1,route2),42);
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

                .addDelivery(s2)
                .addPickup(shipment1).addDelivery(shipment1)
                .addPickup(s1)
                .build();

        solution = new VehicleRoutingProblemSolution(Arrays.asList(route),300);
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

    /*
     * Retrieve best solution.
     */
    VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);

    /*
     * print solution
     */
    SolutionPrinter.print(vrp,solution, SolutionPrinter.Print.VERBOSE);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.