mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
fixed bug #263
This commit is contained in:
parent
9e6ff24cab
commit
5b8ca8e965
3 changed files with 14 additions and 5 deletions
|
|
@ -70,8 +70,8 @@ class JobNeighborhoodsOptimized implements JobNeighborhoods {
|
|||
this.vrp = vrp;
|
||||
this.jobDistance = jobDistance;
|
||||
this.capacity = capacity;
|
||||
neighbors = new int[vrp.getJobs().size()][capacity];
|
||||
jobs = new Job[vrp.getJobs().size()+1];
|
||||
neighbors = new int[vrp.getJobsInclusiveInitialJobsInRoutes().size()+1][capacity];
|
||||
jobs = new Job[vrp.getJobsInclusiveInitialJobsInRoutes().size()+1];
|
||||
logger.debug("initialize {}", this);
|
||||
}
|
||||
|
||||
|
|
@ -97,10 +97,10 @@ class JobNeighborhoodsOptimized implements JobNeighborhoods {
|
|||
logger.debug("pre-process distances between locations ...");
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
for (Job job_i : vrp.getJobs().values()) {
|
||||
for (Job job_i : vrp.getJobsInclusiveInitialJobsInRoutes().values()) {
|
||||
jobs[job_i.getIndex()] = job_i;
|
||||
List<ReferencedJob> jobList = new ArrayList<ReferencedJob>(vrp.getJobs().size());
|
||||
for (Job job_j : vrp.getJobs().values()) {
|
||||
List<ReferencedJob> jobList = new ArrayList<ReferencedJob>(vrp.getJobsInclusiveInitialJobsInRoutes().values().size());
|
||||
for (Job job_j : vrp.getJobsInclusiveInitialJobsInRoutes().values()) {
|
||||
if (job_i == job_j) continue;
|
||||
double distance = jobDistance.getDistance(job_i, job_j);
|
||||
if (distance > maxDistance) maxDistance = distance;
|
||||
|
|
|
|||
|
|
@ -546,6 +546,7 @@ public class VehicleRoutingProblem {
|
|||
*/
|
||||
private final Map<String, Job> jobs;
|
||||
|
||||
private final Map<String, Job> allJobs;
|
||||
/**
|
||||
* Collection that contains available vehicles.
|
||||
*/
|
||||
|
|
@ -593,6 +594,7 @@ public class VehicleRoutingProblem {
|
|||
this.activityMap = builder.activityMap;
|
||||
this.nuActivities = builder.activityIndexCounter;
|
||||
this.allLocations = builder.allLocations;
|
||||
this.allJobs = builder.tentativeJobs;
|
||||
logger.info("setup problem: {}", this);
|
||||
}
|
||||
|
||||
|
|
@ -623,6 +625,9 @@ public class VehicleRoutingProblem {
|
|||
return Collections.unmodifiableMap(jobs);
|
||||
}
|
||||
|
||||
public Map<String, Job> getJobsInclusiveInitialJobsInRoutes(){
|
||||
return Collections.unmodifiableMap(allJobs);
|
||||
}
|
||||
/**
|
||||
* Returns a copy of initial vehicle routes.
|
||||
*
|
||||
|
|
@ -685,6 +690,8 @@ public class VehicleRoutingProblem {
|
|||
return Collections.unmodifiableList(activityMap.get(job));
|
||||
}
|
||||
|
||||
// public Map<Job,List<AbstractActivity>> getActivityMap() { return Collections.unmodifiableMap(activityMap); }
|
||||
|
||||
/**
|
||||
* @return total number of activities
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -142,4 +142,6 @@ public class JobNeighborhoodsOptimizedTest {
|
|||
assertEquals(2, services.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue