Beispiel #1
0
    def to_xml(self, id_stage, fd, indent=0):
        # <ride from="1/3to0/3" to="0/4to1/4" lines="train0"/>
        ind = self.get_ind(id_stage)
        fd.write(xm.start('ride', indent=indent))

        # generate string with all vehicles of this line during entire
        # simulation
        ptlines = self.parent.get_ptlines()

        id_line = self.cols.id_line[ind]
        ids_veh = ptlines.get_ids_veh(id_line)

        #landuse = self.parent.get_landuse()
        #
        #edge_from, pos_from = landuse.get_edge_pos_parking(self.cols.id_parking_from[ind])
        #edge_to, pos_to = landuse.get_edge_pos_parking(self.cols.id_parking_to[ind])
        ptstops = self.parent.get_ptstops()

        fd.write(xm.num('from', ptstops.get_id_edge(
            self.cols.id_stop_from[ind])))
        fd.write(xm.num('to', ptstops.get_id_edge(self.cols.id_stop_to[ind])))
        fd.write(xm.arr('lines', ids_veh))
        # if self.cols.pos_edge_from[ind]>0:
        #    fd.write(xm.num('departPos', self.cols.pos_edge_from[ind]))
        # if self.cols.pos_edge_to[ind]>0:
        #    fd.write(xm.num('arrivalPos', self.cols.pos_edge_to[ind]))

        fd.write(xm.stopit())  # ends stage
Beispiel #2
0
    def to_xml(self, id_stage, fd, indent=0):
        # <ride from="1/3to0/3" to="0/4to1/4" lines="train0"/>
        ind = self.get_ind(id_stage)
        fd.write(xm.start('ride', indent=indent))

        # generate string with all vehicles of this line during entire
        # simulation
        ptlines = self.parent.get_ptlines()

        id_line = self.cols.id_line[ind]
        ids_veh = ptlines.get_ids_veh(id_line)

        #landuse = self.parent.get_landuse()
        #
        #edge_from, pos_from = landuse.get_edge_pos_parking(self.cols.id_parking_from[ind])
        #edge_to, pos_to = landuse.get_edge_pos_parking(self.cols.id_parking_to[ind])
        ptstops = self.parent.get_ptstops()

        fd.write(
            xm.num('from', ptstops.get_id_edge(self.cols.id_stop_from[ind])))
        fd.write(xm.num('to', ptstops.get_id_edge(self.cols.id_stop_to[ind])))
        fd.write(xm.arr('lines', ids_veh))
        # if self.cols.pos_edge_from[ind]>0:
        #    fd.write(xm.num('departPos', self.cols.pos_edge_from[ind]))
        # if self.cols.pos_edge_to[ind]>0:
        #    fd.write(xm.num('arrivalPos', self.cols.pos_edge_to[ind]))

        fd.write(xm.stopit())  # ends stage
