Comments (8)
I omitted stay constraints in my version. I found that for my purposes of typical application layout they weren't needed (such systems are typically well-constrained).
From what I've seen, stays are useful when doing pick-and-move type operations where the system is naturally under-constrained and the stays are needed to make it well-behaved.
Kiwi is fast for a couple of key reasons:
- There are no virtual functions in kiwi. Virtual classes take longer to instantiate and have non-trivial copy-semantics. The only exception is for the user data variable context, which is never copied.
- Variables are replaced in the solver with trivially-copyable symbols.
- Maps are implemented using sorted vectors instead of node-based containers. This makes them very cpu-cache friendly. Most of the speed and memory wins come from this point. Recompile after uncommenting this line and see for yourself (the difference is huge): https://github.com/nucleic/kiwi/blob/master/kiwi/maptype.h#L31
from kiwi.
It's good to hear stays can be removed without a problem for doing GUI layouts, I'll definitely give that a try and see if anyone actually misses them. Replacing the big polymorphic variables with symbols is also a very good idea! (I had already replaced all maps with sorted vectors and unordered_maps, might be a trivial optimization but like you said, it makes a huge difference.)
Thank you for the detailed answer!
from kiwi.
Is there any way to work around this (read hack), or extend current code base? I'm not very (read barely) familiar with the implementation-details of cassowary & stays, but they are vital in my case since I use the solver in a "drag-n-drop" editor which is at most times under-constrained...
Is it possible without too much trouble?
from kiwi.
You can probably work-around it by adding non-required ==
constraints for the variables which should remain in their current location. When editing parameters, remove the the ==
constraints and use suggestValue
for the variables which should be edited.
from kiwi.
Yeah thought about that, but I want to avoid this since then I have to keep adding/removing constraints when moving vars around which might cause performance issues...
Just looked over another implementation of cassowary and stay-constraints seem to be highly embedded (lots of nasty if/else special cases), which is what I feared.
from kiwi.
In my experience cassowary is solving things very quickly. I wouldn't worry about performance issues.
from kiwi.
Been having some issues with older implementations which is why I set my hopes for this one, but then again I'm running on mobile devices so every inch counts!
But yeah I might be able to mimic it with equal-constraints without to much effort... :)
from kiwi.
I'm also on mobile c++ (ios). The java implementation seems slower.
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.