.get_last_iteration()
Memory Output Formatter method
In-memory results of the PLANit run. All results are collected in a multi-dimensional matrix, where you can access data by providing information to pinpoint its location in the result. You must always provide the following meta-information before accessing any result data:
The mode and time period ids refer to the ids provided in the input files, rather then the auto-generated ids used by PLANit internally.
Further, you must be able to pinpoint the location of the output properties, e.g. flow, cost, in the result array that are exposed via an iterator. So, you first collect the position of each output property, then construct the appropriate iterator. Once this is done, you can loop over each result row and collect the relevant data.
This class exposes the necessary methods to both identify the position of output properties, and also allows you to construct the appropriate iterator.
No defaults (yet)
Memory output formatter exposes the following methods
Name | Description |
---|---|
get_position_of_output_value_property(+) |
Collect the index of an activated output property (e.g. flow) for an active output type (e.g. link). Property is not a(n) (partial) id for the row |
get_position_of_output_key_property(+) |
Collect the index of an activated output property (e.g. link segment id) representing a key for an active output type (e.g. link). Property is a(n) (partial) id for the row |
get_last_iteration() |
Collect the index of the last iteration conducted by the PLANit run |
iterator(+) |
Construct an iterator to loop over the results for a given time period, mode, and iteration |
No exposed properties (yet)
from planit import *
#prep
plan_it = PLANit()
plan_it.set(TrafficAssignment.TRADITIONAL_STATIC)
plan_it.assignment.set(PhysicalCost.BPR)
plan_it.assignment.set(VirtualCost.FIXED)
plan_it.assignment.set(Smoothing.MSA)
# remove default formatter - activate memory output
plan_it.deactivate(OutputFormatter.PLANIT_IO)
plan_it.activate(OutputFormatter.MEMORY)
# run simulation
plan_it.run()
#collect iteration index of last recorded iteration
i = plan_it.memory.get_last_iteration()
# find position of flow result
flow_pos = plan_it.memory.get_position_of_output_value_property(OutputType.LINK, OutputProperty.FLOW)
# find position of key; we use link segment (external) id
id_pos = plan_it.memory.get_position_of_output_key_property(OutputType.LINK, OutputProperty.LINK_SEGMENT_EXTERNAL_ID)
# collect iterator for mode 1, time period 2, iteration i, and print results by looping over entries
link_iter = plan_it.memory.iterator(1, 2, i, OutputType.LINK)
while link_iter.has_next():
link_iter.next()
print "id: ", link_iter.get_keys()[id_pos], " flow: ", link_iter.get_values()[flow_pos]
iterator for the implementation of the memory output formatter iterator
PLANit.activate(+) to see how to activate an output formatter
PLANit.deactivate(+) to see how to de-activate an output formatter
PLANit.memory on how to access the memory output formatter
Class MemoryOutputFormatterWrapper
in Wrappers.py
Memory Output Formatter method
Memory Output Formatter method
Memory Output Formatter method
Memory Output Formatter method
An iterator for in-memory output formatter results