How can I solve a multi-class traffic assignment

66 views Asked by At

I am working on a project which needs to use aequilibrae python package. I am getting an issue while doing a multi-class equilibrium task. I am getting an error after assig.execute() as "ValueError: operands could not be broadcast together with shapes (11202,) (9184,)". The shape of my graphs are different for different traffic classes in each traffic class function. The graphs are different as I am using different set of networks for each traffic class.

These are the last few lines of my script.

%%time

aem_usa = AequilibraeMatrix()
aem_china = AequilibraeMatrix()
aem_neutral= AequilibraeMatrix()

os.chdir("D:/Professional/Mir/1_multi_class_analysis/7_matrix_bin/") #setting directory

#load aem file
aem_usa.load("Demand_usa.aem")
aem_usa.computational_view(["matrix"])

aem_china.load("Demand_china.aem")
aem_china.computational_view(["matrix"])

aem_neutral.load("Demand_neutral.aem")
aem_neutral.computational_view(["matrix"])

#now assign classes
tc_usa= TrafficClass("usa_flow", g_usa, aem_usa)
tc_china=TrafficClass("china_flow", g_china, aem_china)
#tc_china.set_pce(1)
tc_neutral= TrafficClass("neutral_flow", g_neutral, aem_neutral)

#set classes
assig= TrafficAssignment()
assig.set_classes([tc_china, tc_neutral])
assig.set_vdf("BPR")
assig.set_vdf_parameters({"alpha":0, "beta":1})
assig.set_capacity_field("capacity")
assig.set_algorithm("all-or-nothing")
assig.max_iter = 100
assig.rgap_target = 1e-6
assig.execute()

This is the error



{
    "name": "ValueError",
    "message": "operands could not be broadcast together with shapes (11202,) (9184,) ",
    "stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File <timed exec>:36

File c:\\Users\\Raisul\\anaconda3\\envs\\my_env\\Lib\\site-packages\\aequilibrae\\paths\\traffic_assignment.py:432, in TrafficAssignment.execute(self, log_specification)
    430 if log_specification:
    431     self.log_specification()
--> 432 self.assignment.execute()

File c:\\Users\\Raisul\\anaconda3\\envs\\my_env\\Lib\\site-packages\\aequilibrae\\paths\\linear_approximation.py:388, in LinearApproximation.execute(self)
    384 self.__maybe_create_path_file_directories()
    386 for c in self.traffic_classes:  # type: TrafficClass
    387     # cost = c.fixed_cost / c.vot + self.congested_time #  now only once
--> 388     cost = c.fixed_cost + self.congested_time
    389     aggregate_link_costs(cost, c.graph.compact_cost, c.results.crosswalk)
    391     aon = allOrNothing(c.matrix, c.graph, c._aon_results)

ValueError: operands could not be broadcast together with shapes (11202,) (9184,) "
}

How can I get my result while the shape of g_usa and g_china are still different?

0

There are 0 answers