djordon / queueing-tool

Simulator for queueing networks written in Python
http://queueing-tool.readthedocs.org/
MIT License
65 stars 10 forks source link

RuntimeWarning: node <num>, position [<float> <float>], expected two floats #90

Closed galenseilis closed 1 year ago

galenseilis commented 1 year ago

I ran this example:

import queueing_tool as qt
import networkx as nx
g = qt.generate_random_graph(200, seed=3)
q = qt.QueueNetwork(g, seed=3)
q.max_agents = 20000
q.initialize(100)
q.simulate(10000)

pos = nx.nx_agraph.graphviz_layout(g.to_undirected(), prog='fdp')
scatter_kwargs = {'s': 30}
q.draw(pos=pos, scatter_kwargs=scatter_kwargs, bgcolor=[0,0,0,0],
       figsize=(10, 16), fname='fig.png',
       bbox_inches='tight')

And I am getting these warnings:

Warning (from warnings module):
  File "/usr/local/lib/python3.10/dist-packages/pygraphviz/agraph.py", line 1405
    warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning)
RuntimeWarning: Warning: node 50, position [1.92072296 7.25669624], expected two floats
Warning: node 176, position [1.92746968 7.26167994], expected two floats
Warning: node 60, position [2.0937335  7.30708124], expected two floats
Warning: node 84, position [2.15949471 8.3176109 ], expected two floats
Warning: node 116, position [2.27712897 8.14782417], expected two floats
Warning: node 106, position [2.75508475 7.98718271], expected two floats
Warning: node 10, position [2.83525082 6.93137918], expected two floats
Warning: node 62, position [2.74780505 6.52223125], expected two floats
Warning: node 128, position [1.72518252 8.28431922], expected two floats
Warning: node 167, position [3.02819838 7.40813371], expected two floats
Warning: node 119, position [1.45289959 7.02020129], expected two floats
Warning: node 145, position [1.14932238 7.62115841], expected two floats
Warning: node 137, position [7.14886672 4.14418859], expected two floats
Warning: node 194, position [7.15881979 4.12382767], expected two floats
Warning: node 36, position [7.23939139 4.75088611], expected two floats
Warning: node 45, position [7.26319498 4.80239956], expected two floats
Warning: node 138, position [7.35324187 4.77091633], expected two floats
Warning: node 48, position [6.33665564 3.65940585], expected two floats
Warning: node 104, position [6.20512681 3.728115  ], expected two floats
Warning: node 130, position [6.75996587 4.4591411 ], expected two floats
Warning: node 131, position [6.71570248 4.60368504], expected two floats
Warning: node 81, position [6.98809998 4.82497042], expected two floats
Warning: node 61, position [6.5112277  4.78978297], expected two floats
Warning: node 73, position [7.27152079 3.59107525], expected two floats
Warning: node 189, position [7.55529477 3.88224195], expected two floats
Warning: node 94, position [7.42737274 3.04686433], expected two floats
Warning: node 72, position [6.94963435 8.41419619], expected two floats
Warning: node 92, position [7.00511779 8.40561085], expected two floats
Warning: node 141, position [6.68787578 7.88832343], expected two floats
Warning: node 149, position [6.74809935 7.90854183], expected two floats
Warning: node 111, position [6.79501804 7.95204587], expected two floats
Warning: node 47, position [6.60325906 9.13975267], expected two floats
Warning: node 68, position [6.91977512 8.95570328], expected two floats
Warning: node 28, position [7.07686622 7.46746223], expected two floats
Warning: node 18, position [6.53410903 5.57840762], expected two floats
Warning: node 152, position [6.50642177 5.43179455], expected two floats
Warning: node 42, position [6.81611779 5.41019673], expected two floats
Warning: node 148, position [6.09027444 4.9120313 ], expected two floats
Warning: node 160, position [8.23961181 4.86711189], expected two floats
Warning: node 162, position [7.44611447 5.52757262], expected two floats
Warning: node 169, position [5.7342128  7.31705676], expected two floats
Warning: node 29, position [6.91092922 6.89180414], expected two floats
Warning: node 187, position [6.19580347 6.97904746], expected two floats
Warning: node 31, position [3.39848664 5.7279387 ], expected two floats
Warning: node 171, position [3.46401703 5.7446946 ], expected two floats
Warning: node 1, position [2.90904739 5.10827605], expected two floats
Warning: node 198, position [2.83864183 5.34640509], expected two floats
Warning: node 197, position [3.63633868 4.90606702], expected two floats
Warning: node 154, position [4.52011616 5.34975579], expected two floats
Warning: node 30, position [3.73600124 6.68134805], expected two floats
Warning: node 182, position [4.24147247 6.19327273], expected two floats
Warning: node 9, position [2.59252447 4.15101197], expected two floats
Warning: node 117, position [2.64325527 4.10320205], expected two floats
Warning: node 24, position [2.77977507 4.54622076], expected two floats
Warning: node 86, position [2.79294597 4.30815022], expected two floats
Warning: node 32, position [3.25807158 4.45145049], expected two floats
Warning: node 75, position [3.13819115 4.19582757], expected two floats
Warning: node 108, position [2.4297818  4.79507305], expected two floats
Warning: node 199, position [2.09651068 4.94329576], expected two floats
Warning: node 184, position [3.44953463 3.9475187 ], expected two floats
Warning: node 192, position [2.92256776 3.8182504 ], expected two floats
Warning: node 102, position [1.83772318 4.36357084], expected two floats
Warning: node 183, position [2.03107657 3.28065744], expected two floats
Warning: node 21, position [2.69235578 2.91792774], expected two floats
Warning: node 22, position [4.57686399 8.60533913], expected two floats
Warning: node 127, position [4.65693071 8.57066433], expected two floats
Warning: node 66, position [5.40760836 8.37462433], expected two floats
Warning: node 153, position [5.57367388 8.68554634], expected two floats
Warning: node 133, position [5.08157429 8.7148954 ], expected two floats
Warning: node 14, position [3.87971258 9.3638365 ], expected two floats
Warning: node 12, position [5.44649018 7.80314765], expected two floats
Warning: node 170, position [5.50832596 9.39403478], expected two floats
Warning: node 69, position [3.40688484 0.64673198], expected two floats
Warning: node 136, position [3.45517339 0.56872574], expected two floats
Warning: node 59, position [4.1412692  0.49108924], expected two floats
Warning: node 113, position [3.90958016 0.46296203], expected two floats
Warning: node 17, position [3.77994041 0.92217009], expected two floats
Warning: node 156, position [4.31925319 1.02134221], expected two floats
Warning: node 88, position [8.36912139 5.3473487 ], expected two floats
Warning: node 144, position [5.06085262 5.67902174], expected two floats
Warning: node 159, position [5.16244481 5.70208238], expected two floats
Warning: node 103, position [4.97782831 5.83311915], expected two floats
Warning: node 55, position [4.85094226 4.55279361], expected two floats
Warning: node 177, position [5.43977954 5.34925335], expected two floats
Warning: node 120, position [5.6706655  6.11593836], expected two floats
Warning: node 151, position [6.31212112 5.76974895], expected two floats
Warning: node 6, position [6.49144048 2.78487283], expected two floats
Warning: node 163, position [6.23825086 2.70391997], expected two floats
Warning: node 23, position [5.86252904 2.83487862], expected two floats
Warning: node 35, position [6.91477511 6.50476858], expected two floats
Warning: node 7, position [6.76254902 5.90862817], expected two floats
Warning: node 126, position [7.35693387 6.32655774], expected two floats
Warning: node 25, position [2.05410345 2.01378711], expected two floats
Warning: node 158, position [2.09706436 2.16637262], expected two floats
Warning: node 79, position [2.04939769 2.4057032 ], expected two floats
Warning: node 56, position [2.17985768 1.77213381], expected two floats
Warning: node 3, position [1.2558531  2.07242878], expected two floats
Warning: node 107, position [1.53089301 2.23322973], expected two floats
Warning: node 39, position [1.51860997 1.00104345], expected two floats
Warning: node 67, position [1.70033544 2.60345073], expected two floats
Warning: node 13, position [3.06363532 2.21957884], expected two floats
Warning: node 188, position [2.91931186 2.92031987], expected two floats
Warning: node 52, position [8.50971417 5.43594327], expected two floats
Warning: node 180, position [8.20291205 5.72860711], expected two floats
Warning: node 99, position [8.84241431 4.45810179], expected two floats
Warning: node 64, position [0.70132505 0.57731488], expected two floats
Warning: node 100, position [0.68549918 0.76496282], expected two floats
Warning: node 93, position [0.45497306 0.55641541], expected two floats
Warning: node 147, position [1.26437305 0.72917094], expected two floats
Warning: node 109, position [0.00745522 0.30311361], expected two floats
Warning: node 175, position [0.41615642 1.20675067], expected two floats
Warning: node 157, position [1.37809893 0.02125558], expected two floats
Warning: node 87, position [5.394465   0.95566815], expected two floats
Warning: node 101, position [5.38792658 0.75566405], expected two floats
Warning: node 11, position [4.40453718 1.56867738], expected two floats
Warning: node 110, position [4.61548152 1.62520685], expected two floats
Warning: node 98, position [4.78915452 0.6227948 ], expected two floats
Warning: node 196, position [4.80691788 0.84221649], expected two floats
Warning: node 58, position [6.40176617 1.43332317], expected two floats
Warning: node 105, position [6.18736583 1.57244658], expected two floats
Warning: node 26, position [5.1403506  0.87229369], expected two floats
Warning: node 115, position [5.97003242 1.3421817 ], expected two floats
Warning: node 49, position [5.52844573 1.96380577], expected two floats
Warning: node 95, position [5.16784366 1.56262424], expected two floats
Warning: node 178, position [4.64536979 0.06694218], expected two floats
Warning: node 37, position [5.96663775 0.66969424], expected two floats
Warning: node 54, position [9.27936348 7.876182  ], expected two floats
Warning: node 164, position [9.37595008 7.69654715], expected two floats
Warning: node 16, position [9.02834109 8.45750871], expected two floats
Warning: node 143, position [9.19820614 8.62605087], expected two floats
Warning: node 44, position [9.26725684 8.39193058], expected two floats
Warning: node 90, position [9.65293351 7.51027307], expected two floats
Warning: node 2, position [8.92946954 8.96293089], expected two floats
Warning: node 77, position [8.8012479  7.98964319], expected two floats
Warning: node 195, position [9.13535812 7.19490499], expected two floats
Warning: node 46, position [8.42103186 7.44752323], expected two floats
Warning: node 15, position [9.75995422 6.72383676], expected two floats
Warning: node 181, position [1.96462961 9.20469425], expected two floats
Warning: node 82, position [2.87049765 8.33687884], expected two floats
Warning: node 135, position [2.51930303 9.04012472], expected two floats
Warning: node 140, position [2.90484896 9.00710867], expected two floats
Warning: node 190, position [1.52463261 9.05264901], expected two floats
Warning: node 19, position [3.61564763 2.25054505], expected two floats
Warning: node 96, position [9.7795241  5.02751048], expected two floats
Warning: node 125, position [9.7122223  4.81846389], expected two floats
Warning: node 63, position [9.56449511 4.35520556], expected two floats
Warning: node 193, position [9.78405152 4.36675741], expected two floats
Warning: node 161, position [8.91454599 3.9506079 ], expected two floats
Warning: node 78, position [9.71624297 3.67702983], expected two floats
Warning: node 40, position [1.29293865 5.53277732], expected two floats
Warning: node 165, position [1.45595029 5.3743437 ], expected two floats
Warning: node 8, position [0.23981882 5.58854088], expected two floats
Warning: node 172, position [0.50779979 5.53432834], expected two floats
Warning: node 146, position [1.73225007 5.33836041], expected two floats
Warning: node 53, position [0.8979087  4.88873245], expected two floats
Warning: node 186, position [1.69990018 6.03300263], expected two floats
Warning: node 71, position [7.41082406 1.58033655], expected two floats
Warning: node 74, position [7.26689751 1.39467124], expected two floats
Warning: node 123, position [7.06056184 0.61540716], expected two floats
Warning: node 155, position [6.90963704 0.89494991], expected two floats
Warning: node 43, position [7.07180601 2.63886671], expected two floats
Warning: node 132, position [7.80003222 1.13444084], expected two floats
Warning: node 89, position [7.74967815 2.30836266], expected two floats
Warning: node 4, position [0.51467203 4.40809844], expected two floats
Warning: node 121, position [0.42030851 4.17266895], expected two floats
Warning: node 5, position [0.29876211 4.56833224], expected two floats
Warning: node 185, position [0.22231887 6.60347052], expected two floats
Warning: node 20, position [4.06519916 4.68940249], expected two floats
Warning: node 70, position [8.64119669 2.90872446], expected two floats
Warning: node 85, position [8.48303897 3.14652999], expected two floats
Warning: node 134, position [9.27529276 2.20336332], expected two floats
Warning: node 142, position [8.95739531 2.50188942], expected two floats
Warning: node 118, position [9.35972176 2.75552463], expected two floats
Warning: node 0, position [5.50797903 7.08147823], expected two floats
Warning: node 112, position [5.78163359 6.94764977], expected two floats
Warning: node 173, position [4.19392944 9.83161788], expected two floats
Warning: node 179, position [3.92471914 9.98938441], expected two floats
Warning: node 91, position [3.43093864 9.48527647], expected two floats
Warning: node 124, position [2.94693499 9.88112753], expected two floats
Warning: node 33, position [0.61528931 2.42675422], expected two floats
Warning: node 38, position [0.72562138 1.98976026], expected two floats
Warning: node 41, position [1.87814825 9.52101243], expected two floats
Warning: node 65, position [0.82871019 9.59707187], expected two floats
Warning: node 129, position [0.42069523 8.66953692], expected two floats
Warning: node 191, position [0.1308281  8.86484408], expected two floats
Warning: node 57, position [0.73623669 8.92393188], expected two floats
Warning: node 168, position [0.39361448 7.46671091], expected two floats
Warning: node 51, position [7.84936703 9.72098364], expected two floats
Warning: node 150, position [9.82687493 0.84080681], expected two floats
Warning: node 166, position [9.95786306 0.49056333], expected two floats
Warning: node 83, position [8.72179508 0.92131592], expected two floats
Warning: node 174, position [9.45607319 1.38279415], expected two floats
Warning: node 114, position [4.39421533 3.71980312], expected two floats
Warning: node 139, position [5.00565554 4.1756191 ], expected two floats
Warning: node 27, position [4.83585532 3.62176212], expected two floats
Warning: node 80, position [8.27862801 9.65228149], expected two floats
Warning: node 34, position [9.71602606 2.30584204], expected two floats
Warning: node 76, position [8.77212039 1.53740209], expected two floats
Warning: node 122, position [0.04266434 2.46535469], expected two floats
Warning: node 97, position [8.29001078 0.74037796], expected two floats

