Debian Codegraph @

README.md

raw
1 # Welcome to Kiwi
2
3 [![Continuous Integration](https://github.com/nucleic/kiwi/workflows/Continuous%20Integration/badge.svg)](https://github.com/nucleic/kiwi/actions)
4 [![Documentation building](https://github.com/nucleic/kiwi/workflows/Documentation%20building/badge.svg)](https://github.com/nucleic/kiwi/actions)
5 [![codecov](https://codecov.io/gh/nucleic/kiwi/branch/main/graph/badge.svg)](https://codecov.io/gh/nucleic/kiwi)
6 [![Documentation Status](https://readthedocs.org/projects/kiwisolver/badge/?version=latest)](https://kiwisolver.readthedocs.io/en/latest/?badge=latest)
7
8 Kiwi is an efficient C++ implementation of the Cassowary constraint solving
9 algorithm. Kiwi is an implementation of the algorithm based on the
10 [seminal Cassowary paper](https://constraints.cs.washington.edu/solvers/cassowary-tochi.pdf).
11 It is *not* a refactoring of the original C++ solver. Kiwi has been designed
12 from the ground up to be lightweight and fast. Kiwi ranges from 10x to 500x
13 faster than the original Cassowary solver with typical use cases gaining a 40x
14 improvement. Memory savings are consistently > 5x.
15
16 In addition to the C++ solver, Kiwi ships with hand-rolled Python bindings.
17
18 # How to use
19 ## C++ with CMake
20 Write the following in your CMakeLists.txt to include Kiwi as a dependency:
21 ``` cmake
22 include(FetchContent)
23
24 FetchContent_Declare(
25 kiwi
26 GIT_REPOSITORY https://github.com/nucleic/kiwi
27 GIT_TAG {release name}
28 )
29
30 FetchContent_MakeAvailable(kiwi)
31
32 target_link_libraries(your_target PRIVATE kiwi::kiwi)
33 ```
34 C++ code example:
35 ``` cpp
36 #include <kiwi/kiwi.h>
37 #include <iostream>
38
39 int main() {
40 // initialize the solver
41 kiwi::Solver solver;
42 // initialize the variables
43 kiwi::Variable x = kiwi::Variable("x");
44 kiwi::Variable y = kiwi::Variable("y");
45 solver.addConstraint(x + y == 10);
46 solver.addConstraint(x - y == 4);
47 // solve the system of equations
48 solver.updateVariables();
49 std::cout << "x: " << x.value() << ", y: " << y.value() << std::endl;
50 // Output: x: 7, y: 3
51 return 0;
52 }
53 ```
54 You can also use tests to see more examples of how to use the solver: [SimlpexTest](https://github.com/nucleic/kiwi/blob/main/tests/SimplexTest.cpp) and [SolverTest](https://github.com/nucleic/kiwi/blob/main/tests/SolverTest.cpp).