.get_position_of_output_key_property(+)

Memory Output Formatter method

Description

The .get_position_of_output_key_property(+) method allows you to collect the index of output properties in any result entry array. This index can be used to collect the actual value, once you have access to a particular result entry via, for example, the iterator.

This method only retrieves output activated properties that must be part of the unique identifiers - keys - for the result row entry. For example. When the result rows have two columns, where one is identified by OutputProperty.LINK_XML_ID, and the other by OutputProperty.FLOW. Then the former can be be collected via this method, i.e., it reflects the unique identifier for the row. The latter’s property position can be collected as a value position since it reflects a value rather than a unique identifier.

Make sure that the properties you request a position for have been activated. If not, then None is returned

Positions are the same regardless of the mode, time period, or iteration, so you can (re)use the position for all iterators that you construct. Where we point out that constructing an iterator does require the time period, mode and iteration to be specified.

Signature

.get_position_of_output_key_property(output_type, output_property)

with

Parameter Type Unit Compulsory Description
output_type OutputType.<enum> None YES Output type you want to access this value property on
output_property OutputPropertyType.<enum> None YES The output property you want the position information for

Return type

integer when successful, None otherwise

Example 1

from planit import *

#prep
plan_it = Planit()
plan_it.project.set(TrafficAssignment.TRADITIONAL_STATIC)
plan_it.project.assignment.set(PhysicalCost.BPR)
plan_it.project.assignment.set(VirtualCost.FIXED)
plan_it.project.assignment.set(Smoothing.MSA)

#remove default formatter - activate memory output
plan_it.project.deactivate(OutputFormatter.PLANIT_IO)
plan_it.project.activate(OutputFormatter.MEMORY)

#run simulation
plan_it.project.run()

#find position of flow result
flow_pos = plan_it.project.memory.get_position_of_output_key_property(OutputType.LINK, OutputProperty.LINK_EXTERNAL_ID)

See also

Memory Formatter Iterator iterator for the memory output formatter OutputType.<enum> for available output types
OutputPropertyType.<enum> for available output properties

Source code

Class MemoryOutputFormatterWrapper in projectwrappers.py