Skip to content

Commit

Permalink
fix: set all scores to null initially (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschlenther authored Sep 1, 2023
1 parent 2b683ed commit edb3671
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.population.*;
import org.matsim.contrib.common.util.StraightLineKnnFinder;
import org.matsim.core.gbl.MatsimRandom;
import org.matsim.core.network.algorithms.MultimodalNetworkCleaner;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.population.routes.NetworkRoute;
Expand Down Expand Up @@ -139,7 +138,7 @@ static void prepareInputPlansForCarProhibitionWithPRLogic(Scenario scenario,
PopulationFactory fac = scenario.getPopulation().getFactory();
MutableInt replacedTrips = new MutableInt();

Random rnd = MatsimRandom.getRandom();
Random rnd = new Random(4711);

StraightLineKnnFinder<Activity,PRStation> straightLineKnnFinder = new StraightLineKnnFinder<>(kPrStations, Activity::getCoord, PRStation::getCoord);
log.warn("will assume that the first activity of each person is the home activity. This holds true for the open Berlin scenario. For other scenarios, please check !!");
Expand All @@ -162,6 +161,9 @@ static void prepareInputPlansForCarProhibitionWithPRLogic(Scenario scenario,

for (Plan plan : person.getPlans()) {

//we (sometimes) make plan copies. remove all scores values, thus ensure that all plans are executed at least once.
plan.setScore(null);

//will in fact put an attribute into the origin activity
List<TripStructureUtils.Trip> tripsToReplace = collectAndAttributeTripsToReplace(scenario, plan, mainModeIdentifier, Set.of(TransportMode.car, TransportMode.ride), carFreeGeoms);
if (tripsToReplace.isEmpty()){
Expand Down Expand Up @@ -329,9 +331,10 @@ static void prepareInputPlansForCarProhibitionWithPRLogic(Scenario scenario,
}
//after we've iterated over existing plans, add all the plan copies
plansToAdd.forEach(plan -> person.addPlan(plan));
}
//TODO iterate over all plans, set score to null !!

//select random plan
person.setSelectedPlan(person.getPlans().get(rnd.nextInt(person.getPlans().size())));
}

log.info("overall nr of trips replaced = " + replacedTrips);
log.info("finished modifying input plans....");
Expand Down

0 comments on commit edb3671

Please sign in to comment.