private List<Subtour> getRootSubtoursWithMode(final Plan plan) { final Collection<Subtour> allSubtours = TripStructureUtils.getSubtours( plan , tripRouter.getStageActivityTypes() ); final List<Subtour> roots = new ArrayList<Subtour>(); for ( Subtour s : allSubtours ) { if ( s.getParent() != null ) continue; if ( !containsMode( s ) ) continue; roots.add( s ); } return roots; }
); for ( final Subtour s : subtours ) { if ( s.getParent() != null ) continue; // is not a root tour boolean isFirstTrip = true; for ( final Trip t : s.getTrips() ) { for ( final SubtourRecord record : vehicularTours ) { final Subtour s = record.subtour; assert s.getParent() == null; final Id anchor = s.getTrips().get( 0 ).getOriginActivity().getFacilityId()!=null ? s.getTrips().get( 0 ).getOriginActivity().getFacilityId() :
if ( !mutateds.contains( s.getParent() ) ) { nMutatedWithoutMutatedFather++;
if ( !mutated.contains( s.getParent() ) ) { nMutatedWithoutMutatedFather++;
if ( !mutated.contains( s.getParent() ) ) { nMutatedWithoutMutatedFather++;
@Test public void testFatherhood() throws Exception { for (Fixture f : allFixtures( useFacilitiesAsAnchorPoint )) { final Collection<Subtour> subtours = TripStructureUtils.getSubtours( f.plan , CHECKER); for (Subtour s : subtours) { for ( Subtour child : s.getChildren() ) { assertEquals( "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ "wrong father!", child.getParent(), s); } if ( s.getParent() != null ) { assertTrue( "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ "father does not have subtour has a child", s.getParent().getChildren().contains( s )); } } } }
@Override public void run(final Plan plan) { for ( Subtour subtour : TripStructureUtils.getSubtours( plan , stages ) ) { // not clear what we should do with open tours if ( !subtour.isClosed() ) continue; // only consider "root" tours: tours without (closed) parent if ( subtour.getParent() != null && subtour.getParent().isClosed() ) continue; final String mode = modeIdentifier.identifyMode( subtour ); for ( Trip trip : subtour.getTrips() ) { TripRouter.insertTrip( plan, trip.getOriginActivity(), Collections.singletonList( PopulationUtils.createLeg(mode) ), trip.getDestinationActivity() ); } } }