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

Compare commits

..

No commits in common. "da0bff3ac9bc773af1bb3aaf6e7fcf28f1afba36" and "d03906950ff6875a99fa34ce772444c6dc2e558b" have entirely different histories.

2 changed files with 1 additions and 20 deletions

View file

@ -95,10 +95,6 @@ class JobNeighborhoodsOptimized implements JobNeighborhoods {
@Override @Override
public Iterator<Job> getNearestNeighborsIterator(int nNeighbors, Job neighborTo) { public Iterator<Job> getNearestNeighborsIterator(int nNeighbors, Job neighborTo) {
if (neighborTo.getIndex() == 0) {
return Collections.emptyIterator();
}
int[] neighbors = this.neighbors[neighborTo.getIndex()-1]; int[] neighbors = this.neighbors[neighborTo.getIndex()-1];
return new ArrayIterator(nNeighbors,neighbors,jobs); return new ArrayIterator(nNeighbors,neighbors,jobs);
} }

View file

@ -21,10 +21,8 @@ import com.graphhopper.jsprit.core.algorithm.ruin.distance.EuclideanServiceDista
import com.graphhopper.jsprit.core.algorithm.ruin.distance.JobDistance; import com.graphhopper.jsprit.core.algorithm.ruin.distance.JobDistance;
import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.Location;
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
import com.graphhopper.jsprit.core.problem.job.Break;
import com.graphhopper.jsprit.core.problem.job.Job; import com.graphhopper.jsprit.core.problem.job.Job;
import com.graphhopper.jsprit.core.problem.job.Service; import com.graphhopper.jsprit.core.problem.job.Service;
import junit.framework.Assert; import junit.framework.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -50,7 +48,6 @@ public class JobNeighborhoodsOptimizedTest {
Service s5; Service s5;
Service s6; Service s6;
Service s7; Service s7;
Break b1;
@Before @Before
public void doBefore() { public void doBefore() {
@ -64,8 +61,6 @@ public class JobNeighborhoodsOptimizedTest {
s6 = Service.Builder.newInstance("s6").addSizeDimension(0, 1).setLocation(Location.newInstance(0, 7)).build(); s6 = Service.Builder.newInstance("s6").addSizeDimension(0, 1).setLocation(Location.newInstance(0, 7)).build();
s7 = Service.Builder.newInstance("s7").addSizeDimension(0, 1).setLocation(Location.newInstance(0, 8)).build(); s7 = Service.Builder.newInstance("s7").addSizeDimension(0, 1).setLocation(Location.newInstance(0, 8)).build();
b1 = Break.Builder.newInstance("b1").build();
vrp = builder.addJob(target).addJob(s2).addJob(s3).addJob(s4).addJob(s5).addJob(s6).addJob(s7).build(); vrp = builder.addJob(target).addJob(s2).addJob(s3).addJob(s4).addJob(s5).addJob(s6).addJob(s7).build();
jobDistance = new EuclideanServiceDistance(); jobDistance = new EuclideanServiceDistance();
@ -146,16 +141,6 @@ public class JobNeighborhoodsOptimizedTest {
assertEquals(2, services.size()); assertEquals(2, services.size());
} }
@Test
public void whenRequestingNeighborsForZeroIndexBreak_itShouldReturnEmptyIterator() {
JobNeighborhoodsOptimized jn = new JobNeighborhoodsOptimized(vrp,jobDistance,2);
jn.initialise();
Iterator<Job> iter = jn.getNearestNeighborsIterator(100, b1);
List<Service> services = new ArrayList<Service>();
while (iter.hasNext()) {
services.add((Service) iter.next());
}
assertEquals(0, services.size());
}
} }