0

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?

1 Answer 1

0

First a warning: This is not a programming question, as the answer is not in the code. second a disclosure: I am the creator of AequilibraE, the package in question here.

Multi-class traffic assignment only makes sense where the underlying supernetwork is the same, with different graphs for each class being assigned. In the context of static traffic assignment, it only makes sense to do it if performing some sort of equilibrium assignment where there is a feedback (equilibration) mechanism recomputing link costs via the use of volume-delay function, which takes into consideration.

In this case, just perform two separate assignments (and make sure the centroids in the graph are compatible with those in the matrix) and combine the results afterwards.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.