What do these warnings mean?

djordon commented 1 year ago

Would you mind posting the versions of pygraphviz and networkx that are installed here? My first guess is that something changed in a version pygraphviz, but it's hard to say without knowing more.

galenseilis commented 1 year ago

Would you mind posting the versions of pygraphviz and networkx that are installed here? My first guess is that something changed in a version pygraphviz, but it's hard to say without knowing more.

pygraphviz: 1.10 networkx: 2.8.8

djordon commented 1 year ago

I haven't forgotten about this, I've just been a little busy lately. I will look into it further soon(ish).

djordon commented 1 year ago

Okay, finally got around to this and I was able to reproduce your warnings. I did the following

poetry new qt-pygraphvis-warnings
cd qt-pygraphvis-warnings
poetry add 'queueing-tool[plotting]'
poetry add pygraphviz
poetry add --groups dev ipython
source $(poetry env info --path)/bin/activate
ipython

And then ran exactly what you posted above. My pyproject.toml looks like this:

[tool.poetry]
name = "qt-pygraphvis-warnings"
version = "0.1.0"
description = ""
authors = ["djordon <dan.jordon@gmail.com>"]
readme = "README.md"
packages = [{include = "qt_pygraphvis_warnings"}]

[tool.poetry.dependencies]
python = "^3.9"
queueing-tool = {extras = ["plotting"], version = "^1.2.5"}
pygraphviz = "^1.11"

[tool.poetry.group.dev.dependencies]
ipython = "^8.14.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

I think this is more of a pygraphviz or networkx issue, since queueing-tool uses them under the hood. I was able to silence those warning by switching to a different graph layout program. Instead of using fdp I used dot and things worked as expected (as in no warnings). The only wrinkle is that the graph now looks a little different. Here is the code

import queueing_tool as qt
import networkx as nx
g = qt.generate_random_graph(200, seed=3)
q = qt.QueueNetwork(g, seed=3)
q.max_agents = 20000
q.initialize(100)
q.simulate(10000)

pos = nx.nx_agraph.graphviz_layout(g.to_undirected(), prog='dot')
scatter_kwargs = {'s': 30}
q.draw(pos=pos, scatter_kwargs=scatter_kwargs, bgcolor=[0,0,0,0],
       figsize=(10, 16), fname='fig-dot.png',
       bbox_inches='tight')

And here is the new graph:

Here is the graph with fdp layout program:

djordon commented 1 year ago

So, I don't think this is a queueing-tool issue. I'm glad you opened it since I didn't know that this happens, but there is not much I can do here to "fix it" besides up date the docs to use the different pygraphviz program layout (which is what I'll do).

galenseilis commented 1 year ago

@djordon I appreciate you looking into this issue at depth.