-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2831 from matsim-org/addingPlanInheritance
Adding plan inheritance
- Loading branch information
Showing
16 changed files
with
990 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
matsim/src/main/java/org/matsim/core/config/groups/PlanInheritanceConfigGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* *********************************************************************** * | ||
* project: org.matsim.* | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* copyright : (C) 2011 by the members listed in the COPYING, * | ||
* LICENSE and WARRANTY file. * | ||
* email : info at matsim dot org * | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* See also COPYING, LICENSE and WARRANTY file * | ||
* * | ||
* *********************************************************************** */ | ||
|
||
package org.matsim.core.config.groups; | ||
|
||
import java.util.Map; | ||
|
||
import org.matsim.core.config.ReflectiveConfigGroup; | ||
|
||
/** | ||
* @author awagner | ||
*/ | ||
public final class PlanInheritanceConfigGroup extends ReflectiveConfigGroup { | ||
|
||
public static final String GROUP_NAME = "planInheritance"; | ||
|
||
private static final String ENABLED = "enabled"; | ||
|
||
private boolean enabled = false; | ||
|
||
public PlanInheritanceConfigGroup() { | ||
super(GROUP_NAME); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getComments() { | ||
Map<String, String> comments = super.getComments(); | ||
comments.put(ENABLED, "Specifies whether or not PlanInheritance Information should be tracked."); | ||
return comments; | ||
} | ||
|
||
|
||
@StringSetter( ENABLED ) | ||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
|
||
@StringGetter( ENABLED ) | ||
public boolean getEnabled() { | ||
return this.enabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,17 +27,22 @@ | |
import org.apache.logging.log4j.LogManager; | ||
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; | ||
import org.matsim.api.core.v01.population.Plan; | ||
import org.matsim.api.core.v01.population.PlanElement; | ||
import org.matsim.core.replanning.inheritance.PlanInheritanceModule; | ||
import org.matsim.core.scenario.CustomizableUtils; | ||
import org.matsim.utils.objectattributes.attributable.Attributes; | ||
import org.matsim.utils.objectattributes.attributable.AttributesImpl; | ||
|
||
/* deliberately package */ final class PlanImpl implements Plan { | ||
|
||
private Id<Plan> id= null; | ||
|
||
private ArrayList<PlanElement> actsLegs = new ArrayList<>(); | ||
|
||
private Double score = null; | ||
|
@@ -121,6 +126,44 @@ public String getType() { | |
public void setType(final String type) { | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public Id<Plan> getId() { | ||
if(this.id!=null) | ||
return this.id; | ||
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 | ||
public void setPlanId(Id<Plan> planId) { | ||
this.getAttributes().putAttribute(PlanInheritanceModule.PLAN_ID, planId.toString()); | ||
this.id = planId; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mrieser
Contributor
|
||
} | ||
|
||
@Override | ||
public int getIterationCreated() { | ||
return (int) this.getAttributes().getAttribute(PlanInheritanceModule.ITERATION_CREATED); | ||
} | ||
|
||
@Override | ||
public void setIterationCreated(int iteration) { | ||
this.getAttributes().putAttribute(PlanInheritanceModule.ITERATION_CREATED, iteration); | ||
} | ||
|
||
@Override | ||
public String getPlanMutator() { | ||
return (String) this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_MUTATOR); | ||
} | ||
|
||
@Override | ||
public void setPlanMutator(String planMutator) { | ||
this.getAttributes().putAttribute(PlanInheritanceModule.PLAN_MUTATOR, planMutator); | ||
} | ||
|
||
@Override | ||
public final List<PlanElement> getPlanElements() { | ||
|
@@ -164,6 +207,8 @@ public final Map<String, Object> getCustomAttributes() { | |
return this.customizableDelegate.getCustomAttributes(); | ||
} | ||
|
||
|
||
|
||
// public final void setLocked() { | ||
// for ( PlanElement pe : this.actsLegs ) { | ||
// if ( pe instanceof ActivityImpl ) { | ||
|
Oops, something went wrong.
Why is the planId stored in the attributes and directly as a class-member? Shouldn't one be enough?