Beispiel #3
0
    def write_prtvehicle_xml(self, fd, id_veh, time_begin, indent=2):
        print 'write_prtvehicle_xml', id_veh, time_begin
        # TODO: actually this should go in prtvehicles
        #time_veh_wait_after_stop = 3600
        net = self.get_scenario().net
        #lanes = net.lanes
        edges = net.edges
        #ind_ride = rides.get_inds(id_stage)
        #id_veh = rides.ids_veh[id_stage]
        prtvehicles = self.prtvehicles
        #ptstops = net.ptstops
        #prtstops = self.parent.prtstops
        #ids_prtstop = prtstops.get_ids()
        #ids_ptstop = prtstops.ids_ptstop[id_prtstop]
        # lanes.ids_edge[ptstops.ids_lane[ids_ptstop]],
        #id_lane_from = parking.ids_lane[id_parking_from]
        #laneindex_from =  lanes.indexes[id_lane_from]
        #pos_from = parking.positions[id_parking_from]

        #id_parking_to = rides.ids_parking_to[id_stage]
        #id_lane_to = parking.ids_lane[id_parking_to]
        #laneindex_to =  lanes.indexes[id_lane_to]
        #pos_to = parking.positions[id_parking_to]

        # write unique veh ID to prevent confusion with other veh declarations
        fd.write(
            xm.start('vehicle id="%s"' % prtvehicles.get_id_sumo(id_veh),
                     indent + 2))

        fd.write(xm.num('depart', '%d' % time_begin))
        fd.write(
            xm.num('type',
                   self.parent.vtypes.ids_sumo[prtvehicles.ids_vtype[id_veh]]))
        fd.write(xm.num('line', prtvehicles.get_id_line_xml()))
        fd.write(xm.stop())

        # write route
        fd.write(xm.start('route', indent + 4))
        # print '  edgeindex[ids_edge]',edgeindex[ids_edge]
        fd.write(
            xm.arr('edges',
                   [edges.ids_sumo[prtvehicles.ids_currentedge[id_veh]]]))

        # does not seem to have an effect, always starts at base????
        fd.write(xm.num('departPos', 'base'))
        #fd.write(xm.num('departLane', laneindex_from ))
        fd.write(xm.stopit())

        # write depart stop
        # fd.write(xm.start('stop',indent+4))
        #fd.write(xm.num('lane', edges.ids_sumo[lanes.ids_edge[id_lane_from]]+'_%d'%laneindex_from ))
        #fd.write(xm.num('duration', time_veh_wait_after_stop))
        #fd.write(xm.num('startPos', pos_from ))
        #fd.write(xm.num('endPos', pos_from + parking.lengths[id_parking_from]))
        #fd.write(xm.num('triggered', "True"))
        # fd.write(xm.stopit())

        fd.write(xm.end('vehicle', indent + 2))
Beispiel #4
0
    def write_prtvehicle_xml(self,  fd, id_veh, time_begin, indent=2):
        print 'write_prtvehicle_xml', id_veh, time_begin
        # TODO: actually this should go in prtvehicles
        #time_veh_wait_after_stop = 3600
        net = self.get_scenario().net
        #lanes = net.lanes
        edges = net.edges
        #ind_ride = rides.get_inds(id_stage)
        #id_veh = rides.ids_veh[id_stage]
        prtvehicles = self.prtvehicles
        #ptstops = net.ptstops
        #prtstops = self.parent.prtstops
        #ids_prtstop = prtstops.get_ids()
        #ids_ptstop = prtstops.ids_ptstop[id_prtstop]
        # lanes.ids_edge[ptstops.ids_lane[ids_ptstop]],
        #id_lane_from = parking.ids_lane[id_parking_from]
        #laneindex_from =  lanes.indexes[id_lane_from]
        #pos_from = parking.positions[id_parking_from]

        #id_parking_to = rides.ids_parking_to[id_stage]
        #id_lane_to = parking.ids_lane[id_parking_to]
        #laneindex_to =  lanes.indexes[id_lane_to]
        #pos_to = parking.positions[id_parking_to]

        # write unique veh ID to prevent confusion with other veh declarations
        fd.write(xm.start('vehicle id="%s"' % prtvehicles.get_id_sumo(id_veh), indent+2))

        fd.write(xm.num('depart', '%d' % time_begin))
        fd.write(xm.num('type', self.parent.vtypes.ids_sumo[prtvehicles.ids_vtype[id_veh]]))
        fd.write(xm.num('line', prtvehicles.get_id_line_xml()))
        fd.write(xm.stop())

        # write route
        fd.write(xm.start('route', indent+4))
        # print '  edgeindex[ids_edge]',edgeindex[ids_edge]
        fd.write(xm.arr('edges', [edges.ids_sumo[prtvehicles.ids_currentedge[id_veh]]]))

        # does not seem to have an effect, always starts at base????
        fd.write(xm.num('departPos', 'base'))
        #fd.write(xm.num('departLane', laneindex_from ))
        fd.write(xm.stopit())

        # write depart stop
        # fd.write(xm.start('stop',indent+4))
        #fd.write(xm.num('lane', edges.ids_sumo[lanes.ids_edge[id_lane_from]]+'_%d'%laneindex_from ))
        #fd.write(xm.num('duration', time_veh_wait_after_stop))
        #fd.write(xm.num('startPos', pos_from ))
        #fd.write(xm.num('endPos', pos_from + parking.lengths[id_parking_from]))
        #fd.write(xm.num('triggered', "True"))
        # fd.write(xm.stopit())

        fd.write(xm.end('vehicle', indent+2))
