private void startLeg(final Attributes atts) { String mode = atts.getValue("mode").toLowerCase(Locale.ROOT); if (mode.equals("undef")) { mode = "undefined"; } this.currleg = PopulationUtils.createAndAddLeg( this.currplan, mode.intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time"))); this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time"))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue("arr_time")) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private void startLeg(final Attributes atts) { this.currleg = PopulationUtils.createAndAddLeg( this.currplan, atts.getValue("mode").toLowerCase(Locale.ROOT).intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time"))); this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time"))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue("arr_time")) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private void startLeg(final Attributes atts) { this.currleg = PopulationUtils.createAndAddLeg( this.currplan, atts.getValue("mode").toLowerCase(Locale.ROOT).intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time"))); this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time"))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue("arr_time")) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
public void handleEvent(PersonDepartureEvent event) { Leg leg = PopulationUtils.createLeg(event.getLegMode()); leg.setDepartureTime(event.getTime()); currentLeg = leg; currentRoute = new ArrayList<Id<Link>>(); }
private void startLeg(final Attributes atts) { if (this.routeDescription != null) { finishLastRoute(); } String mode = atts.getValue(ATTR_LEG_MODE); if (VALUE_UNDEF.equals(mode)) { mode = "undefined"; } this.currleg = PopulationUtils.createAndAddLeg( this.currplan, mode.intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue(ATTR_LEG_DEPTIME))); this.currleg.setTravelTime(Time.parseTime(atts.getValue(ATTR_LEG_TRAVTIME))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue(ATTR_LEG_ARRTIME)) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private void startLeg(final Attributes atts) { if (this.routeDescription != null) { finishLastRoute(); } String mode = atts.getValue(ATTR_LEG_MODE); if (VALUE_UNDEF.equals(mode)) { mode = "undefined"; } this.currleg = PopulationUtils.createAndAddLeg( this.currplan, mode.intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue(ATTR_LEG_DEPTIME))); this.currleg.setTravelTime(Time.parseTime(atts.getValue(ATTR_LEG_TRAVTIME))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue(ATTR_LEG_ARRTIME)) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
@Override public void handleEvent(PersonDepartureEvent event) { Leg leg = PopulationUtils.createLeg(event.getLegMode()); leg.setDepartureTime(event.getTime()); legs.put(event.getPersonId(), leg); List<Id<Link>> route = new ArrayList<>(); route.add(event.getLinkId()); experiencedRoutes.put(event.getPersonId(), route); }
/** * Removes the specified leg <b>and</b> the following act, too! If the following act is not the last one, * the following leg will be emptied to keep consistency (i.e. for the route) * @param index */ public static void removeLeg( Plan plan, int index) { if ((index % 2 == 0) || (index < 1) || (index >= plan.getPlanElements().size()-1)) { log.warn(plan + "[index=" + index +" is wrong. nothing removed]"); } else { if (index != plan.getPlanElements().size()-2) { // not the last leg Leg next_leg = (Leg)plan.getPlanElements().get(index+2); next_leg.setDepartureTime(Time.UNDEFINED_TIME); next_leg.setTravelTime(Time.UNDEFINED_TIME); next_leg.setRoute(null); } plan.getPlanElements().remove(index+1); // following act plan.getPlanElements().remove(index); // leg } } public static void removeActivity( Plan plan, int index ) {
@Override public List<? extends PlanElement> calcRoute( final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person) { Leg l = popFactory.createLeg( modeName ); l.setDepartureTime( departureTime ); Route r = new PassengerRoute( fromFacility.getLinkId() , toFacility.getLinkId() ); l.setRoute( r ); return Collections.singletonList( l ); }
/** * Removes the specified leg <b>and</b> the following act, too! If the following act is not the last one, * the following leg will be emptied to keep consistency (i.e. for the route) * * @param index */ public final void removeLeg(final int index) { if ((index % 2 == 0) || (index < 1) || (index >= getPlanElements().size() - 1)) { log.warn(this + "[index=" + index + " is wrong. nothing removed]"); } else { if (index != getPlanElements().size() - 2) { // not the last leg Leg next_leg = (Leg) getPlanElements().get(index + 2); next_leg.setDepartureTime(Time.UNDEFINED_TIME); next_leg.setTravelTime(Time.UNDEFINED_TIME); next_leg.setTravelTime( Time.UNDEFINED_TIME - next_leg.getDepartureTime() ); next_leg.setRoute(null); } getPlanElements().remove(index + 1); // following act getPlanElements().remove(index); // leg } }
public Leg getLeg() { Leg leg = PopulationUtils.createLeg(mode); leg.setDepartureTime(departureTime); leg.setTravelTime(travelTime); leg.setRoute(route == null ? null : route.getRoute(mode)); return leg; } }
@Override public List<? extends PlanElement> calcRoute( final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person) { Leg newLeg = this.populationFactory.createLeg( this.mode ); newLeg.setDepartureTime( departureTime ); double travTime = routeLeg( person, newLeg, new FacilityWrapperActivity( fromFacility ), new FacilityWrapperActivity( toFacility ), departureTime); // otherwise, information may be lost newLeg.setTravelTime( travTime ); return Arrays.asList(newLeg); }
@Override public List<? extends PlanElement> calcRoute( final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person) { Leg newLeg = this.populationFactory.createLeg( this.mode ); newLeg.setDepartureTime( departureTime ); double travTime = routeLeg( person, newLeg, new FacilityWrapperActivity( fromFacility ), new FacilityWrapperActivity( toFacility ), departureTime); // otherwise, information may be lost newLeg.setTravelTime( travTime ); return Arrays.asList( newLeg ); }
protected double computeTravelTime(Person person, Activity fromAct, Activity toAct) { Leg leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime(0.0); leg.setTravelTime(0.0); leg.setTravelTime( 0.0 - leg.getDepartureTime() ); PlanRouterAdapter.handleLeg(router, person, leg, fromAct, toAct, fromAct.getEndTime()); return leg.getTravelTime(); }
private static void fillInLegTravelTimes( final double departureTime, final List<? extends PlanElement> trip ) { double time = departureTime; for ( PlanElement pe : trip ) { if ( !(pe instanceof Leg) ) continue; final Leg leg = (Leg) pe; if ( leg.getDepartureTime() == Time.UNDEFINED_TIME ) { leg.setDepartureTime( time ); } if ( leg.getTravelTime() == Time.UNDEFINED_TIME ) { leg.setTravelTime( leg.getRoute().getTravelTime() ); } time += leg.getTravelTime(); } }
public static void addBushwhackingLegFromLinkToFacilityIfNecessary( final Facility toFacility, final Person person, final Link egressActLink, double now, final List<PlanElement> result, final PopulationFactory populationFactory, final String stageActivityType ) { if ( toFacility.getCoord() != null ) { // otherwise the trip ends directly on the link; no need to bushwhack Coord egressActCoord = egressActLink.getToNode().getCoord() ; Gbl.assertNotNull( egressActCoord ); final Activity interactionActivity = createInteractionActivity( egressActCoord, egressActLink.getId(), stageActivityType ); result.add( interactionActivity ) ; // log.warn( interactionActivity ); Leg egressLeg = populationFactory.createLeg( TransportMode.egress_walk ) ; egressLeg.setDepartureTime( now ); routeBushwhackingLeg(person, egressLeg, egressActCoord, toFacility.getCoord(), now, egressActLink.getId(), egressActLink.getId(), populationFactory ) ; result.add( egressLeg ) ; // log.warn( egressLeg ); } // log.warn( "===" ); }
public static double addBushwhackingLegFromFacilityToLinkIfNecessary( final Facility fromFacility, final Person person, final Link accessActLink, double now, final List<PlanElement> result, final PopulationFactory populationFactory, final String stageActivityType ) { if ( fromFacility.getCoord() != null ) { // otherwise the trip starts directly on the link; no need to bushwhack Coord accessActCoord = accessActLink.getToNode().getCoord() ; // yyyy think about better solution: this may generate long walks along the link. // (e.g. orthogonal projection) Gbl.assertNotNull(accessActCoord); Leg accessLeg = populationFactory.createLeg( TransportMode.access_walk ) ; accessLeg.setDepartureTime( now ); now += routeBushwhackingLeg(person, accessLeg, fromFacility.getCoord(), accessActCoord, now, accessActLink.getId(), accessActLink.getId(), populationFactory ) ; // yyyy might be possible to set the link ids to null. kai & dominik, may'16 result.add( accessLeg ) ; // log.warn( accessLeg ); final Activity interactionActivity = createInteractionActivity(accessActCoord, accessActLink.getId(), stageActivityType ); result.add( interactionActivity ) ; // log.warn( interactionActivity ); } return now; }
public static void copyFromTo(Leg in, Leg out) { out.setMode( in.getMode() ); out.setDepartureTime(in.getDepartureTime()); out.setTravelTime(in.getTravelTime()); if (in.getRoute() != null) { out.setRoute(in.getRoute().clone()); } AttributesUtils.copyAttributesFromTo( in , out ); }
@Override public List<? extends PlanElement> calcRoute(Facility fromFacility, Facility toFacility, double departureTime, Person person) { Leg newLeg = scenario.getPopulation().getFactory().createLeg( TransportMode.pt ); Id<Link> startLinkId = fromFacility.getLinkId(); Id<Link> endLinkId = toFacility.getLinkId(); newLeg.setDepartureTime( departureTime ); double travelTime = this.ptMatrix.getTotalTravelTime_seconds(fromFacility.getCoord(), toFacility.getCoord()); newLeg.setTravelTime( travelTime ); final Route route = genericRouteFactory.createRoute(startLinkId, endLinkId); double distance = this.ptMatrix.getTotalTravelDistance_meter(fromFacility.getCoord(), toFacility.getCoord()) ; route.setDistance(distance) ; newLeg.setRoute(route); return Arrays.asList( newLeg ); }
/* package */ double routeLeg(Person person, Leg leg, Activity fromAct, Activity toAct, double depTime) { // make simple assumption about distance and walking speed final Coord fromActCoord = fromAct.getCoord(); Gbl.assertNotNull( fromActCoord ); final Coord toActCoord = toAct.getCoord(); Gbl.assertNotNull( toActCoord ); double dist = CoordUtils.calcEuclideanDistance( fromActCoord, toActCoord ); // create an empty route, but with realistic travel time Route route = this.populationFactory.getRouteFactories().createRoute(Route.class, fromAct.getLinkId(), toAct.getLinkId()); double estimatedNetworkDistance = dist * this.beelineDistanceFactor; int travTime = (int) (estimatedNetworkDistance / this.networkTravelSpeed); route.setTravelTime(travTime); route.setDistance(estimatedNetworkDistance); leg.setRoute(route); leg.setDepartureTime(depTime); leg.setTravelTime(travTime); Leg r = (leg); r.setTravelTime( depTime + travTime - r.getDepartureTime() ); // yy something needs to be done once there are alternative implementations of the interface. kai, apr'10 return travTime; }