Skip to content

Commit

Permalink
feat: generalize multimodal link chooser (#3536)
Browse files Browse the repository at this point in the history
* feat: generalize multimodal link chooser

* update test

* make method private
  • Loading branch information
sebhoerl authored Nov 15, 2024
1 parent 8969b53 commit 826595e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.facilities.Facility;

public interface MultimodalLinkChooser {

public Link decideOnLink( final Facility facility, final Network network );
public Link decideAccessLink(RoutingRequest request, Network network);
public Link decideEgressLink(RoutingRequest request, Network network);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ class MultimodalLinkChooserDefaultImpl implements MultimodalLinkChooser {
private static final Logger log = LogManager.getLogger( FacilitiesUtils.class ) ;

@Override
public Link decideOnLink(Facility facility, Network network) {
public Link decideAccessLink(RoutingRequest request, Network network) {
return decideOnLink(request.getFromFacility(), network);
}

@Override
public Link decideEgressLink(RoutingRequest request, Network network) {
return decideOnLink(request.getToFacility(), network);
}

private Link decideOnLink(Facility facility, Network network) {
Link accessActLink = null ;

Id<Link> accessActLinkId = null ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ public synchronized List<? extends PlanElement> calcRoute(RoutingRequest request
Gbl.assertNotNull(fromFacility);
Gbl.assertNotNull(toFacility);

Link accessActLink = multimodalLinkChooser.decideOnLink(fromFacility, filteredNetwork);

Link egressActLink = multimodalLinkChooser.decideOnLink(toFacility, filteredNetwork);
Link accessActLink = multimodalLinkChooser.decideAccessLink(request, filteredNetwork);
Link egressActLink = multimodalLinkChooser.decideEgressLink(request, filteredNetwork);

double now = departureTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
*/

public class MultimodalLinkChooserTest {
public class MultimodalLinkChooserDefaultImplTest {

@Test
void testDecideOnLink() {
Expand Down Expand Up @@ -75,11 +75,13 @@ void testDecideOnLink() {

MultimodalLinkChooser linkChooser = new MultimodalLinkChooserDefaultImpl();

Link linkFromFacLinkId = linkChooser.decideOnLink(facilityLinkIdNotNull, network);
RoutingRequest request = DefaultRoutingRequest.of(facilityLinkIdNotNull, facilityLinkIdNull, 0, null, null);

Link linkFromFacLinkId = linkChooser.decideAccessLink(request, network);

Assertions.assertEquals(networkLink, linkFromFacLinkId);

Link linkFromFacCoord = linkChooser.decideOnLink(facilityLinkIdNull, network);
Link linkFromFacCoord = linkChooser.decideEgressLink(request, network);

Assertions.assertEquals(networkLink, linkFromFacCoord);

Expand Down

0 comments on commit 826595e

Please sign in to comment.