Beispiel #5
0
    def export_flows_and_turns(self,
                               flowfilepath,
                               turnsfilepath,
                               id_mode,
                               indent=0):
        """
        Create the flow file and turn ratios file for a specific mode.
        In the SUMOpy tunflow data structure, each mode has its own 
        flow and turnratio data.
        """
        print '\n\n' + 79 * '_'
        print 'export_flows_and_turns id_mode=', id_mode, 'ids_vtype=', self.parent.vtypes.select_by_mode(
            id_mode)
        print '  write flows', flowfilepath
        fd = open(flowfilepath, 'w')
        fd.write(xm.begin('flows', indent))

        # write all possible vtypes for this mode
        self.parent.vtypes.write_xml(
            fd,
            indent=indent,
            ids=self.parent.vtypes.select_by_mode(id_mode),
            is_print_begin_end=False)

        id_flow = 0
        ids_allsourceedges = []
        time_start_min = +np.inf
        time_end_max = -np.inf
        for id_inter in self.get_ids():
            time_start = self.times_start[id_inter]
            time_end = self.times_end[id_inter]
            fd.write(
                xm.begin(
                    'interval' + xm.num('begin', time_start) +
                    xm.num('end', time_end), indent + 2))
            ids_sourceedge, id_flow = self.turnflowmodes[
                id_inter].export_flows_xml(fd, id_mode, id_flow, indent + 4)
            # print '  got ids_sourceedge, id_flow',ids_sourceedge, id_flow
            ids_allsourceedges += ids_sourceedge

            if len(ids_sourceedge) > 0:
                # print '  extend total time interval only for intervals with
                # flow'
                if time_start < time_start_min:
                    time_start_min = time_start

                if time_end > time_end_max:
                    time_end_max = time_end

            fd.write(xm.end('interval', indent + 2))

        fd.write(xm.end('flows', indent))
        fd.close()

        # print '  write turndefs', turnsfilepath
        fd = open(turnsfilepath, 'w')
        fd.write(xm.begin('turns', indent))

        for id_inter in self.get_ids():
            time_start = self.times_start[id_inter]
            time_end = self.times_end[id_inter]
            fd.write(
                xm.begin(
                    'interval' + xm.num('begin', time_start) +
                    xm.num('end', time_end), indent + 2))
            self.turnflowmodes[id_inter].export_turns_xml(
                fd, id_mode, indent + 4)
            fd.write(xm.end('interval', indent + 2))

        #  take sink edges from sink zones
        ids_sinkedge = self.get_sinkedges()  # it's a set
        # ...and remove source edges, otherwise vehicle will be inserted and
        # immediately removed
        # print '  ids_sinkedge',ids_sinkedge
        # print '  ids_allsourceedges',ids_allsourceedges
        ids_sinkedge = ids_sinkedge.difference(ids_allsourceedges)

        ids_sumoedge = self.get_edges().ids_sumo
        # print '  determined sink edges',list(ids_sinkedge)
        if len(ids_sinkedge) > 0:
            fd.write(xm.start('sink'))
            fd.write(xm.arr('edges', ids_sumoedge[list(ids_sinkedge)]))
            fd.write(xm.stopit())

        fd.write(xm.end('turns', indent))
        fd.close()
        if len(ids_allsourceedges) == 0:
            time_start_min = 0
            time_end_max = 0

        return time_start_min, time_end_max
Beispiel #6
0
    def _export_plans(self, fd, indent=0):
        if len(self) == 0:
            return

        scenario = self.parent.get_scenario()
        edges = scenario.net.edges
        lanes = scenario.net.lanes
        landuse = self.get_landuse()
        # ptlines=self.get_ptlines()
        persons = self  # instance holding all arrays for persons
        # instance holding all arrays for individual vehicles
        ivehs = self.individualvehicles.value
        parking = landuse.parking  # instance holding all arrays for parking
        plans = self.plans.value

        # sort users by initial time
        # print '  persons.times_start.value',persons.times_start.value
        # print '  persons.get_inds()',persons.get_inds()
        times_sorted = np.concatenate((persons.times_start.value.reshape(
            -1, 1), persons.get_inds().reshape(-1, 1)), 1).tolist()
        times_sorted.sort()
        # print '  times_sorted',times_sorted
        inds_pers = np.array(times_sorted, int)[:, 1]
        # print '  inds_pers',inds_pers

        # used to start first vehcile appearance
        time_first, ind_first = times_sorted[0]

        vehindex = self.parent.vtypes.ids_sumo  # vehindex.get_index_from_ids()
        edgeindex = edges.ids_sumo
        # pt
        # self.parent.get_ptlines().to_routes(fd,2)

        #----------------------
        # write vehicles first
        inds_veh = ivehs.get_inds()
        for id_veh, id_vtype, ids_edge, ids_parking in zip(
                ivehs.get_ids(inds_veh), ivehs.ids_vtype.value[inds_veh],
                ivehs.routes.value[inds_veh],
                ivehs.ids_parkings.value[inds_veh]):
            if (ids_edge != None) & (ids_parking != None):
                if len(ids_edge) > 0:
                    # print "  vehicle id=", id_veh,ids_edge, ids_parking

                    inds_parking = parking.get_inds(ids_parking)
                    # first depart position  equals position of first parking
                    pos_depart = parking.positions.value[inds_parking][
                        0]  # get pos of first parking

                    fd.write(xm.start('vehicle id="%s"' % id_veh, indent + 2))
                    fd.write(xm.num('depart', '%.1f' % time_first))
                    fd.write(xm.num('type', vehindex[id_vtype]))
                    fd.write(xm.stop())

                    # write route
                    fd.write(xm.start('route', indent + 4))
                    fd.write(xm.arr('edges', edgeindex[ids_edge], indent + 6))
                    fd.write(xm.num('departPos', pos_depart))
                    # depart lane is 1 , 0 would be on the side-walk)
                    fd.write(
                        xm.num(
                            'departLane',
                            lanes.indexes[parking.ids_lane[ids_parking[0]]]))
                    fd.write(xm.stopit())

                    # write stops
                    ids_lane_parking = parking.ids_lane.value[inds_parking]
                    ids_edge_parking = lanes.ids_edge[ids_lane_parking]
                    laneindexes_parking = lanes.indexes[ids_lane_parking]

                    poss_end_parking = parking.positions[inds_parking]
                    poss_start_parking = poss_end_parking - \
                        parking.lengths[inds_parking]
                    for id_edge_parking, laneindex_parking, pos_start_parking, pos_end_parking in zip(
                            ids_edge_parking, laneindexes_parking,
                            poss_start_parking, poss_end_parking):
                        fd.write(xm.start('stop', indent + 4))
                        fd.write(
                            xm.num(
                                'lane', edges.ids_sumo[id_edge_parking] +
                                '_%d' % laneindex_parking))
                        fd.write(xm.num('duration', 3000))
                        fd.write(xm.num('startPos', pos_start_parking))
                        fd.write(xm.num('endPos', pos_end_parking))
                        fd.write(xm.num('triggered', "True"))
                        fd.write(xm.stopit())

                    fd.write(xm.end('vehicle', indent + 2))

        #----------------------
        # write plans

        # print '  inds_pers',inds_pers
        # print '  times_start[inds_pers]',persons.times_start.value[inds_pers]
        for time_start, id_pers, stages in zip(
                persons.times_start.value[inds_pers],
                persons.get_ids(inds_pers),
                plans.stagelists[persons.ids_plan.value[inds_pers]]):
            print '  time_start,id_pers', time_start, id_pers, stages != None
            if stages != None:
                # TODO: self.persons.to_xml()??..pass all attrs?
                fd.write(xm.start('person', indent=indent + 2))
                fd.write(xm.num('id', id_pers))
                fd.write(xm.num('depart', time_start))
                fd.write(xm.num('type', 'pedestrian'))
                fd.write(xm.stop())

                for stage, id_stage in stages:
                    stage.to_xml(id_stage, fd, indent + 4)

                fd.write(xm.end('person', indent=indent + 2))
Beispiel #7
0
    def _export_plans(self, fd, indent=0):
        if len(self) == 0:
            return

        scenario = self.parent.get_scenario()
        edges = scenario.net.edges
        lanes = scenario.net.lanes
        landuse = self.get_landuse()
        # ptlines=self.get_ptlines()
        persons = self  # instance holding all arrays for persons
        # instance holding all arrays for individual vehicles
        ivehs = self.individualvehicles.value
        parking = landuse.parking  # instance holding all arrays for parking
        plans = self.plans.value

        # sort users by initial time
        # print '  persons.times_start.value',persons.times_start.value
        # print '  persons.get_inds()',persons.get_inds()
        times_sorted = np.concatenate(
            (persons.times_start.value.reshape(-1, 1),  persons.get_inds().reshape(-1, 1)), 1).tolist()
        times_sorted.sort()
        # print '  times_sorted',times_sorted
        inds_pers = np.array(times_sorted, int)[:, 1]
        # print '  inds_pers',inds_pers

        # used to start first vehcile appearance
        time_first, ind_first = times_sorted[0]

        vehindex = self.parent.vtypes.ids_sumo  # vehindex.get_index_from_ids()
        edgeindex = edges.ids_sumo
        # pt
        # self.parent.get_ptlines().to_routes(fd,2)

        #----------------------
        # write vehicles first
        inds_veh = ivehs.get_inds()
        for id_veh, id_vtype, ids_edge, ids_parking in zip(ivehs.get_ids(inds_veh), ivehs.ids_vtype.value[inds_veh], ivehs.routes.value[inds_veh], ivehs.ids_parkings.value[inds_veh]):
            if (ids_edge != None) & (ids_parking != None):
                if len(ids_edge) > 0:
                    # print "  vehicle id=", id_veh,ids_edge, ids_parking

                    inds_parking = parking.get_inds(ids_parking)
                    # first depart position  equals position of first parking
                    pos_depart = parking.positions.value[
                        inds_parking][0]  # get pos of first parking

                    fd.write(xm.start('vehicle id="%s"' % id_veh, indent + 2))
                    fd.write(xm.num('depart', '%.1f' % time_first))
                    fd.write(xm.num('type', vehindex[id_vtype]))
                    fd.write(xm.stop())

                    # write route
                    fd.write(xm.start('route', indent + 4))
                    fd.write(xm.arr('edges', edgeindex[ids_edge], indent + 6))
                    fd.write(xm.num('departPos', pos_depart))
                    # depart lane is 1 , 0 would be on the side-walk)
                    fd.write(xm.num('departLane', lanes.indexes[
                             parking.ids_lane[ids_parking[0]]]))
                    fd.write(xm.stopit())

                    # write stops
                    ids_lane_parking = parking.ids_lane.value[inds_parking]
                    ids_edge_parking = lanes.ids_edge[ids_lane_parking]
                    laneindexes_parking = lanes.indexes[ids_lane_parking]

                    poss_end_parking = parking.positions[inds_parking]
                    poss_start_parking = poss_end_parking - \
                        parking.lengths[inds_parking]
                    for id_edge_parking, laneindex_parking, pos_start_parking, pos_end_parking in zip(ids_edge_parking, laneindexes_parking, poss_start_parking, poss_end_parking):
                        fd.write(xm.start('stop', indent + 4))
                        fd.write(xm.num('lane', edges.ids_sumo[
                                 id_edge_parking] + '_%d' % laneindex_parking))
                        fd.write(xm.num('duration', 3000))
                        fd.write(xm.num('startPos', pos_start_parking))
                        fd.write(xm.num('endPos', pos_end_parking))
                        fd.write(xm.num('triggered', "True"))
                        fd.write(xm.stopit())

                    fd.write(xm.end('vehicle', indent + 2))

        #----------------------
        # write plans

        # print '  inds_pers',inds_pers
        # print '  times_start[inds_pers]',persons.times_start.value[inds_pers]
        for time_start, id_pers, stages in zip(persons.times_start.value[inds_pers], persons.get_ids(inds_pers), plans.stagelists[persons.ids_plan.value[inds_pers]]):
            print '  time_start,id_pers', time_start, id_pers, stages != None
            if stages != None:
                # TODO: self.persons.to_xml()??..pass all attrs?
                fd.write(xm.start('person', indent=indent + 2))
                fd.write(xm.num('id', id_pers))
                fd.write(xm.num('depart', time_start))
                fd.write(xm.num('type', 'pedestrian'))
                fd.write(xm.stop())

                for stage, id_stage in stages:
                    stage.to_xml(id_stage, fd, indent + 4)

                fd.write(xm.end('person', indent=indent + 2))
