本文整理了Java中org.matsim.api.core.v01.population.Population.getPersonAttributes()
方法的一些代码示例,展示了Population.getPersonAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Population.getPersonAttributes()
方法的具体详情如下:
包路径:org.matsim.api.core.v01.population.Population
类名称:Population
方法名:getPersonAttributes
暂无
代码示例来源:origin: matsim-org/matsim
@Override
public ObjectAttributes getPersonAttributes() {
return population.getPersonAttributes();
}
代码示例来源:origin: matsim-org/matsim
@Override public ObjectAttributes getPersonAttributes() {
return delegate.getPersonAttributes();
}
代码示例来源:origin: matsim-org/matsim
@Inject
SubpopulationScoringParameters(PlansConfigGroup plansConfigGroup, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, ScenarioConfigGroup scenarioConfigGroup, Population population, TransitConfigGroup transitConfigGroup) {
this.config = planCalcScoreConfigGroup;
this.scConfig = scenarioConfigGroup;
this.transitConfigGroup = transitConfigGroup;
this.personAttributes = population.getPersonAttributes();
this.subpopulationAttributeName = plansConfigGroup.getSubpopulationAttributeName();
}
代码示例来源:origin: matsim-org/matsim
private void add(Id<Person> id, double val, final String attributeName) {
final ObjectAttributes pAttribs = this.scenario.getPopulation().getPersonAttributes();
Double oldVal = (Double) pAttribs.getAttribute( id.toString(), attributeName) ;
double newVal = val ;
if ( oldVal!=null ) {
newVal += oldVal ;
}
pAttribs.putAttribute( id.toString(), attributeName, newVal ) ;
}
代码示例来源:origin: matsim-org/matsim
/**
* Randomly chooses for each person of the population a strategy and uses that
* strategy on the person.
*
*/
public final void run(final Population population, final ReplanningContext replanningContext) {
beforePopulationRunHook(population, replanningContext);
delegate.run(population.getPersons().values(), population.getPersonAttributes(), replanningContext);
afterRunHook(population);
}
代码示例来源:origin: matsim-org/matsim
private static String identifySubpopulation(
final ReplanningGroup g,
final Scenario sc) {
final String attName = sc.getConfig().plans().getSubpopulationAttributeName();
final ObjectAttributes atts = sc.getPopulation().getPersonAttributes();
String name = null;
for ( Person p : g.getPersons() ) {
final String persSubPop = (String) atts.getAttribute( p.getId().toString() , attName );
if ( persSubPop == null && name != null ) throw new RuntimeException( "inconsistent subpopulations in group "+g );
if ( name != null && !name.equals( persSubPop ) ) throw new RuntimeException( "inconsistent subpopulations in group "+g );
name = persSubPop;
}
return name;
}
代码示例来源:origin: matsim-org/matsim
public static double getTypicalDuration(
final Scenario scenario,
final Person person,
final String type ) {
final Double typicalDuration =
(Double) scenario.getPopulation().getPersonAttributes().getAttribute(
person.getId().toString(),
"typicalDuration_"+type );
if ( typicalDuration != null ) return typicalDuration.doubleValue();
final ActivityParams params = scenario.getConfig().planCalcScore().getActivityParams( type );
if ( params == null ) {
//throw new RuntimeException( "could not find typical duration for Person "+person.getId()+" for type "+type );
// not that nice, but needed for agents that might not have a preference. BeingTogetherScoring knows how to handle that
return Double.NEGATIVE_INFINITY;
}
return params.getTypicalDuration();
}
代码示例来源:origin: matsim-org/matsim
private String getSubpopName(Person person) {
return "yy_" + getSubpopName( person.getId(), this.population.getPersonAttributes(), this.scenario.getConfig().plans().getSubpopulationAttributeName() ) ;
}
public static final String getSubpopName( Id<Person> personId, ObjectAttributes personAttributes, String subpopAttrName ) {
代码示例来源:origin: matsim-org/matsim
@Override
public void reset(final int iteration) {
delegate.reset(iteration);
this.agentDepartures.clear();
this.agentLegs.clear();
for ( StatType type : StatType.values() ) {
this.statsContainer.get(type).clear() ;
if ( this.sumsContainer.get(type)==null ) {
this.sumsContainer.put( type, new DataMap<String>() ) ;
}
this.sumsContainer.get(type).clear() ;
}
for ( Person person : this.scenario.getPopulation().getPersons().values() ) {
ObjectAttributes attribs = this.scenario.getPopulation().getPersonAttributes() ;
attribs.putAttribute( person.getId().toString(), TRAV_TIME, 0. ) ;
if ( attribs.getAttribute( person.getId().toString(), CERTAIN_LINKS_CNT ) != null ) {
attribs.putAttribute( person.getId().toString(), CERTAIN_LINKS_CNT, 0. ) ;
}
if ( attribs.getAttribute( person.getId().toString(), PAYMENTS) != null ) {
attribs.putAttribute( person.getId().toString(), PAYMENTS, 0. ) ;
}
}
// (yy not sure if I like the above; might be better to just use a local data structure. kai, may'14)
controlStatisticsSum = 0. ;
controlStatisticsCnt = 0. ;
}
代码示例来源:origin: matsim-org/matsim
public TimeAllocationMutator(Provider<TripRouter> tripRouterProvider, PlansConfigGroup plansConfigGroup, TimeAllocationMutatorConfigGroup timeAllocationMutatorConfigGroup, GlobalConfigGroup globalConfigGroup,
final Population population) {
super(globalConfigGroup);
this.tripRouterProvider = tripRouterProvider;
this.activityDurationInterpretation = plansConfigGroup.getActivityDurationInterpretation();
this.mutationRange = timeAllocationMutatorConfigGroup.getMutationRange();
this.affectingDuration = timeAllocationMutatorConfigGroup.isAffectingDuration();
// in case we have subpopulations and individual settings for them
if (plansConfigGroup.getSubpopulationAttributeName() != null && timeAllocationMutatorConfigGroup.isUseIndividualSettingsForSubpopulations() && population != null) {
this.subpopulationAttribute = plansConfigGroup.getSubpopulationAttributeName();
this.subpopulationMutationRanges = new HashMap<>();
this.subpopulationAffectingDuration = new HashMap<>();
this.personAttributes = population.getPersonAttributes();
Collection<? extends ConfigGroup> settings = timeAllocationMutatorConfigGroup.getParameterSets(TimeAllocationMutatorSubpopulationSettings.SET_NAME);
for (ConfigGroup group : settings) {
TimeAllocationMutatorSubpopulationSettings subpopulationSettings = (TimeAllocationMutatorSubpopulationSettings) group;
String subpopulation = subpopulationSettings.getSubpopulation();
this.subpopulationMutationRanges.put(subpopulation, subpopulationSettings.getMutationRange());
this.subpopulationAffectingDuration.put(subpopulation, subpopulationSettings.isAffectingDuration());
log.info("Found individual time mutator settings for subpopulation: " + subpopulation);
}
} else {
this.personAttributes = null;
this.subpopulationAttribute = null;
this.subpopulationMutationRanges = null;
this.subpopulationAffectingDuration = null;
}
}
代码示例来源:origin: matsim-org/matsim
@Override
public void run(HasPlansAndId<Plan, Person> person) {
counter.incCounter();
Assert.assertNull(
"unexpected subpopulation",
population.getPersonAttributes().getAttribute(
person.getId().toString(),
SUBPOP_ATT_NAME) );
}
代码示例来源:origin: matsim-org/matsim
@Override
public void run(HasPlansAndId<Plan, Person> person) {
counter.incCounter();
Assert.assertEquals(
"unexpected subpopulation",
POP_NAME_1,
population.getPersonAttributes().getAttribute(
person.getId().toString(),
SUBPOP_ATT_NAME) );
}
代码示例来源:origin: matsim-org/matsim
@Override
public void run(HasPlansAndId<Plan, Person> person) {
counter.incCounter();
Assert.assertEquals(
"unexpected subpopulation",
POP_NAME_2,
population.getPersonAttributes().getAttribute(
person.getId().toString(),
SUBPOP_ATT_NAME) );
}
代码示例来源:origin: matsim-org/matsim
public Builder(
final Scenario scenario,
final Id<Person> person ) {
this(
scenario.getConfig().planCalcScore(),
scenario.getConfig().planCalcScore().getScoringParameters(
(String)
scenario.getPopulation().getPersonAttributes().getAttribute(
person.toString(),
scenario.getConfig().plans().getSubpopulationAttributeName() ) ),
scenario.getConfig().scenario() );
}
代码示例来源:origin: matsim-org/matsim
public final void positionAgentGivenDistanceFromFNode(final Collection<AgentSnapshotInfo> positions, Coord startCoord, Coord endCoord,
double lengthOfCurve, QVehicle veh, double distanceFromFromNode,
Integer lane, double speedValueBetweenZeroAndOne){
// I think that the main reason why this exists as public method is that AssignmentEmulatingQLane wants to use it directly.
// The reason for this, in return, is that positionVehiclesAlongLine(...) is a service method for queue models only. kai, apr'16
MobsimDriverAgent driverAgent = veh.getDriver();
AgentSnapshotInfo pos = snapshotInfoFactory.createAgentSnapshotInfo(driverAgent.getId(), startCoord, endCoord,
distanceFromFromNode, lane, lengthOfCurve);
pos.setColorValueBetweenZeroAndOne(speedValueBetweenZeroAndOne);
if (driverAgent instanceof TransitDriverAgent){
pos.setAgentState(AgentState.TRANSIT_DRIVER);
} else if ( driverAgent.getMode().equals(TransportMode.car)) {
pos.setAgentState(AgentState.PERSON_DRIVING_CAR);
} else {
pos.setAgentState(AgentState.PERSON_OTHER_MODE );
}
if ( scenario.getPopulation().getPersonAttributes().getAttribute( driverAgent.getId().toString(), "marker" ) != null ) {
pos.setAgentState( AgentState.PERSON_OTHER_MODE ) ;
}
this.positionPassengers(positions, veh.getPassengers(), distanceFromFromNode, startCoord,
endCoord, lengthOfCurve, lane+5, speedValueBetweenZeroAndOne);
// (this is deliberately first memorizing "pos" but then filling in the passengers first)
positions.add(pos);
}
代码示例来源:origin: matsim-org/matsim
private void dumpPlans() {
// dump plans
final PopulationWriter writer = new PopulationWriter(population, network);
writer.putAttributeConverters( attributeConverters );
writer.write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_POPULATION));
final ObjectAttributes personAttributes = population.getPersonAttributes();
if ( personAttributes!=null ) {
ObjectAttributesXmlWriter attributesXmlWriter = new ObjectAttributesXmlWriter(personAttributes) ;
attributesXmlWriter.setPrettyPrint(true);
attributesXmlWriter.putAttributeConverters( attributeConverters );
attributesXmlWriter.writeFile( controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_PERSON_ATTRIBUTES ) );
}
}
代码示例来源:origin: matsim-org/matsim
@Override
public GroupLevelPlanSelector createSelector() {
final GroupReplanningConfigGroup weights = (GroupReplanningConfigGroup)
sc.getConfig().getModule(
GroupReplanningConfigGroup.GROUP_NAME );
return new HighestWeightSelector(
true ,
incompatiblePlansIdentifierFactory,
new WeightedWeight(
new InverseScoreWeight(),
weights.getWeightAttributeName(),
sc.getPopulation().getPersonAttributes() ));
}
}
代码示例来源:origin: matsim-org/matsim
private void loadPopulation() {
if ((this.config.plans() != null) && (this.config.plans().getInputFile() != null)) {
URL populationFileName = this.config.plans().getInputFileURL(this.config.getContext());
log.info("loading population from " + populationFileName);
final String targetCRS = config.global().getCoordinateSystem();
final String internalCRS = config.global().getCoordinateSystem();
final PopulationReader reader = new PopulationReader(targetCRS, internalCRS, this.scenario);
reader.putAttributeConverters( attributeConverters );
reader.parse( populationFileName );
PopulationUtils.printPlansCount(this.scenario.getPopulation()) ;
}
else {
log.info("no population file set in config, not able to load population");
}
if ((this.config.plans() != null) && (this.config.plans().getInputPersonAttributeFile() != null)) {
URL personAttributesURL = this.config.plans().getInputPersonAttributeFileURL(this.config.getContext());
log.info("loading person attributes from " + personAttributesURL);
ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(this.scenario.getPopulation().getPersonAttributes());
reader.putAttributeConverters( attributeConverters );
reader.parse(personAttributesURL);
}
else {
log.info("no person-attributes file set in config, not loading any person attributes");
}
}
代码示例来源:origin: matsim-org/matsim
@Override
public GroupLevelPlanSelector createSelector() {
final GroupReplanningConfigGroup configGroup = (GroupReplanningConfigGroup)
sc.getConfig().getModule(
GroupReplanningConfigGroup.GROUP_NAME );
return
new HighestWeightSelector(
incompatiblePlansIdentifierFactory ,
new WeightedWeight(
new LogitWeight(
MatsimRandom.getLocalInstance(),
sc.getConfig().planCalcScore().getBrainExpBeta()),
configGroup.getWeightAttributeName(),
sc.getPopulation().getPersonAttributes() ) );
}
代码示例来源:origin: matsim-org/matsim
@Test
public void testLoadScenario_loadPersonAttributes() {
Config config = ConfigUtils.loadConfig(IOUtils.newUrl(this.util.classInputResourcePath(), "personAttributesConfig.xml"));
config.plans().addParam("inputPersonAttributesFile", "personAttributes.xml");
Scenario scenario = ScenarioUtils.loadScenario(config);
Assert.assertEquals("world", scenario.getPopulation().getPersonAttributes().getAttribute("1", "hello"));
}
内容来源于网络,如有侵权,请联系作者删除!