From 800e03d48cd87cbb79d4b81af76f842bb5e9ed5d Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Wed, 17 Sep 2014 20:13:08 +0200 Subject: [PATCH] reproduce bug #131 --- .../algorithm/DeactivateTimeWindowsTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 jsprit-core/src/test/java/jsprit/core/algorithm/DeactivateTimeWindowsTest.java diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/DeactivateTimeWindowsTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/DeactivateTimeWindowsTest.java new file mode 100644 index 00000000..fca624d7 --- /dev/null +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/DeactivateTimeWindowsTest.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (C) 2014 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 . + ******************************************************************************/ + +package jsprit.core.algorithm; + + +import jsprit.core.problem.VehicleRoutingProblem; +import jsprit.core.problem.job.Service; +import jsprit.core.problem.solution.VehicleRoutingProblemSolution; +import jsprit.core.problem.solution.route.VehicleRoute; +import jsprit.core.problem.solution.route.activity.TimeWindow; +import jsprit.core.problem.vehicle.VehicleImpl; +import jsprit.core.util.Coordinate; +import jsprit.core.util.Solutions; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Collection; + +public class DeactivateTimeWindowsTest { + + @Test + public void activityTimesShouldIgnoreTimeWindows(){ + Service service = Service.Builder.newInstance("s").setCoord(Coordinate.newInstance(20, 0)) + .setTimeWindow(TimeWindow.newInstance(40,50)).build(); + VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(0,0)).build(); + VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addVehicle(vehicle).build(); + VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp,"src/test/resources/algorithmConfig.xml"); + vraBuilder.addDefaultCostCalculators(); + VehicleRoutingAlgorithm vra = vraBuilder.build(); //this should ignore any constraints + vra.setMaxIterations(10); + Collection solutions = vra.searchSolutions(); + + VehicleRoute route = Solutions.bestOf(solutions).getRoutes().iterator().next(); + Assert.assertEquals(20., route.getActivities().get(0).getEndTime(), 0.01); + } +}