Skip to content

Commit

Permalink
Merge branch 'collision_graph_remove_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
rinde committed May 4, 2015
2 parents 5990a3b + 271285e commit 9034dc8
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# RinSim 3.2.2
# RinSim 3.2.3

RinSim is an extensible logistics simulator with support for (de)centralized algorithms for pickup and delivery problems and AGV routing. The simulator focuses on __simplicity__ and __consistency__ making it ideal for performing scientific simulations. Further, software quality is a priority resulting in an ever improving test suite and documentation.

Expand Down
2 changes: 1 addition & 1 deletion central/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ public void addObjectAtSamePosition(RoadUser newObj, RoadUser existingObj) {
"Vehicles can not be added at the same position.");
}

@Override
public void removeObject(RoadUser object) {
checkArgument(objLocs.containsKey(object),
"RoadUser: %s does not exist.", object);
occupiedNodes.removeAll(object);
super.removeObject(object);
}

/**
* Checks whether the specified node is occupied.
* @param node The node to check for occupancy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class CollisionGraphRoadModelTest {
public void setUp() {
graph = new ListenableGraph<>(new TableGraph<LengthData>());
model = CollisionGraphRoadModel.builder(graph)
.setVehicleLength(1d)
.setMinDistance(0)
.build();
.setVehicleLength(1d)
.setMinDistance(0)
.build();
NW = new Point(0, 0);
NE = new Point(10, 0);
SE = new Point(10, 10);
Expand Down Expand Up @@ -118,6 +118,33 @@ public void testAddObject() {
assertEquals(NW, model.getPosition(agv2));
}

/**
* Tests that a removed object no longer occupies its position.
*/
@Test
public void testRemoveObject() {
final MovingRoadUser agv1 = new TestRoadUser();
model.addObjectAt(agv1, NW);
assertTrue(model.isOccupied(NW));

model.removeObject(agv1);
assertFalse(model.isOccupied(NW));
}

/**
* Tests that a unregistered object is removed.
*/
@Test
public void testUnregisterObject() {
final MovingRoadUser agv1 = new TestRoadUser();
model.addObjectAt(agv1, NW);
assertTrue(model.isOccupied(NW));

model.unregister(agv1);
assertFalse(model.containsObject(agv1));
assertFalse(model.isOccupied(NW));
}

