/
README (full)
Welcome to Kiwi
Kiwi is an efficient C++ implementation of the Cassowary constraint solving algorithm. Kiwi is an implementation of the algorithm based on the seminal Cassowary paper. It is not a refactoring of the original C++ solver. Kiwi has been designed from the ground up to be lightweight and fast. Kiwi ranges from 10x to 500x faster than the original Cassowary solver with typical use cases gaining a 40x improvement. Memory savings are consistently > 5x.
In addition to the C++ solver, Kiwi ships with hand-rolled Python bindings.
How to use
C++ with CMake
Write the following in your CMakeLists.txt to include Kiwi as a dependency:
include(FetchContent)
FetchContent_Declare(
kiwi
GIT_REPOSITORY https://github.com/nucleic/kiwi
GIT_TAG {release name}
)
FetchContent_MakeAvailable(kiwi)
target_link_libraries(your_target PRIVATE kiwi::kiwi)
C++ code example:
#include <kiwi/kiwi.h>
#include <iostream>
int main() {
// initialize the solver
kiwi::Solver solver;
// initialize the variables
kiwi::Variable x = kiwi::Variable("x");
kiwi::Variable y = kiwi::Variable("y");
solver.addConstraint(x + y == 10);
solver.addConstraint(x - y == 4);
// solve the system of equations
solver.updateVariables();
std::cout << "x: " << x.value() << ", y: " << y.value() << std::endl;
// Output: x: 7, y: 3
return 0;
}
You can also use tests to see more examples of how to use the solver: SimlpexTest and SolverTest.
| dir | .github/ |
| dir | benchmarks/ |
| dir | debian/ |
| dir | docs/ |
| dir | kiwi/ |
| dir | py/ |
| dir | tests/ |
| file | .gitignore |
| file | .pre-commit-config.yaml |
| file | .readthedocs.yaml |
| file | CMakeLists.txt |
| file | LICENSE |
| file | MANIFEST.in |
| file | PKG-INFO |
| file | README.md |
| file | codecov.yml |
| file | lint_requirements.txt |
| file | pyproject.toml |
| file | releasenotes.rst |
| file | setup.cfg |
| file | setup.py |