def _init_attributes(self): attrsman = self.get_attrsman() scenario = self.get_scenario() self.edgeresults = attrsman.add( cm.ObjConf( Edgeresults(self, scenario.net.edges), groupnames=['Edge results'], )) # add trip results from all demand objects print 'Simresults._init_attributes' # print ' scenario.demand.get_demandobjects()',scenario.demand.get_demandobjects() for demandobj in scenario.demand.get_demandobjects(): demandobj.config_results(self) for simobj in self.parent.get_simobjects(): simobj.config_simresults(self)
def __init__(self, ident, parent, zones, **kwargs): self._init_objman( ident, parent=parent, name='OD trips', info= 'Contains the number of trips between an origin and a destination zone.', xmltag=('odtrips', 'odtrip', None), **kwargs) self.add_col( am.IdsArrayConf( 'ids_orig', zones, groupnames=['state'], name='Orig.', choices=zones.ids_sumo.get_indexmap(), info='traffic assignment zone of origin of trip.', xmltag='id_orig', )) self.add_col( am.IdsArrayConf( 'ids_dest', zones, groupnames=['state'], name='Dest.', choices=zones.ids_sumo.get_indexmap(), info='ID of traffic assignment zone of destination of trip.', xmltag='id_dest', )) self.add_col( am.ArrayConf( 'tripnumbers', 0, groupnames=['state'], perm='rw', name='Trips', info= 'Number of trips from zone with ID Orig to zone with ID Dest.', xmltag='tripnumber', )) self.add(cm.ObjConf(zones, is_child=False, groups=['_private']))
def _init_attributes(self): self.add(cm.ObjConf(PrtBerths('berths', self))) berths = self.get_berths() net = self.get_scenario().net self.add_col( am.IdsArrayConf( 'ids_ptstop', net.ptstops, name='ID PT stop', info='ID of public transport stop. ', )) self.add_col( am.ArrayConf( 'are_depot', default=False, dtype='bool', perm='rw', name='Is depot?', info='If true stop is a depot.', )) self.add_col( am.IdlistsArrayConf( 'ids_berth_alight', berths, #groupnames = ['_private'], name='Alight berth IDs', info="Alight berth IDs.", )) self.add_col( am.IdlistsArrayConf( 'ids_berth_board', berths, #groupnames = ['_private'], name='Board berth IDs', info="Board berth IDs.", ))
def __init__(self, ident, parent, modes, zones, **kwargs): self._init_objman(ident, parent=parent, name='Mode OD tables', info='Contains for each transport mode an OD trip table.', xmltag=('modesods', 'modeods', 'ids_mode'), **kwargs) self.add_col(am.IdsArrayConf('ids_mode', modes, groupnames=['state'], choices=MODES, name='ID mode', xmltag='vClass', info='ID of transport mode.', )) self.add_col(cm.ObjsConf('odtrips', groupnames=['state'], is_save=True, name='OD matrix', info='Matrix with trips from origin to destintion for a specific mode.', )) self.add(cm.ObjConf(zones, is_child=False, groups=['_private']))
def __init__(self, ident, parent, modes, edges, **kwargs): self._init_objman( ident, parent=parent, name='Mode OD tables', info='Contains for each transport mode an OD trip table.', xmltag=('modesods', 'modeods', 'ids_mode'), **kwargs) print 'TurnflowModes.__init__', modes self.add_col( am.IdsArrayConf( 'ids_mode', modes, groupnames=['state'], choices=MODES, name='ID mode', is_index=True, #xmltag = 'vClass', info='ID of transport mode.', )) print ' self.ids_mode.is_index', self.ids_mode.is_index() self.add_col( cm.ObjsConf( 'flowtables', groupnames=['state'], name='Flows', info='Flow generation per edge for a specific mode.', )) self.add_col( cm.ObjsConf( 'turntables', groupnames=['state'], name='Turns', info='Turn probabilities between edges for a specific mode.', )) self.add(cm.ObjConf(edges, is_child=False, groups=['_private']))
def add_simobject(self, obj=None, ident=None, SimClass=None, **kwargs): if obj is not None: ident = obj.get_ident() if not hasattr(self, ident): if obj is None: # init simobject and make it a child of simulation obj = SimClass(ident, self, **kwargs) is_child = True else: # link to simobject, which must be a child of another object is_child = False attrsman = self.get_attrsman() attrsman.add(cm.ObjConf(obj, groupnames=['simulation objects'], is_child=is_child, )) setattr(self, ident, obj) return getattr(self, ident)
def _init_attributes(self): print 'Scenario._init_attributes' # ,dir(self) attrsman = self.get_attrsman() self.simulation = attrsman.add(cm.ObjConf(simulation.Simulation(self))) self.set_version(0.2)
def __init__(self, ident='odintervals', parent=None, net=None, zones=None, **kwargs): self._init_objman( ident, parent=parent, # = demand name='OD Demand', info= 'Contains origin-to-destination zone transport demand for different time intervals.', xmltag=('odintervals', 'odinteval', None), **kwargs) self.add_col( am.ArrayConf( 'times_start', 0, groupnames=['state'], perm='rw', name='Start time', unit='s', info= 'Start time of interval in seconds (no fractional seconds).', xmltag='t_start', )) self.add_col( am.ArrayConf( 'times_end', 3600, groupnames=['state'], perm='rw', name='End time', unit='s', info='End time of interval in seconds (no fractional seconds).', xmltag='t_end', )) activitytypes = self.parent.activitytypes self.add_col( am.IdsArrayConf( 'ids_activitytype_orig', activitytypes, groupnames=['parameters'], perm='rw', #choices = activitytypes.names.get_indexmap(), name='Activity type at orig.', symbol='Act. orig.', info='Type of activity performed at origin, before the trip.', #xmltag = 'actType', #xmlmap = get_inversemap( activitytypes.names.get_indexmap()), )) self.add_col( am.IdsArrayConf( 'ids_activitytype_dest', activitytypes, groupnames=['parameters'], perm='rw', #choices = activitytypes.names.get_indexmap(), name='Activity type at dest.', symbol='Act. dest.', info= 'Type of activity performed at destination, after the trip.', #xmltag = 'actType', #xmlmap = get_inversemap( activitytypes.names.get_indexmap()), )) self.add_col( cm.ObjsConf( 'odmodes', groupnames=['state'], is_save=True, name='OD modes', info= 'OD transport demand for all transport modes within the respective time interval.', )) self.add(cm.ObjConf(net, is_child=False, groups=['_private'])) self.add(cm.ObjConf(zones, is_child=False, groups=['_private']))
def _init_attributes(self, zones=None): # print '_init_attributes',self.ident if not self.has_attrname('zones'): self.add(cm.ObjConf(zones, is_child=False, groups=['_private'])) else: # zones is already an attribute zones = self.zones.get_value() if self.get_version() < 0.1: # update attrs from previous # IdsArrayConf not yet modifiable interactively, despite perm = 'rw',!!! self.ids_orig.set_perm('rw') self.ids_dest.set_perm('rw') if hasattr(self, 'func_delete_row'): self.func_make_row._is_returnval = False self.func_delete_row._is_returnval = False self.add_col( am.IdsArrayConf( 'ids_orig', zones, groupnames=['state'], perm='rw', name='Orig.', #choices = zones.ids_sumo.get_indexmap(), info='traffic assignment zone of origin of trip.', xmltag='id_orig', )) self.add_col( am.IdsArrayConf( 'ids_dest', zones, groupnames=['state'], perm='rw', name='Dest.', #choices = zones.ids_sumo.get_indexmap(), info='ID of traffic assignment zone of destination of trip.', xmltag='id_dest', )) self.add_col( am.ArrayConf( 'tripnumbers', 0, groupnames=['state'], perm='rw', name='Trips', info= 'Number of trips from zone with ID Orig to zone with ID Dest.', xmltag='tripnumber', )) # print ' pre add func_make_row' self.add( cm.FuncConf( 'func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New OD flow.', info='Add a new OD flow.', is_returnval=False, )) # print ' post add func_make_row' self.add( cm.FuncConf( 'func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del OD flow', info='Delete OD flow.', is_returnval=False, ))
def _init_attributes(self): # attrsman = self # = self.get_attrsman() demand = self.parent net = self.get_net() self.add(cm.ObjConf(PtLinks('ptlinks', self))) self.add_col( am.ArrayConf( 'linenames', default='', dtype='object', perm='rw', name='Line name', info= 'This is the official name or number of the line. Note that the same line may have several line services for different service periods.', xmltag='line', )) self.add_col( am.ArrayConf( 'times_begin', 0, name='Begin time', unit='s', perm='rw', info='Time when service begins.', xmltag='begin', )) self.add_col( am.ArrayConf( 'times_end', 0, name='End time', perm='rw', unit='s', info='Time when service ends.', xmltag='end', )) self.add_col( am.ArrayConf( 'periods', 0, name='Interval', perm='rw', unit='s', info='Time interval between consecutive vehicles.', xmltag='period', )) self.add_col( am.ArrayConf( 'times_dwell', 20, groupnames=['options'], perm='rw', name='Dwell time', untit='s', info= 'Dwell time in a stop while passengers are boarding/alighting.', xmltag='duration', )) self.add_col( am.IdlistsArrayConf( 'ids_stops', net.ptstops, groupnames=['parameters'], name='PT stop IDs', info= 'Sequence of IDs of stops or stations of a public transort line.', )) self.add_col( am.IdlistsArrayConf( 'ids_edges', net.edges, name='Edge IDs', info= 'Sequence of edge IDs constituting this public transport line.', xmltag='edges', )) self.add_col( am.IdsArrayConf( 'ids_vtype', demand.vtypes, id_default=0, groupnames=['state'], name='Veh. type ID', info='Vehicle type used to derve this line.', xmltag='type', )) self.add( cm.FuncConf( 'func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del line', info='Delete line service.', is_returnval=False, )) if self.get_version() < 0.2: if hasattr(self, 'period'): self.delete('period') self.linenames.set_xmltag('line') self.ids_vtype.set_xmltag('type') self.times_dwell.set_xmltag('duration') self.periods.set_xmltag('period') self.times_end.set_xmltag('end') self.times_begin.set_xmltag('begin')
def __init__(self, demand, **kwargs): self._init_objman( ident='virtualpop', parent=demand, name='Virtual polulation', info= 'Contains information of each individual of the virtual population.', #xmltag = ('plans','plan',None), **kwargs) scenario = demand.get_scenario() #-------------------------------------------------------------------- # plans table self.add(cm.ObjConf(Plans(self))) #-------------------------------------------------------------------- # individual vehicles table self.add( cm.ObjConf( IndividualVehicles('individualvehicles', self, demand.vtypes, scenario.net.edges, scenario.landuse.parking))) #-------------------------------------------------------------------- # walks table #self.walks = self.add_tableman(Walks(self)) self.add(cm.ObjConf(Walks('walks', self, scenario.net.edges))) #-------------------------------------------------------------------- # rides table self.add(cm.ObjConf(Rides('rides', self, scenario.landuse.parking))) #-------------------------------------------------------------------- # pt rides table # self.add(cm.ObjConf(Transits(self, publictransport)) ) #-------------------------------------------------------------------- # Activities table self.add(cm.ObjConf(Activities('activities', self, scenario.net.lanes))) #-------------------------------------------------------------------- # misc params # this is option for intermodal routing process # self.add(AttrConf( 'dist_max_wait', kwargs.get('dist_max_wait',20.0), # groupnames = ['options'], # perm='wr', # unit = 'm', # name = 'Max dist. Wait', # info = 'The maximum distance between two stops or platforms, when a person during transfer is not walking, but just waiting for the next bus/train to come.' , # #xmltag = 'pos', # )) #-------------------------------------------------------------------- # columns self.add_col( am.ArrayConf( 'identification ', '', dtype=np.object, name='Name', info='Identification or name of person.', )) self.add_col( am.IdsArrayConf( 'ids_fac_home', scenario.landuse.facilities, groupnames=['state'], name='ID home fac.', info='Facility ID of home.', )) self.add_col( am.IdsArrayConf( 'ids_fac_activity', scenario.landuse.facilities, groupnames=['state'], name='ID activity fac.', info='Facility ID of location of main activity (work, study).', )) self.add_col( am.IdsArrayConf( 'ids_mode_preferred', scenario.net.modes, name='ID preferred mode', info='ID of preferred transport mode of person.', )) self.add_col( am.ArrayConf( 'times_start', 0, name='Start time', unit='s', info= 'Time when person leaves home facility for doing some activity.', )) # this could be extended to a list with more plans self.add_col( am.IdsArrayConf( 'ids_plan', self.get_plans(), name='ID Plan', info='Currently best mobility plan ID of person.', )) self.add_col( am.IdlistsArrayConf( 'lists_ids_plan', self.get_plans(), name='IDs Plans', info='List with the IDs of feasible mobility plans.', ))
def __init__(self, demand, net, **kwargs): # print 'Trips.__init__' self._init_objman(ident='trips', parent=demand, name='Trips', info='Table with trip and route info.', xmltag=('trips', 'trip', 'ids_sumo'), **kwargs) self.add_col(SumoIdsConf('Trip', xmltag='id')) self.add_col(am.IdsArrayConf('ids_vtype', demand.vtypes, groupnames=['state'], name='Type', info='Vehicle type.', xmltag='type', )) self.add_col(am.ArrayConf('times_depart', 0, dtype=np.int32, perm='rw', name='Depart time', info="Departure time of vehicle in seconds. Must be an integer!", xmltag='depart', )) self.add_col(am.IdsArrayConf('ids_edge_depart', net.edges, groupnames=['state'], name='ID from-edge', info='ID of network edge where trip starts.', xmltag='from', )) self.add_col(am.IdsArrayConf('ids_edge_arrival', net.edges, groupnames=['state'], name='ID to-edge', info='ID of network edge where trip ends.', xmltag='to', )) self.add_col(am.ArrayConf('inds_lane_depart', OPTIONMAP_LANE_DEPART["free"], dtype=np.int32, #choices = OPTIONMAP_LANE_DEPART, perm='r', name='Depart lane', info="Departure lane index. 0 is rightmost lane or sidewalk, if existant.", xmltag='departLane', xmlmap=get_inversemap(OPTIONMAP_LANE_DEPART), )) self.add_col(am.ArrayConf('positions_depart', OPTIONMAP_POS_DEPARTURE["random_free"], dtype=np.float32, #choices = OPTIONMAP_POS_DEPARTURE, perm='r', name='Depart pos', unit='m', info="Position on edge at the moment of departure.", xmltag='departPos', xmlmap=get_inversemap( OPTIONMAP_POS_DEPARTURE), )) self.add_col(am.ArrayConf('speeds_depart', 0.0, dtype=np.float32, #choices = OPTIONMAP_SPEED_DEPARTURE, perm='r', name='Depart speed', unit='m/s', info="Speed at the moment of departure.", xmltag='departSpeed', xmlmap=get_inversemap( OPTIONMAP_SPEED_DEPARTURE), )) self.add_col(am.ArrayConf('inds_lane_arrival', OPTIONMAP_LANE_ARRIVAL["current"], dtype=np.int32, #choices = OPTIONMAP_LANE_ARRIVAL, perm='r', name='Arrival lane', info="Arrival lane index. 0 is rightmost lane or sidewalk, if existant.", xmltag='arrivalLane', xmlmap=get_inversemap( OPTIONMAP_LANE_ARRIVAL), )) self.add_col(am.ArrayConf('positions_arrival', OPTIONMAP_POS_ARRIVAL["random"], dtype=np.float32, #choices = OPTIONMAP_POS_ARRIVAL, perm='r', name='Arrival pos', unit='m', info="Position on edge at the moment of arrival.", xmltag='arrivalPos', xmlmap=get_inversemap(OPTIONMAP_POS_ARRIVAL), )) self.add_col(am.ArrayConf('speeds_arrival', 0.0, dtype=np.float32, #choices = OPTIONMAP_SPEED_ARRIVAL, perm='r', name='Arrival speed', unit='m/s', info="Arrival at the moment of departure.", xmltag='arrivalSpeed', xmlmap=get_inversemap( OPTIONMAP_SPEED_ARRIVAL), )) self.add(cm.ObjConf(Routes('routes', self, net))) # print ' self.routes.get_value()',self.routes.get_value() self.add_col(am.IdlistsArrayConf('ids_routes', self.routes.get_value(), name='Route IDs', info='List of edge IDs constituting the route.', ))
def __init__(self, rootname, name_scenario='myscenario', description='', parent=None, workdirpath=None, **kwargs): self._init_objman(ident='scenario', parent=parent, name='Scenario', info='Main scenario instance.', version=0.2, **kwargs) attrsman = self.set_attrsman(cm.Attrsman(self)) if workdirpath is not None: # create a directory if path is given, but does not exist if not os.path.isdir(workdirpath): os.mkdir(workdirpath) else: workdirpath = os.getcwd() #workdirpath = os.path.expanduser("~") self.name_scenario = attrsman.add( cm.AttrConf( 'name_scenario', name_scenario, groupnames=['options'], perm='rw', name='Name', info='Scenario name, used for documentation purposes only.', )) self.description = attrsman.add( cm.AttrConf( 'description', description, groupnames=['options'], perm='rw', name='Description', info='Short, free description of Scenario.', )) self.rootname = attrsman.add( cm.AttrConf( 'rootname', rootname, groupnames=['options'], perm='r', is_save=True, name='Shortname', info= 'Short name for scenario. This string is defined when saving the scenario. It is used as rootname for all files produced by this scenario. Please avoid special charracters, whitespace, accents etc. ASCII is recommented in order to remain compatible between operating systems.', )) self.workdirpath = attrsman.add( cm.AttrConf( 'workdirpath', workdirpath, groupnames=['options'], perm='r', is_save=True, name='Workdir', metatype='dirpath', info= 'Working directory for this scenario and can be changed when saving the scenario. Please avoid special charracters, whitespace, accents etc. ASCII is recommented in order to remain compatible between operating systems.', )) self.net = attrsman.add(cm.ObjConf(network.Network(self))) self.landuse = attrsman.add(cm.ObjConf(landuse.Landuse(self, self.net))) self.demand = attrsman.add(cm.ObjConf(demand.Demand(self))) # if self.get_version()<0.2: # self.delete('simulation') self._init_attributes()