/**
* Test for detection of a dead lock situation between two AGVs. The AGVs
* drive on the same connection from opposite ends. An
Expand Down Expand Up @@ -159,9 +186,9 @@ public void testHeadTailCollisionAvoidance() {
model.moveTo(agv2, NE, meter(20));

assertPointEquals(new Point(3, 0), model.getPosition(agv1),
GraphRoadModel.DELTA);
GraphRoadModel.DELTA);
assertPointEquals(new Point(2, 0), model.getPosition(agv2),
GraphRoadModel.DELTA);
GraphRoadModel.DELTA);

// moving is not allowed
checkNoMovement(model.moveTo(agv2, NE, meter(20)));
Expand Down Expand Up @@ -200,9 +227,9 @@ public void testNodeCollisionAvoidance() {
model.moveTo(agv2, NW, meter(10));

assertPointEquals(new Point(1d - 0.0002777777778, 0),
model.getPosition(agv1), GraphRoadModel.DELTA);
model.getPosition(agv1), GraphRoadModel.DELTA);
assertPointEquals(new Point(0, 1.0), model.getPosition(agv2),
GraphRoadModel.DELTA);
GraphRoadModel.DELTA);

// moving agv2 is not allowed
checkNoMovement(model.moveTo(agv2, NW, meter(20)));
Expand All @@ -225,7 +252,7 @@ public void testNodeCollisionAvoidance() {
assertEquals(1L, tl3.getTimeLeft());
model.moveTo(agv1, X, tl3);
assertPointEquals(new Point(0, -1), model.getPosition(agv1),
GraphRoadModel.DELTA);
GraphRoadModel.DELTA);
model.moveTo(agv2, NW, meter(1));
assertEquals(NW, model.getPosition(agv2));
}
Expand All @@ -239,7 +266,7 @@ public void testBuilderVehicleLength() {
boolean fail = false;
try {
CollisionGraphRoadModel.builder(graph)
.setVehicleLength(0d);
.setVehicleLength(0d);
} catch (final IllegalArgumentException e) {
fail = true;
}
Expand All @@ -249,15 +276,15 @@ public void testBuilderVehicleLength() {
fail = false;
try {
CollisionGraphRoadModel.builder(graph)
.setVehicleLength(Double.POSITIVE_INFINITY);
.setVehicleLength(Double.POSITIVE_INFINITY);
} catch (final IllegalArgumentException e) {
fail = true;
}
assertTrue(fail);

final CollisionGraphRoadModel cgr1 = CollisionGraphRoadModel.builder(graph)
.setVehicleLength(5d)
.build();
.setVehicleLength(5d)
.build();
assertEquals(5d, cgr1.getVehicleLength(), 0);
}

Expand All @@ -267,24 +294,24 @@ public void testBuilderVehicleLength() {
@Test
public void testBuilderMinDistance() {
assertEquals(0d, CollisionGraphRoadModel.builder(graph)
.setMinDistance(0d)
.build()
.getMinDistance(),
0);
.setMinDistance(0d)
.build()
.getMinDistance(),
0);

assertEquals(2d, CollisionGraphRoadModel.builder(graph)
.setMinDistance(2d)
.build()
.getMinDistance(),
0);
.setMinDistance(2d)
.build()
.getMinDistance(),
0);

// min distance may not be > 2 * vehicle length
boolean fail = false;
try {
CollisionGraphRoadModel.builder(graph)
.setVehicleLength(1d)
.setMinDistance(2.000000001)
.build();
.setVehicleLength(1d)
.setMinDistance(2.000000001)
.build();
} catch (final IllegalArgumentException e) {
fail = true;
}
Expand All @@ -294,7 +321,7 @@ public void testBuilderMinDistance() {
fail = false;
try {
CollisionGraphRoadModel.builder(graph)
.setMinDistance(-1d);
.setMinDistance(-1d);
} catch (final IllegalArgumentException e) {
fail = true;
}
Expand All @@ -307,17 +334,17 @@ public void testBuilderMinDistance() {
@Test
public void testDetectInvalidConnAtConstruction() {
final ListenableGraph<?> g = new ListenableGraph<>(
new TableGraph<LengthData>());
new TableGraph<LengthData>());
// this connection is allowed:
g.addConnection(new Point(0, 0), new Point(1, 0));
// this connection is not allowed:
g.addConnection(new Point(0, 0), new Point(.99, 0));
boolean fail = false;
try {
CollisionGraphRoadModel.builder(g)
.setVehicleLength(1d)
.setMinDistance(.25)
.build();
.setVehicleLength(1d)
.setMinDistance(.25)
.build();
} catch (final IllegalArgumentException e) {
fail = true;
}
Expand Down
2 changes: 1 addition & 1 deletion event/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion experiment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion fsm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion geom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion pdptw/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<packaging>pom</packaging>

<name>RinSim</name>
Expand Down
3 changes: 3 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release notes

## v3.2.3
* CollisionGraphRoadModel bug fix: when a road user is removed from the model the position it was occupying is now released which was previously not the case.

## v3.2.2
* CollisionGraphRoadModel is changed such that only implementors of MovingRoadUser (instead of RoadUser) are blocking. This means that depots and parcels are no longer blocking the way of AGVs which means that the PDPModel can now actually be used together with the CollisionGraphRoadModel.

Expand Down
2 changes: 1 addition & 1 deletion scenario-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion scenario/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion test-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.rinde</groupId>
<artifactId>rinsim-main</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down

0 comments on commit 9034dc8

Please sign in to comment.