/** * Returns the score of a single agent. This method only returns useful * values if the method {@link #finish() } was called before. description * * @param agentId * The id of the agent the score is requested for. * @return The score of the specified agent. */ public Double getAgentScore(final Id<Person> agentId) { if (!finished) { throw new IllegalStateException("Must call finish first."); } ScoringFunction scoringFunction = scoringFunctionsForPopulation.getScoringFunctionForAgent(agentId); if (scoringFunction == null) return null; return scoringFunction.getScore(); }
@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()); } } } }
public void finishScoringFunctions() { // Rethrow an exception in a scoring function (user code) if there was one. Throwable throwable = this.exception.get(); if (throwable != null) { if (throwable instanceof RuntimeException) { throw ((RuntimeException) throwable); } else { throw new RuntimeException(throwable); } } for (ScoringFunction sf : this.agentScorers.values()) { sf.finish(); } for (Entry<Id<Person>, TDoubleCollection> entry : this.partialScores.entrySet()) { entry.getValue().add(this.getScoringFunctionForAgent(entry.getKey()).getScore()); } }
@Override synchronized public void handleLeg(PersonExperiencedLeg o) { Id<Person> agentId = o.getAgentId(); Leg leg = o.getLeg(); ScoringFunction scoringFunction = ScoringFunctionsForPopulation.this.getScoringFunctionForAgent(agentId); if (scoringFunction != null) { scoringFunction.handleLeg(leg); TDoubleCollection partialScoresForAgent = this.partialScores.get(agentId); partialScoresForAgent.add(scoringFunction.getScore()); } Plan plan = this.tripRecords.get( agentId ) ; // as container for trip if ( plan!=null ) { plan.addLeg( leg ); } }
ScoringFunction sf = scoringFunctionsForPopulation.getScoringFunctionForAgent(person.getId()); double score = sf.getScore(); Plan plan = person.getSelectedPlan();
Id<Person> agentId = o.getAgentId(); Activity activity = o.getActivity(); ScoringFunction scoringFunction = ScoringFunctionsForPopulation.this.getScoringFunctionForAgent(agentId); if (scoringFunction != null) { scoringFunction.handleActivity(activity);
ScoringFunction scoringFunction = getScoringFunctionForAgent(((HasPersonId) o).getPersonId()); if (scoringFunction != null) { if (o instanceof PersonStuckEvent) { Id<Vehicle> vehicleId = ((LinkEnterEvent)o).getVehicleId() ; Id<Person> driverId = this.vehicles2Drivers.getDriverOfVehicle(vehicleId) ; ScoringFunction scoringFunction = getScoringFunctionForAgent( driverId );
ScoringFunction s = sf.getScoringFunctionForAgent(personId); Assert.assertEquals(RecordingScoringFunction.class, s.getClass()); RecordingScoringFunction rs = (RecordingScoringFunction) s;
assertEquals(1.0/6.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0);
assertEquals(1.0/6.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0);