Hi all,

I need a custom SUMO Weight File that consist of SUMO Edge ID and Traveltime 
(Length / Speed) in a separate xml file so that I can use --weight-files 
attribute with the possibility to add more other custom weight attributes.

I also need to use --weight-files attribute for all simulation, so as to 
compare a static no rerouting as well as dynamic rerouting by TraCI later.

I have tried the following:


  1.  Declare a description file, run the simulation once (And hence, failed to 
meet my requirements).

http://sumo.dlr.de/wiki/Simulation/Output/Lane-_or_Edge-based_Traffic_Measures



However, the CSV format generated from XML tools (xml2csv) cannot be directly 
convert back to XML again using csv2xml.

This is because I need a XSD file.

http://sumo.dlr.de/wiki/Tools/Xml





  1.  Tried using sumolib directly with the following codes:



net = sumolib.net.readNet('Network.net.xml')

edges = net.getEdges()



i = 0

csvWeight = "edge_id;travelTime\n"



while (i < len(edges)):

#Get the edge item for edges in XML format that is converted to String: <edge 
id="x" from="y" to ="z">

            edge_item = str(edges[i])

            #Extract only the id part, we want only edge id.

            edge_id = edge_item.split("\"")[1]



            #Get the specific edge

            currentEdge = net.getEdge(edge_id)

            length = currentEdge.getLength()

            speed = currentEdge.getSpeed()

            minTime = length / speed

            csvWeight += str.format("{0};{1}\n", edge_id, minTime)



            i+= 1
            try:
                        resultFile = open('weight.csv', "w") #Which will 
overwrite existing file.
                         resultFile.write(csvWeight)
                         resultFile.close() #Always remember to close a file 
after I/O operation.

            except IOError as e:
                         #Prints error message due to write error (Typically 
due to lack of permissions).
                         print(str.format("Error occurred: {0}", str(e)))


I still face the same XSD file issue if I used:
python csv2xml.py -x edges_file.xsd input.csv

http://sumo.dlr.de/wiki/XMLValidation#Adding_a_schema_declaration

Because it says it requires 3 attributes, while I provided only 2.


csv2xml does not work if I do not declare a XSD.


So what should I do to get a CSV weight file that is compatible with csv2xml 
for SUMO's use?


Regards,

Samuel Lee
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to