mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
modified and tested start and end to deal with multiple cap-dims
This commit is contained in:
parent
b6a235bf92
commit
bcfe9a401d
4 changed files with 114 additions and 4 deletions
|
|
@ -1,5 +1,75 @@
|
|||
package jsprit.core.problem.solution.route.activity;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class EndTest {
|
||||
|
||||
@Test
|
||||
public void whenCallingCapacity_itShouldReturnEmptyCapacity(){
|
||||
End end = End.newInstance("loc", 0., 0.);
|
||||
assertEquals(0,end.getCapacity().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallingCapacityDemand_itShouldReturnEmptyCapacity(){
|
||||
End end = End.newInstance("loc", 0., 0.);
|
||||
assertEquals(0,end.getCapacityDemand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
assertEquals(1.,end.getTheoreticalEarliestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
assertEquals(2.,end.getTheoreticalLatestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingEndTime_itShouldBeSetCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
end.setEndTime(4.0);
|
||||
assertEquals(4.,end.getEndTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingLocationId_itShouldBeSetCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
end.setLocationId("newLoc");
|
||||
assertEquals("newLoc",end.getLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingEarliestStart_itShouldBeSetCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
end.setTheoreticalEarliestOperationStartTime(5.);
|
||||
assertEquals(5.,end.getTheoreticalEarliestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingLatestStart_itShouldBeSetCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
end.setTheoreticalLatestOperationStartTime(5.);
|
||||
assertEquals(5.,end.getTheoreticalLatestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCopyingEnd_itShouldBeDoneCorrectly(){
|
||||
End end = End.newInstance("loc", 1., 2.);
|
||||
end.setTheoreticalEarliestOperationStartTime(3.);
|
||||
end.setTheoreticalLatestOperationStartTime(5.);
|
||||
|
||||
End copy = End.copyOf(end);
|
||||
assertEquals(3.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
|
||||
assertEquals(5.,copy.getTheoreticalLatestOperationStartTime(),0.01);
|
||||
assertEquals("loc",copy.getLocationId());
|
||||
assertTrue(copy!=end);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,48 @@ public class StartTest {
|
|||
@Test
|
||||
public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly(){
|
||||
Start start = Start.newInstance("loc", 1., 2.);
|
||||
|
||||
assertEquals(2.,start.getTheoreticalLatestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingStartEndTime_itShouldBeSetCorrectly(){
|
||||
Start start = Start.newInstance("loc", 1., 2.);
|
||||
start.setEndTime(4.0);
|
||||
assertEquals(4.,start.getEndTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingLocationId_itShouldBeSetCorrectly(){
|
||||
Start start = Start.newInstance("loc", 1., 2.);
|
||||
start.setLocationId("newLoc");
|
||||
assertEquals("newLoc",start.getLocationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingEarliestStart_itShouldBeSetCorrectly(){
|
||||
Start start = Start.newInstance("loc", 1., 2.);
|
||||
start.setTheoreticalEarliestOperationStartTime(5.);
|
||||
assertEquals(5.,start.getTheoreticalEarliestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingLatestStart_itShouldBeSetCorrectly(){
|
||||
Start start = Start.newInstance("loc", 1., 2.);
|
||||
start.setTheoreticalLatestOperationStartTime(5.);
|
||||
assertEquals(5.,start.getTheoreticalLatestOperationStartTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCopyingStart_itShouldBeDoneCorrectly(){
|
||||
Start start = Start.newInstance("loc", 1., 2.);
|
||||
start.setTheoreticalEarliestOperationStartTime(3.);
|
||||
start.setTheoreticalLatestOperationStartTime(5.);
|
||||
|
||||
Start copy = Start.copyOf(start);
|
||||
assertEquals(3.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
|
||||
assertEquals(5.,copy.getTheoreticalLatestOperationStartTime(),0.01);
|
||||
assertEquals("loc",copy.getLocationId());
|
||||
assertTrue(copy!=start);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue