jfinkels / birkhoff Goto Github PK
View Code? Open in Web Editor NEWBirkhoff decomposition for doubly stochastic matrices.
Home Page: https://birkhoff.readthedocs.org
License: GNU General Public License v3.0
Birkhoff decomposition for doubly stochastic matrices.
Home Page: https://birkhoff.readthedocs.org
License: GNU General Public License v3.0
For the latest version of numpy (1.19.0 at 2022.7), the code can not get a result. I check the code, and find that the line 62 in the birkhoff.py ( print(list(zip(*(matches.items())))) ) seems don't work correctly.
When replace the "list" with "tuple", it works well. (The line 62 is "print(tuple(zip(*(matches.items()))))").
Running on Fedora 27
pip3 install nose networkx birkhoff numpy --user
Run the test_birkhoff_von_neumann_decomposition() function with the following result
>>> test.test_birkhoff_von_neumann_decomposition()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tbottom/test.py", line 55, in test_birkhoff_von_neumann_decomposition
actual = birkhoff_von_neumann_decomposition(D)
File "/home/tbottom/.local/lib/python3.6/site-packages/birkhoff/decompose.py", line 173, in birkhoff_von_neumann_decomposition
M = hopcroft_karp_matching(G)
File "/home/tbottom/.local/lib/python3.6/site-packages/birkhoff/matching.py", line 98, in hopcroft_karp_matching
left, right = bipartite_sets(G)
File "/home/tbottom/.local/lib/python3.6/site-packages/networkx/algorithms/bipartite/basic.py", line 203, in sets
raise nx.AmbiguousSolution(msg)
networkx.exception.AmbiguousSolution: Disconnected graph: Ambiguous solution for bipartite sets.
Hi,
Currently I'm using you birkhoff module, it works fine in most cases, great work!
However, in the to_permutation_matrix(matches) functions, the length of matches might be different from the input matrix S(D) 's degree (m,n) (Somehow? I'm not sure about the algorithm itself.In the test, sometimes it works fine but sometimes failed), leading to a index_out_of_range exception, since you are using len(matches) as the length of returned matrix P.
After I create the right length of P in to_permutation_matrix(), it works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.