1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

migrated from log4j1x to log4j2

This commit is contained in:
oblonski 2014-07-26 22:56:01 +02:00
parent 8ebae73847
commit 11300b90d3
13 changed files with 93 additions and 134 deletions

View file

@ -18,6 +18,7 @@
******************************************************************************/
package jsprit.examples;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.GraphStreamViewer.Label;
import jsprit.analysis.toolbox.Plotter;
@ -27,6 +28,7 @@ import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
import jsprit.core.algorithm.state.StateManager;
import jsprit.core.algorithm.state.StateUpdater;
import jsprit.core.algorithm.termination.VariationCoefficientTermination;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.Builder;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
@ -108,8 +110,8 @@ public class BicycleMessenger {
public ConstraintsStatus fulfilled(JobInsertionContext iFacts,TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
//make sure vehicle can manage direct path
double arrTime_at_nextAct_onDirectRoute = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), nextAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
double latest_arrTime_at_nextAct = stateManager.getActivityState(nextAct, latest_act_arrival_time_stateId, Double.class);
Double latest_arrTime_at_nextAct = stateManager.getActivityState(nextAct, latest_act_arrival_time_stateId, Double.class);
if(latest_arrTime_at_nextAct == null) latest_arrTime_at_nextAct = nextAct.getTheoreticalLatestOperationStartTime();
if(arrTime_at_nextAct_onDirectRoute > latest_arrTime_at_nextAct){
//constraint can never be fulfilled anymore, thus .NOT_FULFILLED_BREAK
return ConstraintsStatus.NOT_FULFILLED_BREAK;
@ -274,10 +276,10 @@ public class BicycleMessenger {
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
algorithm.setNuOfIterations(2000);
// VariationCoefficientTermination prematureAlgorithmTermination = new VariationCoefficientTermination(200, 0.001);
// algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination);
// algorithm.addListener(prematureAlgorithmTermination);
// algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
VariationCoefficientTermination prematureAlgorithmTermination = new VariationCoefficientTermination(200, 0.001);
algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination);
algorithm.addListener(prematureAlgorithmTermination);
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
//search
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();

View file

@ -16,15 +16,8 @@
******************************************************************************/
package jsprit.examples;
import java.util.Arrays;
import java.util.Collection;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.*;
import jsprit.analysis.toolbox.SolutionPrinter.Print;
import jsprit.analysis.toolbox.StopWatch;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
@ -40,6 +33,9 @@ import jsprit.core.util.Coordinate;
import jsprit.core.util.Solutions;
import jsprit.util.Examples;
import java.util.Arrays;
import java.util.Collection;
public class MultipleDepotExampleWithPenaltyVehicles {
@ -111,7 +107,8 @@ public class MultipleDepotExampleWithPenaltyVehicles {
* solve the problem
*/
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
vra.setNuOfIterations(5000);
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -16,8 +16,6 @@
******************************************************************************/
package jsprit.examples;
import java.util.Collection;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.Plotter;
@ -31,16 +29,13 @@ import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.util.Examples;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import java.util.Collection;
public class PickupAndDeliveryExample2 {
public static void main(String[] args) {
Logger.getRootLogger().setLevel(Level.INFO);
/*
* some preparation - create output folder
*/