Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Query] Co2 Value is 0 all the time

There is currently to traci API to regrieve aggregated emission values. Therefore you must retrieve the emissions  for every edge in every simulation step and store the sum of emissions over some time range that is appropriate to your goals.

Am Mi., 5. Juni 2019 um 12:47 Uhr schrieb Bijal <bijal.varia88@xxxxxxxxx>:
Thanks for reply.

I need to get emissions values at the time of making decision on which edge to take.

I calculate emissions on complete available alternative routes (set of edges).

So please suggest how to do this using traci.edge.getco2emisson() ?

Thanks.
Bijal

On Wed, Jun 5, 2019, 12:52 PM <sumo-user-request@xxxxxxxxxxx> wrote:
Send sumo-user mailing list submissions to
        sumo-user@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
        https://www.eclipse.org/mailman/listinfo/sumo-user
or, via email, send a message with subject or body 'help' to
        sumo-user-request@xxxxxxxxxxx

You can reach the person managing the list at
        sumo-user-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of sumo-user digest..."


Today's Topics:

   1. Re: [Query] Co2 Value is 0 all the time (Jakob Erdmann)
   2. Re: [SUMO-USER] Adding a new vehicle (Pratik Dutta)


----------------------------------------------------------------------

Message: 1
Date: Wed, 5 Jun 2019 08:27:05 +0200
From: Jakob Erdmann <namdre.sumo@xxxxxxxxx>
To: Sumo project User discussions <sumo-user@xxxxxxxxxxx>
Subject: Re: [sumo-user] [Query] Co2 Value is 0 all the time
Message-ID:
        <CAMbUcbxu96TyWMrRPiJ5yAr=h1LdKsvUpUQPxfOHLyQ4nHaC1g@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset="utf-8"

The return value of *traci.edge.getCO2Emission* only reflects emissions in
the last time step. If you have no vehicles driving in that step, the value
will be 0. I suggest you re-check in sumo-gui. There you can also color
edges and/or vehicles according to CO2Emission.

Am Mi., 5. Juni 2019 um 07:10 Uhr schrieb Bijal <bijal.varia88@xxxxxxxxx>:

> Dear Sir,
> Following is the code to find shortest path using ACO.
> *I have tried a lot But I don't know why i am getting value of Co2 to 00
> for all the edges. Please help to resolve this issue.*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *import randomgraph = sumolib.net.readNet('Dijkstra1.net.xml')class
> ACOAlgorithm():    '''    Ant colony optimization algorithms to find
> shortest path    '''    def __init__(self):    def set_graph(self,
> Objgraph): #Initialize pheromone values to the length of edge        for
> edge in graph.getEdges():            Co2_Value =
> get_pollution_level_Of_Edge(edge.getID())    def
> process(self,start_node,end_node):        while True:
> self._start_travel(start_node)
> self._find_edge(start_node,end_node)            if
> self._finish_travel(end_node):                break    def
> _start_travel(self,start_node):    def
> _find_edge(self,start_node,end_node):    def
> _finish_travel(self,end_node):        return self.remain_path < self.size
>   def _have_ant_completed(self,end_node):def
> get_pollution_level_Of_Edge(EdgeId):        #Get Edge Carbon Emission
>   Value_co2 = traci.edge.getCO2Emission(EdgeId)        print 'Co2 Value of
> '+ str(EdgeId) + '  Is : '+ str(Value_co2)        return Value_co2def
> generate_routefile():    with open("dijkstra_000.rou.xml", "w") as routes:
>       print >> routes, """<routes>        <vType id="vehicle1" accel="0.8"
> decel="4.5" sigma="0.5" length="5" minGap="2.5" maxSpeed="16.67"
> guiShape="passenger"/>        <route id="1" edges="1 3 5 9" /><flow
> id="myflow" begin="0" end="3600" number="1000" from="1" to="18"/>
> </routes>"""def main():    start_node = 9    end_node = 2
> traci.init(PORT)    Objgraph_mat = Graph_mat()    aco = ACOAlgorithm()
> for edge in graph.getEdges():        FromNode =
> str(int(str(edge.getFromNode().getID())) - 1)        ToNode =
> str(int(str(edge.getToNode().getID())) - 1)
> Objgraph_mat.add_vertex(Vertex(FromNode))
> Objgraph_mat.add_vertex(Vertex(ToNode))    for edge in graph.getEdges():
>     Objgraph_mat.add_edge(int(str(edge.getFromNode().getID())) -
> 1,int(str(edge.getToNode().getID()))-1,edge.getLength())
> #Objgraph_mat.print_graph()    aco.set_graph(Objgraph_mat)
> aco.process(start_node,end_node)    #create the new route for vehicle
> traci.route.add("0", edges)    #assign the new route for vehicle with id
> vehicle1    traci.vehicle.add("vehicle0","0")    for i in range(3000):    #
>  or whatever nulmber of steps you want to simulate
> traci.simulationStep()    traci.close()    sys.stdout.flush()    def
> get_options():    optParser = optparse.OptionParser()
> optParser.add_option("--nogui", action="" default=False,
> help="run the commandline version of sumo")    options, args =
> optParser.parse_args()    return optionsdef
> get_EdgeId_From_vertex(prenode,nextnode):    # this is the main entry point
> of this scriptif __name__ == "__main__":    options = get_options()    #
> this script has been called from the command line. It will start sumo as a
>   # server, then connect and run    if options.nogui:       sumoBinary =
> checkBinary('sumo')    else:       sumoBinary = checkBinary('sumo-gui')
> generate_routefile()    # this is the normal way of using traci. sumo is
> started as a    # subprocess and then the python script connects and runs
>   sumoProcess = subprocess.Popen([sumoBinary, "-c", "dijkstra.sumo.cfg",
> "--tripinfo-output", "tripinfo.xml",
> "--remote-port",str(PORT),"--device.emissions.probability","1","--emission-output","emmission_aco.xml"],
> stdout=sys.stdout, stderr=sys.stderr)    main()    sumoProcess.wait()*
>
> --
> *:)*
> Bijal Varia
> _______________________________________________
> sumo-user mailing list
> sumo-user@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190605/12334c9e/attachment.html>

