Open earthlyreason opened 3 years ago
That's great investigative work Gavin, thank you for filling this! I don't have any bandwidth to address this problem any time soon, but if you provide a PR I will try to verify and merge it quickly. Cheers!
Sure thing. I should say, that since I did not understand the Simplex algorithm very well to begin with, I ended up reading the literature and writing my own basic implementation in order to learn it. I am currently working through the Cassowary papers and am quite impressed how you got so much into such a compact program. However, I'm not 100% sure I'm going to come out of this yak shave.
Well, frankly you probably already know more than me in this area 😅 This project was originally written by Chris Colbert and based on the algorithms of the kiwi C++ constraint solver (https://github.com/nucleic/kiwi). I found it useful and used it in https://github.com/IjzerenHein/autolayout.js and after a couple years of laying dormant decide to publish it, as I felt it could be useful to other folks as well. That being said, I don't really actively use kiwi.js in any of my work right now. Feel free to post a PR though, I'll review it 👍
Hi, thanks for this project. It is small and easy to work with.
I have found what appears to be a bug in the handling of certain state changes.
As far as I can tell, the only way to know whether a new constraint will lead to a feasible solution is to try adding it and trap the "unsatisfiable constraint" error.
In such cases, the new constraint is not added to the solver.
However, the solver no longer behaves as expected at that point. Specifically, if a previously-existing constraint is then removed and re-added to the solver, it is then reported as unsatisfiable, even though it had already been confirmed.
The following script reproduces the issue:
I have tried other things at this point. For example, you can add effectively the same constraint using a new variable:
All in all, the signs point to a possible issue with the internal management of variables in the
Solver.addConstraint
method, particularly:I hate to file a bug on a holiday, but I thought it might be useful to have for reference. I will dig into this further myself and report back.