String mainMode = mainModeIdentifier.identifyMainMode( trip.getTripElements() ) ; Double item = calcBeelineDistance(trip.getOriginActivity(), trip.getDestinationActivity()) ;
@Override public void run(final Plan plan) { final List<Id> vehs = new ArrayList<Id>( vehicleRessources.identifyVehiclesUsableForAgent( plan.getPerson().getId() ) ); // make sure order is deterministic Collections.sort( vehs ); final List<Subtour> rootSubtours = getRootSubtoursWithMode( plan ); if ( rootSubtours.isEmpty() ) return; final Subtour toHandle = rootSubtours.get( random.nextInt( rootSubtours.size() ) ); final Id veh = vehs.get( random.nextInt( vehs.size() ) ); for ( Trip t : toHandle.getTrips() ) { if ( !identifyMainMode( t ).equals( mode ) ) continue; for ( Leg l : t.getLegsOnly() ) { if ( !(l.getRoute() instanceof NetworkRoute) ) continue; final NetworkRoute route = (NetworkRoute) l.getRoute(); route.setVehicleId( veh ); } } }
trips.add( new Trip( (Activity) planElements.get( originActivityIndex ),
final Id<?> originId; if (trip.getOriginActivity().getFacilityId()!=null ) { originId = trip.getOriginActivity().getFacilityId(); } else { originId = trip.getOriginActivity().getLinkId(); throw new NullPointerException( "Both facility id and link id for origin activity "+trip.getOriginActivity()+ " are null!" ); if (trip.getDestinationActivity().getFacilityId()!=null ) { destinationId = trip.getDestinationActivity().getFacilityId(); } else { destinationId = trip.getDestinationActivity().getLinkId(); throw new NullPointerException( "Both facility id and link id for destination activity "+trip.getDestinationActivity()+ " are null!" );
new Subtour( Arrays.asList( new Trip( act1 , trip1 , act2 ), new Trip( act2 , trip2 , act3 ), new Trip( act3 , trip3 , act4 ) ), true); final Subtour rootSubtour2 = new Subtour( Arrays.asList( new Trip( act4 , trip4 , act5 ), new Trip( act5 , trip5 , act6 ), new Trip( act6 , trip6 , act7 ), new Trip( act7 , trip7 , act8 )), true); new Subtour( Arrays.asList( new Trip( act5 , trip5 , act6 ), new Trip( act6 , trip6 , act7 )), true); childSubtour.parent = rootSubtour2;
new Subtour( Arrays.asList( new Trip( act1 , trip1 , act2 ), new Trip( act2 , trip2 , act3 ), new Trip( act3 , trip3 , act4 ), new Trip( act4 , trip4 , act5 ), new Trip( act5 , trip5 , act6 ) ), true); final Subtour childSubtour1 = new Subtour( Arrays.asList( new Trip( act2 , trip2 , act3 ) ), true); final Subtour childSubtour2 = new Subtour( Arrays.asList( new Trip( act4 , trip4 , act5 ) ), true); childSubtour1.parent = rootSubtour;
subtour.getTrips().get( 0 ).getOriginActivity().getFacilityId() !=null ? subtour.getTrips().get( 0 ).getOriginActivity().getFacilityId() : subtour.getTrips().get( 0 ).getOriginActivity().getLinkId();
"unexpected mutated trip length", 1, t.getTripElements().size());
List<Trip> trips = TripStructureUtils.getTrips(plan, stageActivities) ; for ( Trip trip : trips ) { String mode = this.mainModeIdentifier.identifyMainMode( trip.getTripElements() ) ;
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() : s.getTrips().get( 0 ).getOriginActivity().getLinkId();
"unexpected mutated trip length", 1, t.getTripElements().size());
plan.addActivity( act2 ); trips.add(new Trip(act1, Collections.<PlanElement>singletonList(leg1), act2)); plan.addActivity( act3 ); final Trip tripObject = new Trip( lastAct , trip , act3 ); trips.add( tripObject ); childrenSubtours.add( plan.addActivity( act4 ); trips.add(new Trip(lastAct, trip3, act4));
if ( expectedMode.equals( trip.getLegsOnly().get( 0 ).getMode() ) ) { assertTrue( "inconsistent mode chain",
final List<PlanElement> currentTripElements = tripBeforeAct.getTripElements(); final String currentMode = this.tripRouter.getMainModeIdentifier().identifyMainMode( currentTripElements ) ; upstreamMode = currentMode ; this.editTrips.insertEmptyTrip( plan, tripBeforeAct.getOriginActivity(), newAct, upstreamMode ); final String currentMainMode = this.tripRouter.getMainModeIdentifier().identifyMainMode( tripAfterAct.getTripElements() ); EditTrips.insertEmptyTrip(plan, newAct, tripAfterAct.getDestinationActivity(), currentMainMode, pf); } else { EditTrips.insertEmptyTrip(plan, newAct, tripAfterAct.getDestinationActivity(), downstreamMode, pf);
sf.handleActivity(new PersonExperiencedActivity(personId, pf.createActivityFromCoord("work", new Coord(1000, 100)))); Assert.assertEquals(1, rs.tripCounter); Assert.assertEquals(1, rs.lastTrip.getTripElements().size()); Assert.assertEquals("walk", ((Leg) rs.lastTrip.getTripElements().get(0)).getMode()); sf.handleActivity(new PersonExperiencedActivity(personId, pf.createActivityFromCoord("leisure", new Coord(1000, 200)))); Assert.assertEquals(2, rs.tripCounter); Assert.assertEquals(5, rs.lastTrip.getTripElements().size()); Assert.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(0)).getMode()); Assert.assertEquals("pt", ((Leg) rs.lastTrip.getTripElements().get(2)).getMode()); Assert.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(4)).getMode());
PopulationUtils.createActivityFromLinkId(JointActingTypes.INTERACTION, route != null ? route.getStartLinkId() : subtrip.getOriginActivity().getLinkId()) ); subtrips.get( 0 ).getOriginActivity(), newTrip, subtrips.get( subtrips.size() - 1 ).getDestinationActivity() );