Beispiel #8
0
    def write_xml(self, fd, indent=0):
        """
        Write simpla xml config file
        """
        print 'Simplaconfig.write_xml'
        fd.write(xm.begin(self.xmltag, indent))
        attrsman = self.get_attrsman()
        vtypes = self.parent.get_scenario().demand.vtypes
        ids_sumo_vtypes = vtypes.ids_sumo
        # <controlRate value="0.5" />
        # <maxPlatoonGap value="15.0" />
        # <catchupDist value="100.0" />
        # <switchImpatienceFactor value="0.1" />
        # <platoonSplitTime value="3.0" />
        # <lcMode original="597" leader="597" follower="514" catchup="514" catchupFollower="514" />
        # <speedFactor original="1.0" leader="1.0" follower="2.0" catchup="2.5" catchupFollower="3.0" />
        # <verbosity value="1" />
        # <vTypeMap original="passenger1" leader="leaderVTypeID" follower="followerVTypeID" catchup="catchupVTypeID" catchupFollower="catchupFollowerVTypeID" />

        #ids_plattypes = ['catchup','follower','original']
        #ids_plattypes = self._typemap.keys()
        #ids_vtypes_plat_sumo = []
        # for id_mode in self.ids_platoonmodes:
        #    ids_vtype_sumo= ids_sumo_vtypes[vtypes.select_by_mode(id_mode=id_mode)]
        #    #print '  id_mode',id_mode,'ids_vtype',ids_vtype.tolist()
        #    for id_vtype_sumo in ids_vtype_sumo:
        #        if id_vtype in ids_plattypes
        #            #if id_vtype_sumo.split('_')[-1] not in plattypes:
        #            ids_vtypes_plat_sumo.append(id_vtype_sumo)

        ids_vtypes_plat_sumo = ids_sumo_vtypes[self._typemap.keys()]
        fd.write(xm.start('vehicleSelectors', indent+2))
        fd.write(xm.arr('value', ids_vtypes_plat_sumo, sep=','))
        fd.write(xm.stopit())

        fd.write(xm.start('lcMode', indent+2))
        fd.write(xm.num('leader', self.lanechangemode_leader))
        fd.write(xm.num('follower', self.lanechangemode_follower))
        fd.write(xm.num('catchup', self.lanechangemode_catchup))
        fd.write(xm.num('catchupFollower', self.lanechangemode_catchup_follower))
        fd.write(xm.stopit())

        fd.write(xm.start('speedFactor', indent+2))
        fd.write(xm.num('original', 1.0))
        fd.write(xm.num('leader', self.speedfactor_leader))
        fd.write(xm.num('follower', self.speedfactor_follower))
        fd.write(xm.num('catchup', self.speedfactor_catchup))
        fd.write(xm.num('catchupFollower', self.speedfactor_catchup_follower))
        fd.write(xm.stopit())

        for plattypes in self._typemap.values():
            fd.write(xm.start('vTypeMap', indent+2))
            for plattype, id_vtype in plattypes.iteritems():
                fd.write(xm.num(plattype, ids_sumo_vtypes[id_vtype]))
            fd.write(xm.stopit())

        for attrconfig in attrsman.get_configs():
            if attrconfig.xmltag is not None:
                if (attrconfig.xmltag == 'switchImpatienceFactor') & (attrconfig.get_value() < 0):
                    pass
                else:
                    fd.write(xm.start(attrconfig.xmltag, indent+2))
                    fd.write(xm.num('value', attrconfig.format_value()))
                    fd.write(xm.stopit())

        fd.write(xm.end(self.xmltag, indent))
