mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
rename badJob into unassignedJob
This commit is contained in:
parent
650a20fabc
commit
b7b0ff650c
6 changed files with 25 additions and 23 deletions
|
|
@ -93,7 +93,7 @@ public class SolutionPrinter {
|
||||||
System.out.format("+---------------+------------------------------------------+%n");
|
System.out.format("+---------------+------------------------------------------+%n");
|
||||||
System.out.format(leftAlignSolution, "costs",solution.getCost());
|
System.out.format(leftAlignSolution, "costs",solution.getCost());
|
||||||
System.out.format(leftAlignSolution, "nVehicles",solution.getRoutes().size());
|
System.out.format(leftAlignSolution, "nVehicles",solution.getRoutes().size());
|
||||||
System.out.format(leftAlignSolution, "badJobs", solution.getBadJobs().size());
|
System.out.format(leftAlignSolution, "badJobs", solution.getUnassignedJobs().size());
|
||||||
System.out.format("+----------------------------------------------------------+%n");
|
System.out.format("+----------------------------------------------------------+%n");
|
||||||
|
|
||||||
if(print.equals(Print.VERBOSE)){
|
if(print.equals(Print.VERBOSE)){
|
||||||
|
|
@ -132,7 +132,7 @@ public class SolutionPrinter {
|
||||||
System.out.format("+*:=PenaltyVehicle+%n");
|
System.out.format("+*:=PenaltyVehicle+%n");
|
||||||
System.out.format("+--------------------------------------------------------------------------------------------------------------------------------+%n");
|
System.out.format("+--------------------------------------------------------------------------------------------------------------------------------+%n");
|
||||||
System.out.format("+*:=badJobs+%n");
|
System.out.format("+*:=badJobs+%n");
|
||||||
for(Job j : solution.getBadJobs()){
|
for(Job j : solution.getUnassignedJobs()){
|
||||||
System.out.println(j.getId());
|
System.out.println(j.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class VariablePlusFixedSolutionCostCalculatorFactory {
|
||||||
c += stateManager.getRouteState(r, InternalStates.COSTS, Double.class);
|
c += stateManager.getRouteState(r, InternalStates.COSTS, Double.class);
|
||||||
c += getFixedCosts(r.getVehicle());
|
c += getFixedCosts(r.getVehicle());
|
||||||
}
|
}
|
||||||
c += solution.getBadJobs().size() * c * .1;
|
c += solution.getUnassignedJobs().size() * c * .1;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ public class RuinAndRecreateModule implements SearchStrategyModule{
|
||||||
Collection<Job> ruinedJobs = ruin.ruin(vrpSolution.getRoutes());
|
Collection<Job> ruinedJobs = ruin.ruin(vrpSolution.getRoutes());
|
||||||
Set<Job> ruinedJobSet = new HashSet<Job>();
|
Set<Job> ruinedJobSet = new HashSet<Job>();
|
||||||
ruinedJobSet.addAll(ruinedJobs);
|
ruinedJobSet.addAll(ruinedJobs);
|
||||||
ruinedJobSet.addAll(vrpSolution.getBadJobs());
|
ruinedJobSet.addAll(vrpSolution.getUnassignedJobs());
|
||||||
Collection<Job> badJobs = insertion.insertJobs(vrpSolution.getRoutes(), ruinedJobSet);
|
Collection<Job> unassignedJobs = insertion.insertJobs(vrpSolution.getRoutes(), ruinedJobSet);
|
||||||
vrpSolution.getBadJobs().clear();
|
vrpSolution.getUnassignedJobs().clear();
|
||||||
vrpSolution.getBadJobs().addAll(badJobs);
|
vrpSolution.getUnassignedJobs().addAll(unassignedJobs);
|
||||||
return vrpSolution;
|
return vrpSolution;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class VehicleRoutingProblemSolution {
|
||||||
|
|
||||||
private final Collection<VehicleRoute> routes;
|
private final Collection<VehicleRoute> routes;
|
||||||
|
|
||||||
private Collection<Job> badJobs = new ArrayList<Job>();
|
private Collection<Job> unassignedJobs = new ArrayList<Job>();
|
||||||
|
|
||||||
private double cost;
|
private double cost;
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class VehicleRoutingProblemSolution {
|
||||||
routes.add(route);
|
routes.add(route);
|
||||||
}
|
}
|
||||||
this.cost = solution.getCost();
|
this.cost = solution.getCost();
|
||||||
badJobs.addAll(solution.getBadJobs());
|
unassignedJobs.addAll(solution.getUnassignedJobs());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,12 +73,14 @@ public class VehicleRoutingProblemSolution {
|
||||||
* Constructs a solution with a number of {@link VehicleRoute}s, bad jobs and their corresponding aggregate cost value.
|
* Constructs a solution with a number of {@link VehicleRoute}s, bad jobs and their corresponding aggregate cost value.
|
||||||
*
|
*
|
||||||
* @param routes routes being part of the solution
|
* @param routes routes being part of the solution
|
||||||
|
* @param unassignedJobs jobs that could not be assigned to any vehicle
|
||||||
* @param cost total costs of solution
|
* @param cost total costs of solution
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, Collection<Job> badJobs, double cost) {
|
public VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs, double cost) {
|
||||||
super();
|
super();
|
||||||
this.routes = routes;
|
this.routes = routes;
|
||||||
this.badJobs = badJobs;
|
this.unassignedJobs = unassignedJobs;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,8 +116,8 @@ public class VehicleRoutingProblemSolution {
|
||||||
*
|
*
|
||||||
* @return bad jobs
|
* @return bad jobs
|
||||||
*/
|
*/
|
||||||
public Collection<Job> getBadJobs(){
|
public Collection<Job> getUnassignedJobs(){
|
||||||
return badJobs;
|
return unassignedJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ public class BadJobListTest {
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
||||||
|
|
||||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||||
assertTrue(!solution.getBadJobs().contains(job1));
|
assertTrue(!solution.getUnassignedJobs().contains(job1));
|
||||||
assertTrue(solution.getBadJobs().contains(job2));
|
assertTrue(solution.getUnassignedJobs().contains(job2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -50,8 +50,8 @@ public class BadJobListTest {
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
||||||
|
|
||||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||||
assertTrue(!solution.getBadJobs().contains(job1));
|
assertTrue(!solution.getUnassignedJobs().contains(job1));
|
||||||
assertTrue(solution.getBadJobs().contains(job2));
|
assertTrue(solution.getUnassignedJobs().contains(job2));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class VehicleRoutingProblemSolutionTest {
|
||||||
List<Job> badJobs = new ArrayList<Job>();
|
List<Job> badJobs = new ArrayList<Job>();
|
||||||
badJobs.add(badJob);
|
badJobs.add(badJob);
|
||||||
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), badJobs, 10.0);
|
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), badJobs, 10.0);
|
||||||
assertEquals(1,sol.getBadJobs().size());
|
assertEquals(1,sol.getUnassignedJobs().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -69,8 +69,8 @@ public class VehicleRoutingProblemSolutionTest {
|
||||||
List<Job> badJobs = new ArrayList<Job>();
|
List<Job> badJobs = new ArrayList<Job>();
|
||||||
badJobs.add(badJob);
|
badJobs.add(badJob);
|
||||||
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), 10.0);
|
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), 10.0);
|
||||||
sol.getBadJobs().addAll(badJobs);
|
sol.getUnassignedJobs().addAll(badJobs);
|
||||||
assertEquals(1, sol.getBadJobs().size());
|
assertEquals(1, sol.getUnassignedJobs().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -79,7 +79,7 @@ public class VehicleRoutingProblemSolutionTest {
|
||||||
List<Job> badJobs = new ArrayList<Job>();
|
List<Job> badJobs = new ArrayList<Job>();
|
||||||
badJobs.add(badJob);
|
badJobs.add(badJob);
|
||||||
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), badJobs, 10.0);
|
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), badJobs, 10.0);
|
||||||
assertEquals(badJob,sol.getBadJobs().iterator().next());
|
assertEquals(badJob,sol.getUnassignedJobs().iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -88,8 +88,8 @@ public class VehicleRoutingProblemSolutionTest {
|
||||||
List<Job> badJobs = new ArrayList<Job>();
|
List<Job> badJobs = new ArrayList<Job>();
|
||||||
badJobs.add(badJob);
|
badJobs.add(badJob);
|
||||||
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), 10.0);
|
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), 10.0);
|
||||||
sol.getBadJobs().addAll(badJobs);
|
sol.getUnassignedJobs().addAll(badJobs);
|
||||||
assertEquals(badJob, sol.getBadJobs().iterator().next());
|
assertEquals(badJob, sol.getUnassignedJobs().iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue