GithubHelp home page GithubHelp logo

jfinkels / birkhoff Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 3.0 166 KB

Birkhoff decomposition for doubly stochastic matrices.

Home Page: https://birkhoff.readthedocs.org

License: GNU General Public License v3.0

Python 100.00%

birkhoff's People

Contributors

jfinkels avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

birkhoff's Issues

Seems a bug for new version of numpy

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()))))").

test_birkhoff_von_neumann_decomposition failure

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.

Might be a bug in to_permutation_matrix?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.