Created
September 24, 2017 18:00
-
-
Save jyaif/91b8b9dc040a19623d9236235d196ab2 to your computer and use it in GitHub Desktop.
Kiwi usage example in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I couldn't find any example showing the how to use the C++ constraint | |
// solver library 'Kiwi' ( https://github.com/nucleic/kiwi ). | |
// | |
// Hopefully this Gist will save someone a couple of minutes. | |
// | |
// To build: | |
// clang++ main.cpp | |
#include <iostream> | |
#include "kiwi/kiwi.h" | |
int main() { | |
kiwi::Variable a, b, c; | |
kiwi::Constraint constraint1(a == b * 2 + 10); | |
kiwi::Constraint constraint2(2 * c == b - 10); | |
kiwi::Constraint constraint3(c == 3); | |
kiwi::Solver solver; | |
solver.addConstraint(constraint1); | |
solver.addConstraint(constraint2); | |
solver.addConstraint(constraint3); | |
solver.updateVariables(); | |
std::cout << a.value() << std::endl; | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment