diff --git a/matsim/src/main/java/org/matsim/core/config/Config.java b/matsim/src/main/java/org/matsim/core/config/Config.java index a409e64d579..e6ee24c19be 100644 --- a/matsim/src/main/java/org/matsim/core/config/Config.java +++ b/matsim/src/main/java/org/matsim/core/config/Config.java @@ -45,6 +45,7 @@ import org.matsim.core.config.groups.HouseholdsConfigGroup; import org.matsim.core.config.groups.LinkStatsConfigGroup; import org.matsim.core.config.groups.NetworkConfigGroup; +import org.matsim.core.config.groups.PlanInheritanceConfigGroup; import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.RoutingConfigGroup;import org.matsim.core.config.groups.PlansConfigGroup; 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 5a928e62ba0..8477a25b7dc 100644 --- a/matsim/src/main/java/org/matsim/core/population/PlanImpl.java +++ b/matsim/src/main/java/org/matsim/core/population/PlanImpl.java @@ -131,7 +131,12 @@ public void setType(final String type) { public Id getId() { if(this.id!=null) return this.id; - else return Id.create(this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID).toString(),Plan.class); + else { + if(this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID)!=null) + return Id.create(this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID).toString(),Plan.class); + else return null; + } + } @Override 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 5ee3f3775ac..0a0a48f961d 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 @@ -36,8 +36,8 @@ import org.matsim.api.core.v01.Id; 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.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.events.BeforeMobsimEvent; import org.matsim.core.controler.events.ShutdownEvent; @@ -85,9 +85,9 @@ public class PlanInheritanceModule extends AbstractModule implements StartupList @Override public void notifyStartup(StartupEvent event) { // initialize all default writers - CompressionType compressionType = event.getServices().getConfig().controler().getCompressionType(); + CompressionType compressionType = event.getServices().getConfig().controller().getCompressionType(); this.planInheritanceRecordWriter = new PlanInheritanceRecordWriter(event.getServices().getControlerIO().getOutputFilename(FILENAME_PLAN_INHERITANCE_RECORDS + ".csv", compressionType)); - this.strategies = this.getActiveStrategies(event.getServices().getConfig().strategy().getStrategySettings(), event.getServices().getStrategyManager()); + this.strategies = this.getActiveStrategies(event.getServices().getConfig().replanning().getStrategySettings(), event.getServices().getStrategyManager()); this.selectedPlanStrategyShareWriter = this.initializeDistributionWriter(this.strategies, event.getServices().getControlerIO().getOutputFilename(FILENAME_PLAN_INHERITANCE_RECORDS + "_shares_selected.csv")); this.planStrategyShareWriter = this.initializeDistributionWriter(this.strategies, event.getServices().getControlerIO().getOutputFilename(FILENAME_PLAN_INHERITANCE_RECORDS + "_shares.csv")); 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 759e0a16961..7212f337896 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 @@ -62,7 +62,7 @@ public class PlanInheritanceRecord { /** * Iteration in which the plan had been removed from the choice-set. */ - private int iterationRemoved; + private int iterationRemoved = -1; /** * Collection of iterations this plan had been the selected plan. 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 df351fddc3c..c15436d3391 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 @@ -39,8 +39,8 @@ public void testPlanInheritanceEnabled() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(10); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setLastIteration(10); + config.controller().setOutputDirectory(outputDirectory); config.planInheritance().setEnabled(true); Controler c = new Controler(config); @@ -76,7 +76,7 @@ public void run(Person person) { 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)).getIterationRemoved() == -1); 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))); @@ -84,7 +84,7 @@ public void run(Person person) { 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)).getIterationRemoved() == -1); assert( ((PlanInheritanceRecord) records.get(1)).getPlanId().equals(Id.create("2",Plan.class))); assert( ((PlanInheritanceRecord) records.get(1)).getIterationsSelected().equals(Arrays.asList(5))); @@ -97,8 +97,8 @@ public void testPlanInheritanceDisabled() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(1); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setLastIteration(1); + config.controller().setOutputDirectory(outputDirectory); Controler c = new Controler(config); c.run();