An open API service indexing awesome lists of open source software.

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

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

![](doc/feasible_region.png)

```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.