-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
859f8b6
commit fa3cd6e
Showing
14 changed files
with
390 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/test/java/at/ac/ait/matsim/drs/optimizer/BestMatchFinderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package at.ac.ait.matsim.drs.optimizer; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.matsim.api.core.v01.Id; | ||
import org.matsim.api.core.v01.network.Network; | ||
import org.matsim.api.core.v01.population.PlanElement; | ||
import org.matsim.core.router.DefaultRoutingRequest; | ||
import org.matsim.core.router.RoutingModule; | ||
import org.matsim.core.router.RoutingRequest; | ||
import org.matsim.facilities.FacilitiesUtils; | ||
|
||
import at.ac.ait.matsim.drs.DrsTestUtil; | ||
import at.ac.ait.matsim.drs.RoutingForTests; | ||
import at.ac.ait.matsim.drs.optimizer.DrsRequest.DrsDriverRequest; | ||
import at.ac.ait.matsim.drs.optimizer.DrsRequest.DrsRiderRequest; | ||
|
||
class BestMatchFinderTest { | ||
static Network network; | ||
static DrsDriverRequest driverRequest; | ||
static DrsRiderRequest request2, request3, request4, request5; | ||
static List<? extends PlanElement> request2Route, request3Route, request4Route, request5Route; | ||
static RoutingRequest toRequest2, toRequest3, toRequest4, toRequest5; | ||
static BestMatchFinder bestMatchFinder; | ||
|
||
@BeforeAll | ||
static void setup() { | ||
RoutingForTests routingForTests = new RoutingForTests("data/floridsdorf/network.xml"); | ||
network = routingForTests.getNetwork(); | ||
RoutingModule driverRouter = routingForTests.getDriverRouter(); | ||
|
||
bestMatchFinder = new BestMatchFinder(driverRouter); | ||
|
||
driverRequest = DrsTestUtil.mockDriverRequest(1, 8 * 60 * 60, | ||
network.getLinks().get(Id.createLinkId(1540)), | ||
network.getLinks().get(Id.createLinkId(186))); | ||
|
||
request2 = DrsTestUtil.mockRiderRequest(2, 8 * 60 * 60, | ||
network.getLinks().get(Id.createLinkId(1541)), | ||
network.getLinks().get(Id.createLinkId(186))); | ||
toRequest2 = DefaultRoutingRequest.withoutAttributes( | ||
FacilitiesUtils.wrapLink(request2.getFromLink()), | ||
FacilitiesUtils.wrapLink(request2.getToLink()), | ||
driverRequest.getDepartureTime(), driverRequest.getPerson()); | ||
request2Route = driverRouter.calcRoute(toRequest2); | ||
|
||
request3 = DrsTestUtil.mockRiderRequest(3, 8 * 60 * 60, | ||
network.getLinks().get(Id.createLinkId(1037)), | ||
network.getLinks().get(Id.createLinkId(186))); | ||
toRequest3 = DefaultRoutingRequest.withoutAttributes( | ||
FacilitiesUtils.wrapLink(request3.getFromLink()), | ||
FacilitiesUtils.wrapLink(request3.getToLink()), | ||
driverRequest.getDepartureTime(), driverRequest.getPerson()); | ||
request3Route = driverRouter.calcRoute(toRequest3); | ||
|
||
request4 = DrsTestUtil.mockRiderRequest(4, 8 * 60 * 60, | ||
network.getLinks().get(Id.createLinkId(186)), | ||
network.getLinks().get(Id.createLinkId(1037))); | ||
toRequest4 = DefaultRoutingRequest.withoutAttributes( | ||
FacilitiesUtils.wrapLink(request4.getFromLink()), | ||
FacilitiesUtils.wrapLink(request4.getToLink()), | ||
driverRequest.getDepartureTime(), driverRequest.getPerson()); | ||
request4Route = driverRouter.calcRoute(toRequest4); | ||
|
||
request5 = DrsTestUtil.mockRiderRequest(5, 8 * 60 * 60, | ||
network.getLinks().get(Id.createLinkId(688)), | ||
network.getLinks().get(Id.createLinkId(1540))); | ||
toRequest5 = DefaultRoutingRequest.withoutAttributes( | ||
FacilitiesUtils.wrapLink(request5.getFromLink()), | ||
FacilitiesUtils.wrapLink(request5.getToLink()), | ||
driverRequest.getDepartureTime(), driverRequest.getPerson()); | ||
request5Route = driverRouter.calcRoute(toRequest5); | ||
} | ||
|
||
@Test | ||
void noFilteredRequestsTest() { | ||
assertNull(bestMatchFinder.findBestMatch(Collections.emptyList())); | ||
} | ||
|
||
@Test | ||
void findBestRequestTest() { | ||
List<DrsMatch> potentialMatches = new ArrayList<>(); | ||
potentialMatches.add(DrsMatch.createMinimal(driverRequest, request4, null)); | ||
potentialMatches.add(DrsMatch.createMinimal(driverRequest, request5, null)); | ||
potentialMatches.add(DrsMatch.createMinimal(driverRequest, request3, null)); | ||
potentialMatches.add(DrsMatch.createMinimal(driverRequest, request2, null)); | ||
|
||
DrsMatch bestMatch = bestMatchFinder.findBestMatch(potentialMatches); | ||
assertNotNull(bestMatch); | ||
assertEquals("2", bestMatch.getRider().getId().toString()); | ||
} | ||
} |
100 changes: 0 additions & 100 deletions
100
src/test/java/at/ac/ait/matsim/drs/optimizer/BestRequestFinderTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.