https://github.com/hellonico/zebra
Google's ortools with Clojure
https://github.com/hellonico/zebra
Last synced: 11 months ago
JSON representation
Google's ortools with Clojure
- Host: GitHub
- URL: https://github.com/hellonico/zebra
- Owner: hellonico
- License: epl-1.0
- Created: 2018-10-26T04:31:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-31T07:39:26.000Z (over 7 years ago)
- Last Synced: 2025-03-01T19:02:43.788Z (about 1 year ago)
- Language: Clojure
- Size: 12.6 MB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# zebra
# requirements
- jvm >9
- leiningen
# tested on
- windows64
- macosx
- debian (x64)
- manjaro (x64)
# run the tests
```
lein test
```
# examples
## basic solver
```clojure
(let [solver (new-mpsolver "myprogram" "GLOP_LINEAR_PROGRAMMING")
x (.makeNumVar solver 0.0 1.0 "x")
y (.makeNumVar solver 0.0 2.0 "y")
objective (.objective solver)]
(.setMaximization objective)
(.solve solver)
(is (= 1.0 (.solutionValue x)))
(is (= 2.0 (.solutionValue y))))
```
## simple linear problem

```clojure
(let [solver (new-mpsolver "myprogram" "GLOP_LINEAR_PROGRAMMING")
x (.makeNumVar solver 0.0 infinity "x")
y (.makeNumVar solver 0.0 infinity "y")
objective (.objective solver)]
(doto objective
(.setCoefficient x 3)
(.setCoefficient y 4)
(.setMaximization))
(doto
(.makeConstraint solver -infinity 14.0) ; x + 2y <= 14
(.setCoefficient x 1)
(.setCoefficient y 2))
(doto
(.makeConstraint solver 0.0 infinity) ; 3x - y >= 0
(.setCoefficient x 3)
(.setCoefficient y -1))
(doto
(.makeConstraint solver -infinity 2.0) ; x - y <= 2
(.setCoefficient x 1)
(.setCoefficient y -1))
(.solve solver)
(is (=== (.solutionValue x) 6))
(is (=== (.solutionValue y) 4))
(is (=== (.value (.objective solver)) 34)))
```
A Clojure library designed to work with or-tools from google.
https://github.com/google/or-tools
Copyright © 2018 hellonico
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.