------------------------------

Message: 2
Date: Wed, 5 Jun 2019 12:52:07 +0530
From: Pratik Dutta <pratikcsc@xxxxxxxxx>
To: Sumo project User discussions <sumo-user@xxxxxxxxxxx>
Subject: Re: [sumo-user] [SUMO-USER] Adding a new vehicle
Message-ID:
        <CANiqJ-zTwpn6JTEvVUzM+JT18tv8Vs74vX19jH8dWBE7-fNSPw@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset="utf-8"

The road network consists of two lanes per road, Still, the error occurs. I
am attaching the required files, Please check it for me



*Regards,*
Pratik Dutta
Mob: 8017342498


On Wed, Jun 5, 2019 at 11:54 AM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:

> The second version (departLane='1') is correct use of the API. However, in
> SUMO lane indices start counting at 0 so if you insert the vehicle on a
> 1-lane road, the error ' Invalid departlane definition...' will occur.
>
> regards,
> Jakob
>
> Am Mi., 5. Juni 2019 um 07:15 Uhr schrieb Pratik Dutta <
> pratikcsc@xxxxxxxxx>:
>
>> Pardon, version is 1.1.0
>>
>>
>>
>> *Regards,*
>> Pratik Dutta
>> Mob: 8017342498
>>
>>
>> On Wed, Jun 5, 2019 at 10:43 AM Pratik Dutta <pratikcsc@xxxxxxxxx> wrote:
>>
>>> sumo 1.2.0
>>> SOrry for the double post, actually the post was not showing in the list
>>>
>>>
>>>
>>> *Regards,*
>>> Pratik Dutta
>>> Mob: 8017342498
>>>
>>>
>>> On Wed, Jun 5, 2019 at 2:45 AM Jakob Erdmann <namdre.sumo@xxxxxxxxx>
>>> wrote:
>>>
>>>> what version of sumo are you using?
>>>> Also, please don't double-post your questions. There are already enough
>>>> mails on this list.
>>>>
>>>> Am Di., 4. Juni 2019 um 16:35 Uhr schrieb Pratik Dutta <
>>>> pratikcsc@xxxxxxxxx>:
>>>>
>>>>> Hello everyone,
>>>>> I want to insert an vehicle to the network using the code
>>>>>
>>>>> traci.vehicle.add('X', rID, typeID='DEFAULT_VEHTYPE', depart='72',
>>>>> *departLane=int(1)*, departPos=str(tempPostion), departSpeed='0',
>>>>> arrivalLane="1", arrivalPos='max', arrivalSpeed='current', fromTaz='',
>>>>> toTaz='', line='', personCapacity=0, personNumber=0)
>>>>>
>>>>> but the error occured like this
>>>>>   tc.TYPE_STRING, len(val)) + str(val).encode("latin1")
>>>>>    TypeError: object of type 'int' has no len()
>>>>>
>>>>> then, i started debug, and found the code of
>>>>> traci._vehicle.add(.........)
>>>>> where there is a loop with variable name val, and that val content
>>>>> should be sring, hence the above error triggered.
>>>>>
>>>>> ------------------------------------------------------------------------------------------------
>>>>> So I decided to change the departLane to string, so the code would be
>>>>> like
>>>>>
>>>>> traci.vehicle.add('X', rID, typeID='DEFAULT_VEHTYPE', depart='72',
>>>>> *departLane='1'*, departPos=str(tempPostion), departSpeed='0',
>>>>> arrivalLane="1", arrivalPos='max', arrivalSpeed='current', fromTaz='',
>>>>> toTaz='', line='', personCapacity=0, personNumber=0)
>>>>>
>>>>> and the following error occurs,
>>>>> traci.exceptions.TraCIException: Invalid departlane definition for
>>>>> vehicle 'X'.
>>>>>
>>>>> ---------------------------------------------------------------------------------------------------
>>>>> the departLane should be within ("random", "free", "allowed", "best",
>>>>> "first", or an int>=0)
>>>>>
>>>>> so, what should be the exact code to insert a new vehicle to the
>>>>> network?
>>>>>
>>>>>
>>>>>
>>>>> *Regards,*
>>>>> Pratik Dutta
>>>>>
>>>>> _______________________________________________
>>>>> sumo-user mailing list
>>>>> sumo-user@xxxxxxxxxxx
>>>>> To change your delivery options, retrieve your password, or
>>>>> unsubscribe from this list, visit
>>>>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>>>>
>>>> _______________________________________________
>>>> sumo-user mailing list
>>>> sumo-user@xxxxxxxxxxx
>>>> To change your delivery options, retrieve your password, or unsubscribe
>>>> from this list, visit
>>>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>>>
>>> _______________________________________________
>> sumo-user mailing list
>> sumo-user@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or unsubscribe
>> from this list, visit
>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>
> _______________________________________________
> sumo-user mailing list
> sumo-user@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190605/15e31897/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: network.zip
Type: application/zip
Size: 24878 bytes
Desc: not available
URL: <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190605/15e31897/attachment.zip>

------------------------------

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user


End of sumo-user Digest, Vol 24, Issue 8
****************************************
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top