ValueError: Matrix and graph do not have compatible sets of centroids

140 views
Skip to first unread message

gmormilho

unread,
Oct 12, 2020, 3:24:17 PM10/12/20
to AequilibraE

Hi,

I am trying to do a traffic assignment in QGIS. When I click the ‘Add Traffic class to assignment’ I get the following error:

ValueError: Matrix and graph do not have compatible sets of centroids.

My matrix index and my centroids ids (node_id) are all the same. What else should I check?

Regards,
Gabriel

Pedro Camargo

unread,
Oct 12, 2020, 3:28:46 PM10/12/20
to gmor...@gmail.com, aequi...@googlegroups.com
That is the one check you should do.  Which version of AequilibraE are you using? 

For detailed checks one needs to go to Python and further explore the input data, but it is possible you are missing something. 

If you share your input data it is possible somebody will help you take a look. 

Cheers, 
Pedro 



---- On Tue, 13 Oct 2020 05:24:16 +1000 gmor...@gmail.com wrote ----

--
You received this message because you are subscribed to the Google Groups "AequilibraE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aequilibrae...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aequilibrae/6826f9e2-98f2-4096-8527-7e987ff6f01en%40googlegroups.com.

Gabriel Mormilho

unread,
Oct 12, 2020, 3:40:14 PM10/12/20
to aequi...@googlegroups.com
Thank you for the fast response, Pedro.
I am using version 0.6.2, the latest one available in QGIS.

I attach my data in this e-mail, if someone can reproduce de error.

Regards,
Gabriel
Aloc.rar

Pedro Camargo

unread,
Oct 12, 2020, 8:10:36 PM10/12/20
to Gabriel Mormilho, aequilibrae
Gabriel,
                You stumbled upon a REALLY nasty bug in the underlying AequilibraE library (the Python side) where the order of the centroids as added to the network matter. Something silly and that should not be there.

If you want to take a chance at a quick local fix before a new version is available, this is the deal (assuming you are using Windows):

1. Go to the Python file at  C:\Users\HOUR_USER_NAME\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\AequilibraE-GUI\aequilibrae\aequilibrae\project\network\network.py


And replace line 281

it is
curr.execute('select node_id from nodes where is_centroid=1;')

It should be

curr.execute('select node_id from nodes where is_centroid=1 order by node_id;')
I am filling that bug report to fix in the underlying library and it would be in the next QGIS version (around the new year).

Cheers,
Pedro

PS - You also have a problem with node connectivity for your zone 200, as your modes moto and car are not allowed through the connector...


---- On Tue, 13 Oct 2020 05:39:50 +1000 Gabriel Mormilho <gmor...@gmail.com> wrote ----

gmormilho

unread,
Oct 13, 2020, 10:27:55 AM10/13/20
to AequilibraE
Hi Pedro,

Thank you so much for the help. The assignment process did work with the suggested change to the file. For the record, it is line 241 of the file.

Regards,
Gabriel

PS: thank you for noticing and letting me know about my connectivity problem!

Guilherme Nakao

unread,
Oct 15, 2020, 5:36:43 PM10/15/20
to AequilibraE
Wow, I've been having this exact same problem for over a week now, trying everything to make it work, recreating the links, nodes, etc. Actually, I found out about the group and joined just to ask about this issue!

I have already done other projects with Aequilibrae and did not encounter this problem, so I was very confused with the assignation not working this time.

Made the change (such a small detail) and it worked!

Thank you so much Pedro (and other developers) for creating Aequilibrae! And thank you Gabriel for asking about this before me!

Best regards,
Guilherme

Marco Mendoza

unread,
Apr 7, 2021, 2:08:01 PM4/7/21
to AequilibraE
Thank you so much Pedro 

Marco Mendoza

unread,
Apr 15, 2021, 6:32:28 PM4/15/21
to AequilibraE
Hi pedro and Gabriel

I have a new problem with Aequilibra, i made differents assignments but i had bad results because mi mtx have 109,000 trips and i i had 6037 in my total flow so y aggregated centroids to my project but now i have that problem nuevo problema.JPG

I fixed the problem in the line 241 so i don´t know what i´m doing bad or if it´s a bug 

i attach my project and my mtx, I would appreciate it if you could see it.

Marco

REDMB_PRUEBA_QGIS.rar

Andrés Abarca

unread,
Apr 16, 2021, 9:22:07 AM4/16/21
to Marco Mendoza, AequilibraE
Hi Marco,

I checked your data, it looks like there are 238 centroids in your demand matrix, but only 237 centroids in your network.

Your demand matrix has a node (node_id=249569) that is not in your network model, you probably missed that one.

Best,

Andres Abarca

Marco Mendoza

unread,
Apr 16, 2021, 1:39:45 PM4/16/21
to AequilibraE
Hi Andres 

Thanks a lot for your help Andres, My Project works now, and i had results as transcad 
MB.jpg




Best

Marco Mendoza
Reply all
Reply to author
Forward
0 new messages