Comments (6)
Can you please provide a reproducible test case. As small as possible preferably :)
Also, Kiwi should never return bad values, if it can't find a solution it should throw an unsatisfiable constraint exception. Are you perhaps eating an exception somewhere?
from kiwi.
Yes, I am trying to get a small example that triggers it. Will get back to you.
from kiwi.
@sccolbert Hi, I have found a inconsistent test, with the code below:
#include "kiwi.h"
#include <stdio.h>
using namespace kiwi;
int main(void)
{
Variable xl("xl"), xm("xm"), xr("xr");
Solver solver;
solver.addConstraint(xm*2 == xl + xr);
solver.addConstraint(xl + 10 <= xr);
solver.addConstraint(xr <= 100);
solver.addConstraint(xl >= 0);
solver.updateVariables();
printf("%g, %g, %g\n", xl.value(), xm.value(), xr.value());
solver.addEditVariable(xm, strength::strong);
solver.updateVariables();
printf("%g, %g, %g\n", xl.value(), xm.value(), xr.value());
solver.suggestValue(xm, 70);
solver.updateVariables();
printf("%g, %g, %g\n", xl.value(), xm.value(), xr.value());
return 0;
}
this is my result:
test
90, 95, 100
0, 5, 10
40, 70, 100
Hit any key to close this window...
it should be 65, 70, 75, but not 40, 70, 100, the second constraint missing.
I have found this here, this is the examples in the Cassowary algorithm paper.
could give some help about this? I'm trying implement this algorithm in pure Lua language and meet this issue.
from kiwi.
(40, 70, 100) is a solution to the problem, and so is (65, 70, 75). There may also be more valid solutions.
The problem as-written is underconstrained, so kiwi is just going to pick one of the solutions. Which one is picked is more or less random.
If your second constraint was ==
instead of <=
, or if you added another constraint to pin one of the values, you would get your desired solution.
Kiwi appears to be behaving as designed here.
from kiwi.
@sccolbert okay, my fault :( I just realize this fact, sorry for noise
from kiwi.
Closing as it appears to be normal
from kiwi.
Related Issues (20)
- Failed building wheel for kiwisolver :( HOT 4
- Cann't install on python 3.11b3 HOT 2
- 1.4.3 has no attribute __version__ HOT 2
- ERROR: Failed building wheel for kiwisolver: C2440: 'static_cast': cannot convert from 'expr_type' to 'type' HOT 2
- Provide cp311 releases HOT 1
- Objective cell memory leak? HOT 26
- Continuous fuzzing by way of Google's OSS-Fuzz HOT 1
- Tests fail on pypy
- #egg=kiwisolver See assertion error when installing kiwisolver HOT 4
- about duplicate constraints HOT 3
- Add Python API to get all constraints HOT 14
- Is it possible to get the absolute value of an expression? HOT 10
- Is it possible to tell the Solver to prefer smaller or larger solutions? HOT 3
- Missing type hint for `Constraint.violated()` HOT 1
- Python 3.12 manylinux wheels HOT 2
- PyInstaller executable with matplotlib cannot find _cext DLL HOT 6
- `top_level.txt` include a non existing module `src`
- DLL load failed while importing _cext HOT 2
- How do we define an "objective function" and maximize or minimize it? HOT 1
- On Windows 10 LTSC, import kiwisolver (and/or import matplotlib) fails with DLL _cext even after installing VS runtime (solution incl) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kiwi.