mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
cleaned up project, i.e. deleted redundant files
This commit is contained in:
parent
0e851b4802
commit
64ed26e12e
8 changed files with 0 additions and 1640 deletions
|
|
@ -1,54 +0,0 @@
|
|||
///*******************************************************************************
|
||||
// * Copyright (C) 2013 Stefan Schroeder
|
||||
// *
|
||||
// * This library is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU Lesser General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 3.0 of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This library is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// * Lesser General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public
|
||||
// * License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
// ******************************************************************************/
|
||||
//package jsprit.core.algorithm;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collection;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import jsprit.core.algorithm.recreate.listener.InsertionStartsListener;
|
||||
//import jsprit.core.problem.job.Job;
|
||||
//import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
//
|
||||
//
|
||||
//class FindCheaperVehicle implements InsertionStartsListener{
|
||||
//
|
||||
// FindCheaperVehicleAlgo findCheaperVehicle;
|
||||
//
|
||||
// public FindCheaperVehicle(FindCheaperVehicleAlgo findCheaperVehicle) {
|
||||
// super();
|
||||
// this.findCheaperVehicle = findCheaperVehicle;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) {
|
||||
// List<VehicleRoute> newRoutes = new ArrayList<VehicleRoute>();
|
||||
// for(VehicleRoute route : vehicleRoutes){
|
||||
// if(route.isEmpty()) continue;
|
||||
// VehicleRoute cheaperRoute = findCheaperVehicle.runAndGetVehicleRoute(route);
|
||||
// newRoutes.add(cheaperRoute);
|
||||
// }
|
||||
// vehicleRoutes.clear();
|
||||
// vehicleRoutes.addAll(newRoutes);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "[name=findCheaperVehicle]";
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
///*******************************************************************************
|
||||
// * Copyright (C) 2013 Stefan Schroeder
|
||||
// *
|
||||
// * This library is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU Lesser General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 3.0 of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This library is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// * Lesser General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public
|
||||
// * License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
// ******************************************************************************/
|
||||
//package jsprit.core.algorithm;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import jsprit.core.algorithm.recreate.AuxilliaryCostCalculator;
|
||||
//import jsprit.core.algorithm.state.StateFactory;
|
||||
//import jsprit.core.algorithm.state.StateGetter;
|
||||
//import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
//import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
//import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
//import jsprit.core.problem.vehicle.Vehicle;
|
||||
//import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
//import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
|
||||
//
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//final class FindCheaperVehicleAlgo {
|
||||
//
|
||||
// private static Logger log = Logger.getLogger(FindCheaperVehicleAlgo.class);
|
||||
//
|
||||
// private VehicleFleetManager fleetManager;
|
||||
//
|
||||
// private VehicleRouteUpdater tourStateCalculator;
|
||||
//
|
||||
// private AuxilliaryCostCalculator auxilliaryCostCalculator;
|
||||
//
|
||||
// private double weightFixCosts = 1.0;
|
||||
//
|
||||
// private StateGetter states;
|
||||
//
|
||||
// public void setWeightFixCosts(double weightFixCosts) {
|
||||
// this.weightFixCosts = weightFixCosts;
|
||||
// }
|
||||
//
|
||||
// public void setStates(StateGetter states) {
|
||||
// this.states = states;
|
||||
// }
|
||||
//
|
||||
// public FindCheaperVehicleAlgo(VehicleFleetManager fleetManager, VehicleRouteUpdater tourStateCalculator, AuxilliaryCostCalculator auxilliaryCostCalculator) {
|
||||
// super();
|
||||
// this.fleetManager = fleetManager;
|
||||
// this.tourStateCalculator = tourStateCalculator;
|
||||
// this.auxilliaryCostCalculator = auxilliaryCostCalculator;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public VehicleRoute runAndGetVehicleRoute(VehicleRoute vehicleRoute) {
|
||||
// if(vehicleRoute.getVehicle() instanceof NoVehicle){
|
||||
// return vehicleRoute;
|
||||
// }
|
||||
// if(vehicleRoute.getTourActivities() == null || vehicleRoute.getVehicle() == null){
|
||||
// return vehicleRoute;
|
||||
// }
|
||||
//// Collection<TypeKey> availableVehicleTypes = fleetManager.getAvailableVehicleTypes(new TypeKey(vehicleRoute.getVehicle().getType(),vehicleRoute.getVehicle().getLocationId()));
|
||||
// double bestSaving = 0.0;
|
||||
// Vehicle bestVehicle = null;
|
||||
// List<TourActivity> path = new ArrayList<TourActivity>();
|
||||
// path.add(vehicleRoute.getStart());
|
||||
// path.addAll(vehicleRoute.getTourActivities().getActivities());
|
||||
// path.add(vehicleRoute.getEnd());
|
||||
//
|
||||
// for(Vehicle vehicle : fleetManager.getAvailableVehicles(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
|
||||
//// Vehicle vehicle = fleetManager.getEmptyVehicle(vehicleType);
|
||||
// if(vehicle.getType().getTypeId().equals(vehicleRoute.getVehicle().getType().getTypeId())){
|
||||
// continue;
|
||||
// }
|
||||
// if(states.getRouteState(vehicleRoute,StateFactory.LOAD).toDouble() <= vehicle.getCapacity()){
|
||||
// double fixCostSaving = vehicleRoute.getVehicle().getType().getVehicleCostParams().fix - vehicle.getType().getVehicleCostParams().fix;
|
||||
// double departureTime = vehicleRoute.getStart().getEndTime();
|
||||
// double newCost = auxilliaryCostCalculator.costOfPath(path, departureTime, vehicleRoute.getDriver(), vehicle);
|
||||
// double varCostSaving = states.getRouteState(vehicleRoute, StateFactory.COSTS).toDouble() - newCost;
|
||||
// double totalCostSaving = varCostSaving + weightFixCosts*fixCostSaving;
|
||||
// if(totalCostSaving > bestSaving){
|
||||
// bestSaving = totalCostSaving;
|
||||
// bestVehicle = vehicle;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(bestVehicle != null){
|
||||
// try{
|
||||
// fleetManager.unlock(vehicleRoute.getVehicle());
|
||||
// fleetManager.lock(bestVehicle);
|
||||
// }
|
||||
// catch(IllegalStateException e){
|
||||
// throw new IllegalStateException(e);
|
||||
// }
|
||||
// TourActivities newTour = TourActivities.copyOf(vehicleRoute.getTourActivities());
|
||||
// tourStateCalculator.iterate(vehicleRoute);
|
||||
// return VehicleRoute.newInstance(newTour,vehicleRoute.getDriver(),bestVehicle);
|
||||
// }
|
||||
// return vehicleRoute;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
@ -1,224 +0,0 @@
|
|||
///*******************************************************************************
|
||||
// * Copyright (C) 2013 Stefan Schroeder
|
||||
// *
|
||||
// * This library is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU Lesser General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 3.0 of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This library is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// * Lesser General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public
|
||||
// * License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
// ******************************************************************************/
|
||||
//package jsprit.core.algorithm.module;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Collection;
|
||||
//import java.util.Collections;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import jsprit.core.algorithm.SearchStrategyModule;
|
||||
//import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
|
||||
//import jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
//import jsprit.core.algorithm.recreate.listener.InsertionListener;
|
||||
//import jsprit.core.algorithm.recreate.listener.InsertionListeners;
|
||||
//import jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
//import jsprit.core.algorithm.ruin.listener.RuinListener;
|
||||
//import jsprit.core.problem.Job;
|
||||
//import jsprit.core.problem.VehicleRoutingProblem;
|
||||
//import jsprit.core.problem.VehicleRoutingProblemSolution;
|
||||
//import jsprit.core.problem.route.TourActivity;
|
||||
//import jsprit.core.problem.route.TourActivity.JobActivity;
|
||||
//import jsprit.core.problem.route.VehicleFleetManager;
|
||||
//import jsprit.core.problem.route.VehicleRoute;
|
||||
//import jsprit.core.util.RandomNumberGeneration;
|
||||
//
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
//
|
||||
//final class Gendreau implements SearchStrategyModule{
|
||||
//
|
||||
// private final static Logger log = Logger.getLogger(Gendreau.class);
|
||||
//
|
||||
// private final static String NAME = "gendreauPostOpt";
|
||||
//
|
||||
// private final RuinStrategy ruin;
|
||||
//
|
||||
// private final VehicleRoutingProblem vrp;
|
||||
//
|
||||
// private final InsertionStrategy insertionStrategy;
|
||||
//
|
||||
// private VehicleFleetManager fleetManager;
|
||||
//
|
||||
// private Random random = RandomNumberGeneration.getRandom();
|
||||
//
|
||||
// private int nOfIterations = 10;
|
||||
//
|
||||
// private double shareOfJobsToRuin = 0.15;
|
||||
//
|
||||
// public void setShareOfJobsToRuin(double shareOfJobsToRuin) {
|
||||
// this.shareOfJobsToRuin = shareOfJobsToRuin;
|
||||
// }
|
||||
//
|
||||
// public Gendreau(VehicleRoutingProblem vrp, RuinStrategy ruin, InsertionStrategy insertionStrategy, VehicleFleetManager vehicleFleetManager) {
|
||||
// super();
|
||||
// InsertionListeners insertionListeners = new InsertionListeners();
|
||||
// insertionListeners.addAllListeners(insertionStrategy.getListeners());
|
||||
// new Inserter(insertionListeners);
|
||||
// this.ruin = ruin;
|
||||
// this.vrp = vrp;
|
||||
// this.insertionStrategy = insertionStrategy;
|
||||
// this.fleetManager = vehicleFleetManager;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "[name=gendreau][iterations="+nOfIterations+"][share2ruin="+shareOfJobsToRuin+"]";
|
||||
// }
|
||||
//
|
||||
// public void setRandom(Random random) {
|
||||
// this.random = random;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public void setNuOfIterations(int nOfIterations) {
|
||||
// this.nOfIterations = nOfIterations;
|
||||
// }
|
||||
//
|
||||
//// public void setFleetManager(VehicleFleetManager vehicleFleetManager) {
|
||||
//// this.fleetManager = vehicleFleetManager;
|
||||
////
|
||||
//// }
|
||||
//
|
||||
// @Override
|
||||
// public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
|
||||
//// log.info("run gendreau postopt");
|
||||
// VehicleRoutingProblemSolution bestSolution = vrpSolution;
|
||||
// int itersWithoutImprovement = 0;
|
||||
//
|
||||
// for(int i=0;i<nOfIterations;i++){
|
||||
// List<VehicleRoute> copiedRoutes = copyRoutes(bestSolution.getRoutes());
|
||||
// iniFleet(copiedRoutes);
|
||||
//
|
||||
// VehicleRoute route2split = pickRouteThatHasAtLeastTwoJobs(copiedRoutes);
|
||||
// if(route2split == null) continue;
|
||||
// List<Job> jobsInRoute = getJobs(route2split);
|
||||
// Set<Job> unassignedJobs = new HashSet<Job>();
|
||||
// unassignedJobs.addAll(jobsInRoute);
|
||||
// copiedRoutes.remove(route2split);
|
||||
//
|
||||
// Collections.shuffle(jobsInRoute,random);
|
||||
// Job targetJob = jobsInRoute.get(0);
|
||||
// int nOfJobs2BeRemovedAdditionally = (int) (shareOfJobsToRuin*(double)vrp.getJobs().size());
|
||||
// Collection<Job> unassignedJobsList = ruin.ruin(copiedRoutes, targetJob, nOfJobs2BeRemovedAdditionally);
|
||||
// unassignedJobs.addAll(unassignedJobsList);
|
||||
//
|
||||
// VehicleRoute emptyRoute1 = VehicleRoute.emptyRoute();
|
||||
// copiedRoutes.add(emptyRoute1);
|
||||
// insertionStrategy.insertJobs(Arrays.asList(emptyRoute1), Arrays.asList(targetJob));
|
||||
//
|
||||
// unassignedJobs.remove(targetJob);
|
||||
//
|
||||
// VehicleRoute emptyRoute2 = VehicleRoute.emptyRoute();
|
||||
// copiedRoutes.add(emptyRoute2);
|
||||
// Job job2 = jobsInRoute.get(1);
|
||||
// insertionStrategy.insertJobs(Arrays.asList(emptyRoute2), Arrays.asList(job2));
|
||||
//
|
||||
// unassignedJobs.remove(job2);
|
||||
//
|
||||
// insertionStrategy.insertJobs(copiedRoutes, unassignedJobs);
|
||||
// double cost = getCost(copiedRoutes);
|
||||
//
|
||||
// if(cost < bestSolution.getCost()){
|
||||
//// log.info("BING - new: " + cost + " old: " + bestSolution.getCost());
|
||||
// bestSolution = new VehicleRoutingProblemSolution(copiedRoutes, cost);
|
||||
// itersWithoutImprovement=0;
|
||||
// }
|
||||
// else{
|
||||
// itersWithoutImprovement++;
|
||||
// if(itersWithoutImprovement > 200){
|
||||
//// log.info("BREAK i="+i);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return bestSolution;
|
||||
// }
|
||||
//
|
||||
// private List<VehicleRoute> copyRoutes(Collection<VehicleRoute> routes) {
|
||||
// List<VehicleRoute> routeList = new ArrayList<VehicleRoute>();
|
||||
// for(VehicleRoute r : routes){
|
||||
// routeList.add(VehicleRoute.copyOf(r));
|
||||
// }
|
||||
// return routeList;
|
||||
// }
|
||||
//
|
||||
// private void iniFleet(Collection<VehicleRoute> routes) {
|
||||
// fleetManager.unlockAll();
|
||||
// for(VehicleRoute route : routes){
|
||||
// if(!route.isEmpty()){
|
||||
// fleetManager.lock(route.getVehicle());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private double getCost(Collection<VehicleRoute> routes) {
|
||||
// double c = 0.0;
|
||||
// for(VehicleRoute r : routes){
|
||||
// c+=r.getCost();
|
||||
// }
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// private List<Job> getJobs(VehicleRoute route2split) {
|
||||
// Set<Job> jobs = new HashSet<Job>();
|
||||
// for(TourActivity act : route2split.getTourActivities().getActivities()){
|
||||
// if(act instanceof JobActivity){
|
||||
// jobs.add(((JobActivity) act).getJob());
|
||||
// }
|
||||
// }
|
||||
// return new ArrayList<Job>(jobs);
|
||||
// }
|
||||
//
|
||||
// private VehicleRoute pickRouteThatHasAtLeastTwoJobs(Collection<VehicleRoute> routeList) {
|
||||
// List<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
// for(VehicleRoute r : routeList){
|
||||
// if(getJobs(r).size() > 1){
|
||||
// routes.add(r);
|
||||
// }
|
||||
// }
|
||||
// if(routes.isEmpty()) return null;
|
||||
// Collections.shuffle(routes,random);
|
||||
// return routes.get(0);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getName() {
|
||||
// return NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addModuleListener(SearchStrategyModuleListener moduleListener) {
|
||||
// if(moduleListener instanceof InsertionListener){
|
||||
// InsertionListener iListener = (InsertionListener) moduleListener;
|
||||
// if(!insertionStrategy.getListeners().contains(iListener)){
|
||||
// insertionStrategy.addListener(iListener);
|
||||
// }
|
||||
// }
|
||||
// if(moduleListener instanceof RuinListener){
|
||||
// RuinListener rListener = (RuinListener) moduleListener;
|
||||
// if(!ruin.getListeners().contains(rListener)){
|
||||
// ruin.addListener(rListener);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
package jsprit.core.algorithm.recreate;
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
///*******************************************************************************
|
||||
// * Copyright (c) 2011 Stefan Schroeder.
|
||||
// * eMail: stefan.schroeder@kit.edu
|
||||
// *
|
||||
// * All rights reserved. This program and the accompanying materials
|
||||
// * are made available under the terms of the GNU Public License v2.0
|
||||
// * which accompanies this distribution, and is available at
|
||||
// * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
// *
|
||||
// * Contributors:
|
||||
// * Stefan Schroeder - initial API and implementation
|
||||
// ******************************************************************************/
|
||||
//package algorithms;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collection;
|
||||
//import java.util.List;
|
||||
//import java.util.concurrent.Callable;
|
||||
//import java.util.concurrent.CompletionService;
|
||||
//import java.util.concurrent.ExecutionException;
|
||||
//import java.util.concurrent.ExecutorCompletionService;
|
||||
//import java.util.concurrent.ExecutorService;
|
||||
//import java.util.concurrent.Future;
|
||||
//
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
//import basics.InsertionData;
|
||||
//import basics.Job;
|
||||
//import basics.Service;
|
||||
//import basics.Shipment;
|
||||
//import basics.VehicleRoute;
|
||||
//import basics.InsertionData.NoInsertionFound;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Simplest recreation strategy. All removed customers are inserted where insertion costs are minimal. I.e. each tour-agent is asked for
|
||||
// * minimal marginal insertion costs. The tour-agent offering the lowest marginal insertion costs gets the customer/shipment.
|
||||
// *
|
||||
// * @author stefan schroeder
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//final class ParRegretInsertion extends AbstractRecreationStrategy{
|
||||
//
|
||||
//
|
||||
// private Logger logger = Logger.getLogger(ParRegretInsertion.class);
|
||||
//
|
||||
//
|
||||
// public static double scoreParam_of_timeWindowLegth = 0.0;
|
||||
//
|
||||
// private ExecutorService executor;
|
||||
//
|
||||
// public static double scoreParam_of_distance = 0.5;
|
||||
//
|
||||
// private DepotDistance depotDistance;
|
||||
//
|
||||
// private RouteAlgorithm routeAlgorithm;
|
||||
//
|
||||
// private VehicleRouteFactory vehicleRouteFactory;
|
||||
//
|
||||
// public ParRegretInsertion(ExecutorService executor, RouteAlgorithm routeAlgorithm, VehicleRouteFactory routeFactory, DepotDistance depotDistance) {
|
||||
// super();
|
||||
// this.executor = executor;
|
||||
// this.routeAlgorithm = routeAlgorithm;
|
||||
// this.depotDistance = depotDistance;
|
||||
// this.vehicleRouteFactory = routeFactory;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void recreate(final Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs, double result2beat) {
|
||||
// List<Job> jobs = new ArrayList<Job>(unassignedJobs);
|
||||
// informRecreationStart(unassignedJobs.size());
|
||||
//
|
||||
// while(!jobs.isEmpty()){
|
||||
// List<Job> unassignedJobList = new ArrayList<Job>(jobs);
|
||||
// ScoredJob bestScoredJob = null;
|
||||
// double bestScore = -1*Double.MAX_VALUE;
|
||||
// CompletionService<ScoredJob> completionService = new ExecutorCompletionService<ScoredJob>(executor);
|
||||
//
|
||||
// for(final Job unassignedJob : unassignedJobList){
|
||||
// completionService.submit(new Callable<ScoredJob>(){
|
||||
//
|
||||
// @Override
|
||||
// public ScoredJob call() throws Exception {
|
||||
// return getScoredJob(vehicleRoutes, unassignedJob);
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// try{
|
||||
// for(int i=0;i<unassignedJobList.size();i++){
|
||||
// Future<ScoredJob> fsj = completionService.take();
|
||||
// ScoredJob scoredJob = fsj.get();
|
||||
// if(scoredJob == null){
|
||||
// continue;
|
||||
// }
|
||||
// if(scoredJob.getScore() > bestScore){
|
||||
// bestScoredJob = scoredJob;
|
||||
// bestScore = scoredJob.getScore();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch(InterruptedException e){
|
||||
// Thread.currentThread().interrupt();
|
||||
// }
|
||||
// catch (ExecutionException e) {
|
||||
// e.printStackTrace();
|
||||
// logger.error(e.getCause().toString());
|
||||
// System.exit(1);
|
||||
// }
|
||||
// if(bestScoredJob == null){
|
||||
// Job job = unassignedJobList.get(0);
|
||||
// VehicleRoute newRoute = vehicleRouteFactory.createVehicleRoute();
|
||||
// InsertionData bestI = routeAlgorithm.calculateBestInsertion(newRoute, job, Double.MAX_VALUE);
|
||||
// if(bestI instanceof InsertionData.NoInsertionFound) throw new IllegalStateException("given the vehicles, could not create a valid solution");
|
||||
// routeAlgorithm.insertJob(job,bestI,newRoute);
|
||||
// vehicleRoutes.add(newRoute);
|
||||
// jobs.remove(job);
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// routeAlgorithm.insertJob(bestScoredJob.getJob(),bestScoredJob.getInsertionData(),bestScoredJob.getRoute());
|
||||
// jobs.remove(bestScoredJob.getJob());
|
||||
// }
|
||||
// informJobInsertion(null, (unassignedJobList.size()-1), null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private ScoredJob getScoredJob(Collection<VehicleRoute> vehicleRoutes, Job job){
|
||||
// InsertionData best = null;
|
||||
// InsertionData secondBest = null;
|
||||
// VehicleRoute bestRoute = null;
|
||||
// double benchmark = Double.MAX_VALUE;
|
||||
// for(VehicleRoute route : vehicleRoutes){
|
||||
// if(secondBest != null){
|
||||
// benchmark = secondBest.getInsertionCost();
|
||||
// }
|
||||
// InsertionData iData = routeAlgorithm.calculateBestInsertion(route, job, benchmark);
|
||||
// if(iData instanceof NoInsertionFound) continue;
|
||||
// if(best == null) {
|
||||
// best = iData;
|
||||
// bestRoute = route;
|
||||
// }
|
||||
// else if(iData.getInsertionCost() < best.getInsertionCost()){
|
||||
// secondBest = best;
|
||||
// best = iData;
|
||||
// bestRoute = route;
|
||||
// }
|
||||
// else if(secondBest == null) secondBest = iData;
|
||||
// else if(iData.getInsertionCost() < secondBest.getInsertionCost()) secondBest = iData;
|
||||
// }
|
||||
// if(best == null){
|
||||
// return null;
|
||||
// }
|
||||
// double score = score(job,best,secondBest);
|
||||
// return new ScoredJob(job, score, best, bestRoute);
|
||||
// }
|
||||
//
|
||||
// private double score(Job unassignedJob, InsertionData best, InsertionData secondBest) {
|
||||
// /*
|
||||
// * wieder so eine bescheuerte fallunterscheidung. hier will ich
|
||||
// * doch einfach nur das maßgebende zeitfenster des jobs
|
||||
// * job.getTimeWindow()
|
||||
// * Problem: eine Shipment hat zwei TWs, sowohl ein PickupTW als auch
|
||||
// * ein DeliveryTW
|
||||
// */
|
||||
// double twStart = 0.0;
|
||||
// double twEnd = 0.0;
|
||||
// if(unassignedJob instanceof Shipment){
|
||||
// twStart = ((Shipment) unassignedJob).getDeliveryTW().getStart();
|
||||
// twEnd = ((Shipment) unassignedJob).getDeliveryTW().getEnd();
|
||||
// }
|
||||
// else if(unassignedJob instanceof Service){
|
||||
// twStart = ((Service) unassignedJob).getTimeWindow().getStart();
|
||||
// twEnd = ((Service) unassignedJob).getTimeWindow().getEnd();
|
||||
// }
|
||||
// if(best == null){
|
||||
// throw new IllegalStateException("cannot insert job " + unassignedJob.getId());
|
||||
// }
|
||||
// if(secondBest == null){
|
||||
// return Double.MAX_VALUE;
|
||||
// }
|
||||
//// double score = (secondBest.getInsertionCost()-best.getInsertionCost()) + scoreParam_of_distance*getDistance(unassignedJob) - scoreParam_of_timeWindowLegth*(twEnd-twStart);
|
||||
//// logger.info("priceDiff="+ (secondBest.getPrice()-best.getPrice()) + "; param*dist="
|
||||
// double timeWindowInfluence = scoreParam_of_timeWindowLegth*(twEnd-twStart);
|
||||
// double distanceInfluence = scoreParam_of_distance*getDistance(unassignedJob);
|
||||
// double score = (secondBest.getInsertionCost()-best.getInsertionCost()) - timeWindowInfluence
|
||||
// + distanceInfluence;
|
||||
// return score;
|
||||
// }
|
||||
//
|
||||
// private double getDistance(Job unassignedJob) {
|
||||
// return depotDistance.calcDistance(unassignedJob);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public double getTimeParam() {
|
||||
// return scoreParam_of_timeWindowLegth;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
|
@ -1,246 +0,0 @@
|
|||
package jsprit.core.algorithm.recreate;
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
///*******************************************************************************
|
||||
// * Copyright (c) 2011 Stefan Schroeder.
|
||||
// * eMail: stefan.schroeder@kit.edu
|
||||
// *
|
||||
// * All rights reserved. This program and the accompanying materials
|
||||
// * are made available under the terms of the GNU Public License v2.0
|
||||
// * which accompanies this distribution, and is available at
|
||||
// * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
// *
|
||||
// * Contributors:
|
||||
// * Stefan Schroeder - initial API and implementation
|
||||
// ******************************************************************************/
|
||||
//package algorithms;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collection;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
//import algorithms.InsertionData.NoInsertionFound;
|
||||
//import basics.Job;
|
||||
//import basics.Service;
|
||||
//import basics.algo.InsertionListener;
|
||||
//import basics.route.VehicleRoute;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Insertion based an regret approach.
|
||||
// *
|
||||
// * <p>Basically calculates the insertion cost of the firstBest and the secondBest alternative. The score is then calculated as difference
|
||||
// * between secondBest and firstBest, plus additional scoring variables that can defined in this.ScoringFunction.
|
||||
// * The idea is that if the cost of the secondBest alternative is way higher than the first best, it seems to be important to insert this
|
||||
// * customer immediatedly. If difference is not that high, it might not impact solution if this customer is inserted later.
|
||||
// *
|
||||
// * @author stefan schroeder
|
||||
// *
|
||||
// */
|
||||
//final class RegretInsertion implements InsertionStrategy{
|
||||
//
|
||||
// /**
|
||||
// * Scorer to include other impacts on score such as time-window length or distance to depot.
|
||||
// *
|
||||
// * @author schroeder
|
||||
// *
|
||||
// */
|
||||
// static interface ScoringFunction {
|
||||
//
|
||||
// public double score(Job job);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Scorer that includes the length of the time-window when scoring a job. The wider the time-window, the lower the score.
|
||||
// *
|
||||
// * <p>This is the default scorer, i.e.: score = (secondBest - firstBest) + this.TimeWindowScorer.score(job)
|
||||
// *
|
||||
// * @author schroeder
|
||||
// *
|
||||
// */
|
||||
// static class TimeWindowScorer implements ScoringFunction {
|
||||
//
|
||||
// private double tw_scoringParam = - 0.1;
|
||||
//
|
||||
// @Override
|
||||
// public double score(Job job) {
|
||||
// double twStart = 0.0;
|
||||
// double twEnd = 0.0;
|
||||
//// if(job instanceof Shipment){
|
||||
//// twStart = ((Shipment) job).getDeliveryTW().getStart();
|
||||
//// twEnd = ((Shipment) job).getDeliveryTW().getEnd();
|
||||
//// }
|
||||
//// else
|
||||
// if(job instanceof Service){
|
||||
// twStart = ((Service) job).getTimeWindow().getStart();
|
||||
// twEnd = ((Service) job).getTimeWindow().getEnd();
|
||||
// }
|
||||
// return (twEnd-twStart)*tw_scoringParam;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "[name=timeWindowScorer][scoringParam="+tw_scoringParam+"]";
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static RegretInsertion newInstance(RouteAlgorithm routeAlgorithm) {
|
||||
// return new RegretInsertion(routeAlgorithm);
|
||||
// }
|
||||
//
|
||||
// private Logger logger = Logger.getLogger(RegretInsertion.class);
|
||||
//
|
||||
// private RouteAlgorithm routeAlgorithm;
|
||||
//
|
||||
// private ScoringFunction scoringFunction = new TimeWindowScorer();
|
||||
//
|
||||
// /**
|
||||
// * Sets the scoring function.
|
||||
// *
|
||||
// * <p>By default, the this.TimeWindowScorer is used.
|
||||
// *
|
||||
// * @param scoringFunction
|
||||
// */
|
||||
// public void setScoringFunction(ScoringFunction scoringFunction) {
|
||||
// this.scoringFunction = scoringFunction;
|
||||
// }
|
||||
//
|
||||
// public RegretInsertion(RouteAlgorithm routeAlgorithm) {
|
||||
// super();
|
||||
// this.routeAlgorithm = routeAlgorithm;
|
||||
// logger.info("initialise " + this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "[name=regretInsertion][additionalScorer="+scoringFunction+"]";
|
||||
// }
|
||||
//
|
||||
// public RouteAlgorithm getRouteAlgorithm(){
|
||||
// return routeAlgorithm;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Runs insertion.
|
||||
// *
|
||||
// * <p>Before inserting a job, all unassigned jobs are scored according to its best- and secondBest-insertion plus additional scoring variables.
|
||||
// *
|
||||
// */
|
||||
// @Override
|
||||
// public void insertJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
||||
// List<Job> jobs = new ArrayList<Job>(unassignedJobs);
|
||||
//// informInsertionStarts(routes,unassignedJobs);
|
||||
// int inserted = 0;
|
||||
// while(!jobs.isEmpty()){
|
||||
// List<Job> unassignedJobList = new ArrayList<Job>(jobs);
|
||||
// ScoredJob bestScoredJob = null;
|
||||
// double bestScore = -1*Double.MAX_VALUE;
|
||||
// VehicleRoute insertIn = null;
|
||||
//
|
||||
// for(Job unassignedJob : unassignedJobList){
|
||||
// InsertionData best = null;
|
||||
// InsertionData secondBest = null;
|
||||
// VehicleRoute bestRoute = null;
|
||||
//
|
||||
// double benchmark = Double.MAX_VALUE;
|
||||
// for(VehicleRoute route : routes){
|
||||
// if(secondBest != null){
|
||||
// benchmark = secondBest.getInsertionCost();
|
||||
// }
|
||||
// InsertionData iData = routeAlgorithm.calculateBestInsertion(route, unassignedJob, benchmark);
|
||||
// if(iData instanceof NoInsertionFound) continue;
|
||||
// if(best == null){
|
||||
// best = iData;
|
||||
// bestRoute = route;
|
||||
// }
|
||||
// else if(iData.getInsertionCost() < best.getInsertionCost()){
|
||||
// secondBest = best;
|
||||
// best = iData;
|
||||
// bestRoute = route;
|
||||
// }
|
||||
// else if(secondBest == null || (iData.getInsertionCost() < secondBest.getInsertionCost())){
|
||||
// secondBest = iData;
|
||||
// }
|
||||
// }
|
||||
// if(best == null){
|
||||
// break;
|
||||
// }
|
||||
// double score = score(unassignedJob,best,secondBest);
|
||||
// if(score > bestScore){
|
||||
// bestScoredJob = new ScoredJob(unassignedJob,score,best,bestRoute);
|
||||
// bestScore = score;
|
||||
// }
|
||||
// }
|
||||
// Job assignedJob;
|
||||
// if(bestScoredJob == null){
|
||||
// Job job = unassignedJobList.get(0);
|
||||
// VehicleRoute newRoute = VehicleRoute.emptyRoute();
|
||||
// InsertionData bestI = routeAlgorithm.calculateBestInsertion(newRoute, job, Double.MAX_VALUE);
|
||||
// if(bestI instanceof InsertionData.NoInsertionFound) throw new IllegalStateException("given the vehicles, could not create a valid solution");
|
||||
// insertIn=newRoute;
|
||||
// assignedJob=job;
|
||||
// routeAlgorithm.insertJob(job,bestI,newRoute);
|
||||
// routes.add(newRoute);
|
||||
// jobs.remove(job);
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// routeAlgorithm.insertJob(bestScoredJob.getJob(),bestScoredJob.getInsertionData(), bestScoredJob.getRoute());
|
||||
// insertIn=bestScoredJob.getRoute();
|
||||
// assignedJob=bestScoredJob.getJob();
|
||||
// jobs.remove(bestScoredJob.getJob());
|
||||
// }
|
||||
// inserted++;
|
||||
//// informJobInserted(assignedJob, insertIn);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private double score(Job unassignedJob, InsertionData best, InsertionData secondBest) {
|
||||
// if(best == null){
|
||||
// throw new IllegalStateException("cannot insert job " + unassignedJob.getId());
|
||||
// }
|
||||
// if(secondBest == null){
|
||||
// return Double.MAX_VALUE;
|
||||
// }
|
||||
// return (secondBest.getInsertionCost()-best.getInsertionCost()) + scoringFunction.score(unassignedJob);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void removeListener(InsertionListener insertionListener) {
|
||||
// // TODO Auto-generated method stub
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Collection<InsertionListener> getListeners() {
|
||||
// // TODO Auto-generated method stub
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addListener(InsertionListener insertionListener) {
|
||||
// // TODO Auto-generated method stub
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
Loading…
Add table
Add a link
Reference in a new issue