Beispiel #9
0
    def export_flows_and_turns(self, flowfilepath, turnsfilepath, id_mode, indent=0):
        """
        Create the flow file and turn ratios file for a specific mode.
        In the SUMOpy tunflow data structure, each mode has its own 
        flow and turnratio data.
        """
        print "\n\n" + 79 * "_"
        print "export_flows_and_turns id_mode=", id_mode, "ids_vtype=", self.parent.vtypes.select_by_mode(id_mode)
        print "  write flows", flowfilepath
        fd = open(flowfilepath, "w")
        fd.write(xm.begin("flows", indent))

        # write all possible vtypes for this mode
        self.parent.vtypes.write_xml(
            fd, indent=indent, ids=self.parent.vtypes.select_by_mode(id_mode), is_print_begin_end=False
        )

        id_flow = 0
        ids_allsourceedges = []
        time_start_min = +np.inf
        time_end_max = -np.inf
        for id_inter in self.get_ids():
            time_start = self.times_start[id_inter]
            time_end = self.times_end[id_inter]
            fd.write(xm.begin("interval" + xm.num("begin", time_start) + xm.num("end", time_end), indent + 2))
            ids_sourceedge, id_flow = self.turnflowmodes[id_inter].export_flows_xml(fd, id_mode, id_flow, indent + 4)
            # print '  got ids_sourceedge, id_flow',ids_sourceedge, id_flow
            ids_allsourceedges += ids_sourceedge

            if len(ids_sourceedge) > 0:
                # print '  extend total time interval only for intervals with
                # flow'
                if time_start < time_start_min:
                    time_start_min = time_start

                if time_end > time_end_max:
                    time_end_max = time_end

            fd.write(xm.end("interval", indent + 2))

        fd.write(xm.end("flows", indent))
        fd.close()

        # print '  write turndefs', turnsfilepath
        fd = open(turnsfilepath, "w")
        fd.write(xm.begin("turns", indent))

        for id_inter in self.get_ids():
            time_start = self.times_start[id_inter]
            time_end = self.times_end[id_inter]
            fd.write(xm.begin("interval" + xm.num("begin", time_start) + xm.num("end", time_end), indent + 2))
            self.turnflowmodes[id_inter].export_turns_xml(fd, id_mode, indent + 4)
            fd.write(xm.end("interval", indent + 2))

        #  take sink edges from sink zones
        ids_sinkedge = self.get_sinkedges()  # it's a set
        # ...and remove source edges, otherwise vehicle will be inserted and
        # immediately removed
        # print '  ids_sinkedge',ids_sinkedge
        # print '  ids_allsourceedges',ids_allsourceedges
        ids_sinkedge = ids_sinkedge.difference(ids_allsourceedges)

        ids_sumoedge = self.get_edges().ids_sumo
        # print '  determined sink edges',list(ids_sinkedge)
        if len(ids_sinkedge) > 0:
            fd.write(xm.start("sink"))
            fd.write(xm.arr("edges", ids_sumoedge[list(ids_sinkedge)]))
            fd.write(xm.stopit())

        fd.write(xm.end("turns", indent))
        fd.close()
        if len(ids_allsourceedges) == 0:
            time_start_min = 0
            time_end_max = 0

        return time_start_min, time_end_max