private double getTravelDist(final Person person) { double travelDist=0.0; for (PlanElement pe : person.getSelectedPlan().getPlanElements()) { if (pe instanceof Leg) { travelDist+=((Leg) pe).getRoute().getDistance(); } } return travelDist; }
private double getTravelTime(final Person person) { double travelTime=0.0; for (PlanElement pe : person.getSelectedPlan().getPlanElements()) { if (pe instanceof Leg) { travelTime+=((Leg) pe).getTravelTime(); } } return travelTime; }
@Override public void run(final Plan plan) { for (PlanElement pe : plan.getPlanElements()) { if (pe instanceof Activity) { ((Activity) pe).setLinkId(null); } else if (pe instanceof Leg) { ((Leg) pe).setRoute(null); } } } }
@Override public void handlePlan(final Plan plan) { // Creating a dummy population which only contains the plans which are passed here. // I need to copy the plans because I am not supposed to add a plan to a different Person. // I also need to memorize the plans which are passed here, because I am supposed to mutate them. final Person personWithOnlySelectedPlan = this.exportPopulation.getFactory().createPerson(plan.getPerson().getId()); final Plan planForNewPerson = PopulationUtils.createPlan(personWithOnlySelectedPlan); PopulationUtils.copyFromTo(plan, planForNewPerson); personWithOnlySelectedPlan.addPlan(planForNewPerson); this.exportPopulation.addPerson(personWithOnlySelectedPlan); this.plansToMutate.put(plan.getPerson().getId(), plan); }
private void startRoute() { this.currroute = this.plans.getFactory().getRouteFactories().createRoute(NetworkRoute.class, this.prevAct.getLinkId(), this.prevAct.getLinkId()); this.currleg.setRoute(this.currroute); }
private int getNumberOfTrips(final Person person) { int numberOfLegs=0; for (PlanElement pe : person.getSelectedPlan().getPlanElements()) { if (pe instanceof Leg) { numberOfLegs++; } } return numberOfLegs; }
public static double decideOnTravelTimeForLeg( Leg leg ) { if ( leg.getRoute()!=null ) { return leg.getRoute().getTravelTime() ; } else { return leg.getTravelTime() ; } } public static void sampleDown( Population pop, double sample ) {
public static void resetRoutes(final Plan plan) { // loop over all <leg>s, remove route-information // routing is done after location choice for (PlanElement pe : plan.getPlanElements()) { if (pe instanceof Leg) { ((Leg) pe).setRoute(null); } } } }
public static boolean isSelected(Plan plan) { return plan.getPerson().getSelectedPlan()==plan ; } }
@Override public Double getExpectedTravelDistance() { return ((Leg) this.currentPlanElement).getRoute().getDistance(); }
public static Activity createAndAddActivityFromLinkId( Plan plan, String type, Id<Link> linkId ) { Activity act = getFactory().createActivityFromLinkId(type, linkId) ; plan.addActivity(act); act.setLinkId(linkId); return act ; }
public Activity createFinalActivity(String type, Id<Link> newLinkId) { Activity newAct = this.pf.createActivityFromLinkId(type, newLinkId);; newAct.setEndTime( Double.POSITIVE_INFINITY ) ; return newAct ; } // public Activity createAgentThatKeepsMatsimAlive( String type, Id<Link> newLinkId) {
public static Activity createAndAddActivityFromCoord( Plan plan, String type, Coord coord ) { Activity act = getFactory().createActivityFromCoord(type, coord) ; plan.addActivity(act); act.setCoord(coord); return act ; } public static Activity createAndAddActivityFromLinkId( Plan plan, String type, Id<Link> linkId ) {
@Override public String getType() { return this.delegate.getType(); } @Override
@Override public double getEndTime() { return this.delegate.getEndTime(); } @Override
@Override public Id<ActivityFacility> getFacilityId() { return this.delegate.getFacilityId(); } public EqualsActivity(final String type, final Id<Link> link) {
@Override public void setMaximumDuration(double seconds) { this.delegate.setMaximumDuration(seconds); } @Override