@Override protected double calcStat(final Plan plan) { final Double score = plan.getScore(); return score == null ? Double.NaN : score; }
@Override public double getWeight( final Plan indivPlan, final ReplanningGroup group) { Double score = indivPlan.getScore(); // if there are unscored plan, one of them is selected return score == null ? Double.POSITIVE_INFINITY : score; } }
@Override public double getWeight( final Plan indivPlan, final ReplanningGroup group) { Double score = indivPlan.getScore(); // if there is a plan without score, select it return score == null ? Double.POSITIVE_INFINITY : -score; } }
@Override public Double getScore() { return delegate.getScore(); }
@Override public Double getScore() { return this.delegate.getScore(); }
@Override public void startPlan(final Plan plan, final BufferedWriter out) throws IOException { out.write("\t\t<plan"); if (plan.getScore() != null) out.write(" score=\"" + plan.getScore().toString() + "\""); if (PersonUtils.isSelected(plan)) out.write(" selected=\"" + "yes" + "\""); else out.write(" selected=\"" + "no" + "\""); out.write(">\n"); }
private static double getScore(final Person p) { final Double score = p.getSelectedPlan().getScore(); if ( score == null ) throw new NullPointerException( "got null score for person "+p ); if ( score.isNaN() ) throw new RuntimeException( "got NaN score for person "+p ); return score.doubleValue(); }
private static void startPlan(final Plan plan, final BufferedWriter out) throws IOException { out.write("\t\t<plan"); if (plan.getScore() != null) { out.write(" score=\""); out.write(plan.getScore().toString()); out.write("\""); } if (PersonUtils.isSelected(plan)) out.write(" selected=\"yes\""); else out.write(" selected=\"no\""); if ((plan.getType() != null)) { out.write(" type=\""); out.write(plan.getType()); out.write("\""); } out.write(">\n"); }
@Override public void startPlan(final Plan plan, final BufferedWriter out) throws IOException { out.write("\t\t<plan"); if (plan.getScore() != null) { out.write(" score=\""); out.write(plan.getScore().toString()); out.write("\""); } if (PersonUtils.isSelected(plan)) out.write(" selected=\"yes\""); else out.write(" selected=\"no\""); if ((plan.getType() != null)) { out.write(" type=\""); out.write(plan.getType()); out.write("\""); } out.write(">\n"); }
@Override public final void finishIteration() { // I separated this from "writeExperiencedPlans" so that it can be called separately even when nothing is written. Can't say // if the design might be better served by an iteration ends listener. kai, feb'17 for (Map.Entry<Id<Person>, Plan> entry : this.agentRecords.entrySet()) { Plan plan = entry.getValue(); if (scoringFunctionsForPopulation != null) { plan.setScore(scoringFunctionsForPopulation.getScoringFunctionForAgent(entry.getKey()).getScore()); if (plan.getScore().isNaN()) { log.warn("score is NaN; plan:" + plan.toString()); } } } }
@Override public String toString() { return "{PlanRecord: "+plan.getPerson().getId()+":"+plan.getScore()+ " linkedWith:"+(jointPlan == null ? "[]" : jointPlan.getIndividualPlans().keySet())+ " linkedPlansSize:"+linkedPlans.size()+ " weight="+avgJointPlanWeight+ " isFeasible="+isStillFeasible+"}"; }
private void evaluateAndAdaptPlans(Plan plan, Plan bestPlanSoFar, ChoiceSet cs, ScoringFunctionFactory scoringFunction) { double score = this.computeScoreAndAdaptPlan(plan, cs, scoringFunction); // System.err.println("expected score of new plan is: " + score ) ; // System.err.println("existing score of old plan is: " + bestPlanSoFar.getScore() ) ; if (score > bestPlanSoFar.getScore() + 0.0000000000001) { // plan.setScore(score); // bestPlanSoFar.getPlanElements().clear(); // ((PlanImpl) bestPlanSoFar).copyFrom(plan); Plan source = plan; Plan destination = bestPlanSoFar; PlanUtils.copyFrom(source, destination); } }
@Override public String toString() { return "{PlanRecord: "+plan.getPerson().getId()+":"+plan.getScore()+ " linkedWith:"+(jointPlan == null ? "[]" : jointPlan.getIndividualPlans().keySet())+ " weight="+individualPlanWeight+ " isFeasible="+isStillFeasible+"}"; } }
public PlanSerializable(Plan plan) { planElements = new ArrayList<>(); for (PlanElement planElement : plan.getPlanElements()) if (planElement instanceof Activity) planElements.add(new ActivitySerializable((Activity) planElement)); else planElements.add(new LegSerializable((Leg) planElement)); personId = plan.getPerson().getId().toString(); score = plan.getScore(); // score = 0.0; type = plan.getType(); if (plan instanceof PlanGenome) { PlanGenome planGenome = (PlanGenome) plan; genome = planGenome.getGenome(); pSimScore = planGenome.getpSimScore(); scoreComponents = planGenome.getScoreComponents(); } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { //only for psim iterations if (this.isQSimIteration()) return; for (Person person : scenario.getPopulation().getPersons().values()) { plancatcher.removeExistingPlanOrAddNewPlan(person.getSelectedPlan()); } selectedPlanScoreMemory = new HashMap<>(scenario.getPopulation().getPersons().size()); for (Person person : scenario.getPopulation().getPersons().values()) { selectedPlanScoreMemory.put(person.getId(), person.getSelectedPlan().getScore()); } for (Plan plan : plancatcher.getPlansForPSim()) { selectedPlanScoreMemory.remove(plan.getPerson().getId()); } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { selectedPlanScoreMemory = new HashMap<>(scenario.getPopulation().getPersons().size()); if (event.getIteration() == 0) { plancatcher.init(); for (Person person : scenario.getPopulation().getPersons().values()) { plancatcher.addPlansForPsim(person.getSelectedPlan()); } } else { for (Person person : scenario.getPopulation().getPersons().values()) { selectedPlanScoreMemory.put(person.getId(), person.getSelectedPlan().getScore()); } for (Plan plan : plancatcher.getPlansForPSim()) { selectedPlanScoreMemory.remove(plan.getPerson().getId()); } } executedPlanCount += plancatcher.getPlansForPSim().size(); }
/** loads a copy of an existing plan, but keeps the person reference * * @param in a plan who's data will be loaded into this plan * @param out **/ public static void copyFromTo(final Plan in, Plan out) { out.getPlanElements().clear(); out.setScore(in.getScore()); out.setType(in.getType()); for (PlanElement pe : in.getPlanElements()) { if (pe instanceof Activity) { out.getPlanElements().add(createActivity((Activity) pe)); } else if (pe instanceof Leg) { out.getPlanElements().add( createLeg( (Leg) pe ) ) ; } else { throw new IllegalArgumentException("unrecognized plan element type discovered"); } } AttributesUtils.copyAttributesFromTo(in, out ); }