GithubHelp home page GithubHelp logo

zebra's Introduction

zebra

requirements

  • jvm >9
  • leiningen

tested on

  • windows64
  • macosx
  • debian (x64)
  • manjaro (x64)

run the tests

lein test

examples

basic solver

(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

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

zebra's People

Contributors

hellonico avatar i-love-ramen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.