From 78532cfc899b89d8a00d8237ca53bb3da37ea5d1 Mon Sep 17 00:00:00 2001 From: awagner Date: Thu, 12 Oct 2023 16:29:13 +0200 Subject: [PATCH] implmented Plan as identifiable --- .../dvrp/vrpagent/VrpAgentQueryHelper.java | 4 +- .../locationchoice/zzunused/LCPlan.java | 4 +- .../distributed/plans/PlanGenome.java | 4 +- .../population/PlanWithCachedJointPlan.java | 4 +- .../matsim/api/core/v01/population/Plan.java | 8 ++- .../org/matsim/core/population/PlanImpl.java | 16 ++++-- .../core/population/PopulationUtils.java | 6 +- .../replanning/GenericPlanStrategyImpl.java | 4 +- .../inheritance/PlanInheritanceModule.java | 30 +++++----- .../inheritance/PlanInheritanceRecord.java | 13 +++-- .../PlanInheritanceRecordReader.java | 5 +- .../planInheritance/PlanInheritanceTest.java | 57 ++++++++++++------- 12 files changed, 92 insertions(+), 63 deletions(-) diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentQueryHelper.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentQueryHelper.java index ddb8d2e6f08..68d6e327ed5 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentQueryHelper.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentQueryHelper.java @@ -171,12 +171,12 @@ public void setIterationCreated(int iteration) { } @Override - public Id getPlanId() { + public Id getId() { throw new UnsupportedOperationException(); } @Override - public void setPlanId(Id planId) { + public void setPlanId(Id planId) { throw new UnsupportedOperationException(); } diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/zzunused/LCPlan.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/zzunused/LCPlan.java index f9a167cde9a..f1ba43fd0f5 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/zzunused/LCPlan.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/zzunused/LCPlan.java @@ -286,13 +286,13 @@ else if (planElement instanceof Leg) { } @Override - public void setPlanId(Id planId) { + public void setPlanId(Id planId) { throw new UnsupportedOperationException(); } @Override - public Id getPlanId() { + public Id getId() { throw new UnsupportedOperationException(); } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/plans/PlanGenome.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/plans/PlanGenome.java index 34f725fc92a..33ee42fbc42 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/plans/PlanGenome.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/plans/PlanGenome.java @@ -221,10 +221,10 @@ public void setType(final String type) { } @Override - public Id getPlanId() { return null; } + public Id getId() { return null; } @Override - public void setPlanId(Id planId) { /* nothing to do here */ } + public void setPlanId(Id planId) { /* nothing to do here */ } @Override public int getIterationCreated() { return -1; } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/population/PlanWithCachedJointPlan.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/population/PlanWithCachedJointPlan.java index ce912ec1682..5d5990a7237 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/population/PlanWithCachedJointPlan.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/population/PlanWithCachedJointPlan.java @@ -175,10 +175,10 @@ public void setType(String type) { } @Override - public Id getPlanId() { return null; } + public Id getId() { return null; } @Override - public void setPlanId(Id planId) { /* nothing to do here */ } + public void setPlanId(Id planId) { /* nothing to do here */ } @Override public int getIterationCreated() { return -1; } diff --git a/matsim/src/main/java/org/matsim/api/core/v01/population/Plan.java b/matsim/src/main/java/org/matsim/api/core/v01/population/Plan.java index 85e7775e9b9..6329b62a626 100644 --- a/matsim/src/main/java/org/matsim/api/core/v01/population/Plan.java +++ b/matsim/src/main/java/org/matsim/api/core/v01/population/Plan.java @@ -24,6 +24,7 @@ import org.matsim.api.core.v01.Customizable; import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Identifiable; import org.matsim.core.api.internal.MatsimPopulationObject; import org.matsim.utils.objectattributes.attributable.Attributable; @@ -35,7 +36,7 @@ * The only thing which is not "expected" in the same sense is the score. * */ -public interface Plan extends MatsimPopulationObject, Customizable, BasicPlan, Attributable { +public interface Plan extends MatsimPopulationObject, Customizable, BasicPlan, Attributable, Identifiable { public abstract List getPlanElements(); @@ -51,9 +52,9 @@ public interface Plan extends MatsimPopulationObject, Customizable, BasicPlan, A public abstract void setType(final String type); - public abstract void setPlanId(final Id planId); + public abstract void setPlanId(Id planId); - public abstract Id getPlanId(); + public abstract Id getId(); public abstract int getIterationCreated(); @@ -72,5 +73,6 @@ public interface Plan extends MatsimPopulationObject, Customizable, BasicPlan, A * you are using this method!. */ public abstract void setPerson(Person person); + } diff --git a/matsim/src/main/java/org/matsim/core/population/PlanImpl.java b/matsim/src/main/java/org/matsim/core/population/PlanImpl.java index 4d7f0fd0363..5a928e62ba0 100644 --- a/matsim/src/main/java/org/matsim/core/population/PlanImpl.java +++ b/matsim/src/main/java/org/matsim/core/population/PlanImpl.java @@ -28,6 +28,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Customizable; import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; @@ -40,6 +41,8 @@ /* deliberately package */ final class PlanImpl implements Plan { + private Id id= null; + private ArrayList actsLegs = new ArrayList<>(); private Double score = null; @@ -125,13 +128,16 @@ public void setType(final String type) { } @Override - public Id getPlanId() { - return (Id) this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID); + public Id getId() { + if(this.id!=null) + return this.id; + else return Id.create(this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID).toString(),Plan.class); } @Override - public void setPlanId(Id planId) { - this.getAttributes().putAttribute(PlanInheritanceModule.PLAN_ID, planId); + public void setPlanId(Id planId) { + this.getAttributes().putAttribute(PlanInheritanceModule.PLAN_ID, planId.toString()); + this.id = planId; } @Override @@ -196,6 +202,8 @@ public final Map getCustomAttributes() { return this.customizableDelegate.getCustomAttributes(); } + + // public final void setLocked() { // for ( PlanElement pe : this.actsLegs ) { // if ( pe instanceof ActivityImpl ) { diff --git a/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java b/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java index adac6f947a2..49ea0197e73 100644 --- a/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java +++ b/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java @@ -383,12 +383,12 @@ public void setType(String type) { } @Override - public Id getPlanId() { - return this.delegate.getPlanId(); + public Id getId() { + return this.delegate.getId(); } @Override - public void setPlanId(Id planId) { + public void setPlanId(Id planId) { throw new UnsupportedOperationException(); } diff --git a/matsim/src/main/java/org/matsim/core/replanning/GenericPlanStrategyImpl.java b/matsim/src/main/java/org/matsim/core/replanning/GenericPlanStrategyImpl.java index 75daefffb28..b9063b0878d 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/GenericPlanStrategyImpl.java +++ b/matsim/src/main/java/org/matsim/core/replanning/GenericPlanStrategyImpl.java @@ -93,8 +93,8 @@ public void run(final HasPlansAndId person) { // set the working plan to a copy of the selected plan: plan = person.createCopyOfSelectedPlanAndMakeSelected(); - //planId is only set inside planInheritance -> if null planInheritance is disabled - if (plan instanceof Plan && ((Plan) plan).getPlanId() != null) { + //Id is only set inside planInheritance -> if null planInheritance is disabled + if (plan instanceof Plan && ((Plan) plan).getId() != null) { // add plan inheritance flags ((Plan) plan).setIterationCreated(this.replanningContext.getIteration()); ((Plan) plan).setPlanMutator(this.toString()); diff --git a/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceModule.java b/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceModule.java index 80ef946b263..5ee3f3775ac 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceModule.java +++ b/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceModule.java @@ -37,7 +37,6 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; -import org.matsim.core.config.groups.PlanInheritanceConfigGroup; import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.events.BeforeMobsimEvent; @@ -49,7 +48,6 @@ import org.matsim.core.population.PersonUtils; import org.matsim.core.replanning.GenericPlanStrategy; import org.matsim.core.replanning.StrategyManager; -import org.matsim.core.replanning.annealing.ReplanningAnnealerConfigGroup; import org.matsim.core.utils.io.IOUtils; import com.google.inject.Singleton; @@ -75,7 +73,7 @@ public class PlanInheritanceModule extends AbstractModule implements StartupList public static final String FILENAME_PLAN_INHERITANCE_RECORDS = "planInheritanceRecords"; long numberOfPlanInheritanceRecordsCreated = 0; - Map, PlanInheritanceRecord> planId2planInheritanceRecords = new ConcurrentHashMap<>(); + Map, PlanInheritanceRecord> planId2planInheritanceRecords = new ConcurrentHashMap<>(); PlanInheritanceRecordWriter planInheritanceRecordWriter; private ArrayList strategies; @@ -96,7 +94,7 @@ public void notifyStartup(StartupEvent event) { // reset all plan attributes that might be present from a previously performed matsim run for (Person person : event.getServices().getScenario().getPopulation().getPersons().values()) { for (Plan plan : person.getPlans()) { - plan.setPlanId(Id.create(NONE, String.class)); + plan.setPlanId(Id.create(NONE, Plan.class)); plan.setPlanMutator(INITIAL_PLAN); plan.setIterationCreated(0); } @@ -157,8 +155,8 @@ private BufferedWriter initializeDistributionWriter(ArrayList strategies public void notifyBeforeMobsim(BeforeMobsimEvent event) { // check the plans of the population and all currently stored plan records - do the actual book-keeping - Set> activePlanIds = new HashSet<>(); - Set> selectedPlanIds = new HashSet<>(); + Set> activePlanIds = new HashSet<>(); + Set> selectedPlanIds = new HashSet<>(); for (Person person : event.getServices().getScenario().getPopulation().getPersons().values()) { for (Plan plan : person.getPlans()) { @@ -174,8 +172,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { PlanInheritanceRecord planInheritanceRecord = new PlanInheritanceRecord(); planInheritanceRecord.setAgentId(person.getId()); - planInheritanceRecord.setPlanId( Id.create(Long.toString(++this.numberOfPlanInheritanceRecordsCreated, 36), String.class) ); - planInheritanceRecord.setAncestorId(plan.getPlanId()); + planInheritanceRecord.setPlanId(Id.create(Long.toString(++this.numberOfPlanInheritanceRecordsCreated, 36), Plan.class)); + planInheritanceRecord.setAncestorId(plan.getId()); //works because new plan is copy of old selected and attributes are copied -> thus current attribute plan id is old selected plan id plan.setPlanId(planInheritanceRecord.getPlanId()); planInheritanceRecord.setIterationCreated(plan.getIterationCreated()); planInheritanceRecord.setMutatedBy(plan.getPlanMutator()); @@ -184,22 +182,22 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { } if (PersonUtils.isSelected(plan)) { - this.planId2planInheritanceRecords.get(plan.getPlanId()).getIterationsSelected().add(event.getIteration()); - selectedPlanIds.add(plan.getPlanId()); + this.planId2planInheritanceRecords.get(plan.getId()).getIterationsSelected().add(event.getIteration()); + selectedPlanIds.add(plan.getId()); } - activePlanIds.add(plan.getPlanId()); + activePlanIds.add(plan.getId()); } } - List> deletedPlans = new ArrayList<>(); - for (Id planId : this.planId2planInheritanceRecords.keySet()) { + List> deletedPlans = new ArrayList<>(); + for (Id planId : this.planId2planInheritanceRecords.keySet()) { if (!activePlanIds.contains(planId)) { deletedPlans.add(planId); } } - for (Id deletedPlanId : deletedPlans) { + for (Id deletedPlanId : deletedPlans) { PlanInheritanceRecord deletedPlanInheritanceRecord = this.planId2planInheritanceRecords.remove(deletedPlanId); deletedPlanInheritanceRecord.setIterationRemoved(event.getIteration()); this.planInheritanceRecordWriter.write(deletedPlanInheritanceRecord); @@ -214,12 +212,12 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { /** * Updates the default plan stats - namely the distribution of plan mutators based on the given plan ids. */ - private void calculateAndWriteDistribution(int currentIteration, ArrayList strategies, Map, PlanInheritanceRecord> planId2planInheritanceRecords, Set> planIds, BufferedWriter writer) { + private void calculateAndWriteDistribution(int currentIteration, ArrayList strategies, Map, PlanInheritanceRecord> planId2planInheritanceRecords, Set> planIds, BufferedWriter writer) { Map strategy2count = new HashMap<>(); for (String strategyName : strategies) { strategy2count.put(strategyName, new AtomicLong(0)); } - for (Id planId : planIds) { + for (Id planId : planIds) { String mutatedBy = planId2planInheritanceRecords.get(planId).getMutatedBy(); strategy2count.get(mutatedBy).incrementAndGet(); } diff --git a/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecord.java b/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecord.java index 8a3e54280ac..759e0a16961 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecord.java +++ b/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecord.java @@ -25,6 +25,7 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; +import org.matsim.api.core.v01.population.Plan; /** * Data container storing the data of a single plan. @@ -41,12 +42,12 @@ public class PlanInheritanceRecord { /** * The globally unique plan id. */ - private Id planId; + private Id planId; /** * Id of the plan that this plan had been copied from before mutating. */ - private Id ancestorId; + private Id ancestorId; /** * The name of the strategy that altered this plan. @@ -69,19 +70,19 @@ public class PlanInheritanceRecord { */ private List iterationsSelected = new ArrayList<>(1); - public Id getPlanId() { + public Id getPlanId() { return planId; } - public void setPlanId(Id planId) { + public void setPlanId(Id planId) { this.planId = planId; } - public Id getAncestorId() { + public Id getAncestorId() { return ancestorId; } - public void setAncestorId(Id ancestorId) { + public void setAncestorId(Id ancestorId) { this.ancestorId = ancestorId; } diff --git a/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecordReader.java b/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecordReader.java index a6b90fbd44e..8d83d6ef1de 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecordReader.java +++ b/matsim/src/main/java/org/matsim/core/replanning/inheritance/PlanInheritanceRecordReader.java @@ -33,6 +33,7 @@ import java.util.stream.Collectors; import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.population.Plan; import org.matsim.core.utils.io.IOUtils; /** @@ -69,8 +70,8 @@ public List read() { String[] line = lineString.split(DELIMITER); PlanInheritanceRecord planInheritanceRecord = new PlanInheritanceRecord(); planInheritanceRecord.setAgentId(Id.createPersonId(line[lookUp.get(PlanInheritanceRecordWriter.AGENT_ID)])); - planInheritanceRecord.setPlanId(Id.create(line[lookUp.get(PlanInheritanceRecordWriter.PLAN_ID)], String.class)); - planInheritanceRecord.setAncestorId(Id.create(line[lookUp.get(PlanInheritanceRecordWriter.ANCESTOR_ID)], String.class)); + planInheritanceRecord.setPlanId(Id.create(line[lookUp.get(PlanInheritanceRecordWriter.PLAN_ID)], Plan.class)); + planInheritanceRecord.setAncestorId(Id.create(line[lookUp.get(PlanInheritanceRecordWriter.ANCESTOR_ID)], Plan.class)); planInheritanceRecord.setMutatedBy(line[lookUp.get(PlanInheritanceRecordWriter.MUTATED_BY)]); planInheritanceRecord.setIterationCreated(Integer.parseInt(line[lookUp.get(PlanInheritanceRecordWriter.ITERATION_CREATED)])); planInheritanceRecord.setIterationRemoved(Integer.parseInt(line[lookUp.get(PlanInheritanceRecordWriter.ITERATION_REMOVED)])); diff --git a/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java b/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java index 56f27301f11..df351fddc3c 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.junit.Rule; @@ -11,8 +12,10 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; +import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; +import org.matsim.core.population.algorithms.PersonAlgorithm; import org.matsim.core.population.io.StreamingPopulationReader; import org.matsim.core.replanning.inheritance.PlanInheritanceModule; import org.matsim.core.replanning.inheritance.PlanInheritanceRecord; @@ -27,6 +30,7 @@ public class PlanInheritanceTest { * @author alex94263 */ + @Rule public MatsimTestUtils util = new MatsimTestUtils(); @@ -46,33 +50,42 @@ public void testPlanInheritanceEnabled() throws IOException { assertThat(csv).exists(); + List personList = new ArrayList(); final Scenario scenario = ScenarioUtils.createScenario(config); - StreamingPopulationReader streamingPopulationReader = new StreamingPopulationReader(scenario); - streamingPopulationReader.readFile(util.getOutputDirectory()+"output_plans.xml.gz"); - for(Person p : scenario.getPopulation().getPersons().values()) { + StreamingPopulationReader spr = new StreamingPopulationReader(scenario); + spr.addAlgorithm(new PersonAlgorithm() { + @Override + public void run(Person person) { + personList.add(person); + } + }); + spr.readFile(util.getOutputDirectory()+"output_plans.xml.gz"); + for(Person per : personList) { + for(Plan p : per.getPlans()) { + assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_MUTATOR)); + assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.ITERATION_CREATED)); + assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_ID)); + } - assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_ID)); - assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_MUTATOR)); - assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.ITERATION_CREATED)); } PlanInheritanceRecordReader reader = new PlanInheritanceRecordReader(outputDirectory+"planInheritanceRecords.csv.gz"); List records = reader.read(); assert(records.size()==2); assert( ((PlanInheritanceRecord) records.get(0)).getAgentId().equals(Id.createPersonId("1"))); - assert( ((PlanInheritanceRecord) records.get(0)).getAncestorId().equals(Id.create("NONE",String.class))); + assert( ((PlanInheritanceRecord) records.get(0)).getAncestorId().equals(Id.create("NONE",Plan.class))); assert( ((PlanInheritanceRecord) records.get(0)).getMutatedBy().equals(PlanInheritanceModule.INITIAL_PLAN)); assert( ((PlanInheritanceRecord) records.get(0)).getIterationCreated() == 0); assert( ((PlanInheritanceRecord) records.get(0)).getIterationRemoved() == 0); - assert( ((PlanInheritanceRecord) records.get(0)).getPlanId().equals(Id.create("1",String.class))); + assert( ((PlanInheritanceRecord) records.get(0)).getPlanId().equals(Id.create("1",Plan.class))); assert( ((PlanInheritanceRecord) records.get(0)).getIterationsSelected().equals(Arrays.asList(0, 1, 2, 3, 4, 6, 7, 8, 9, 10))); assert( ((PlanInheritanceRecord) records.get(1)).getAgentId().equals(Id.createPersonId("1"))); - assert( ((PlanInheritanceRecord) records.get(1)).getAncestorId().equals(Id.create("1",String.class))); + assert( ((PlanInheritanceRecord) records.get(1)).getAncestorId().equals(Id.create("1",Plan.class))); assert( ((PlanInheritanceRecord) records.get(1)).getMutatedBy().equals("RandomPlanSelector_ReRoute")); assert( ((PlanInheritanceRecord) records.get(1)).getIterationCreated() == 5); assert( ((PlanInheritanceRecord) records.get(1)).getIterationRemoved() == 0); - assert( ((PlanInheritanceRecord) records.get(1)).getPlanId().equals(Id.create("2",String.class))); + assert( ((PlanInheritanceRecord) records.get(1)).getPlanId().equals(Id.create("2",Plan.class))); assert( ((PlanInheritanceRecord) records.get(1)).getIterationsSelected().equals(Arrays.asList(5))); @@ -94,17 +107,23 @@ public void testPlanInheritanceDisabled() throws IOException { assertThat(csv).doesNotExist(); - + List personList = new ArrayList(); final Scenario scenario = ScenarioUtils.createScenario(config); - StreamingPopulationReader streamingPopulationReader = new StreamingPopulationReader(scenario); - streamingPopulationReader.readFile(util.getOutputDirectory()+"output_plans.xml.gz"); - for(Person p : scenario.getPopulation().getPersons().values()) { + StreamingPopulationReader spr = new StreamingPopulationReader(scenario); + spr.addAlgorithm(new PersonAlgorithm() { + @Override + public void run(Person person) { + personList.add(person); + } + }); + spr.readFile(util.getOutputDirectory()+"output_plans.xml.gz"); + for(Person per : personList) { + for(Plan p : per.getPlans()) { + assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_MUTATOR)); + assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.ITERATION_CREATED)); + assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_ID)); + } - assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_ID)); - assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_MUTATOR)); - assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.ITERATION_CREATED)); } - - } }