This is a Gurobi Ruby binding based on C++ Gurobi API.
-
C++(g++) is installed.
-
Gurobi 5.5 is installed.
-
Environment variable GUROBI_HOME is set (e.g. /opt/gurobi550/linux64).
-
From rubygems.org
$ gem install gurobi
-
From github
-
download or ‘git clone’ like this:
$ mkdir [YOUR_WORK_DIR] $ cd [YOUR_WORK_DIR] $ git clone https://github.com/fuminori-ido/gurobi.git
-
rake build
$ cd gurobi $ rake build
-
install it
$ gem install pkg/gurobi-N.NN.NN.gem # replace N to actual version
-
Following model:
x1, x2, x3 >= 0 x3 <= 30 2*x1 + x2 + x3 <= 60 x1 + 2*x2 + x3 <= 60 maximize 15*x1 + 18*x2 + 30*x3
is written in following ruby code:
require 'gurobi' model = Gurobi::Model.new(Gurobi::Env.new) x1 = model.addVar(0, Gurobi::INFINITY, 0, Gurobi::CONTINUOUS, 'x1') x2 = model.addVar(0, Gurobi::INFINITY, 0, Gurobi::CONTINUOUS, 'x2') x3 = model.addVar(0, 30, 0, Gurobi::CONTINUOUS, 'x3') model.update model.addConstr(2*x1 + x2 + x3 <= 60) model.addConstr( x1 + 2*x2 + x3 <= 60) model.setObjective(15*x1 + 18*x2 + 30*x3, Gurobi::MAXIMIZE) model.optimize print "val = ", model.get_double(Gurobi::DoubleAttr::OBJ_VAL), "\n" print "x1 = ", x1.get_double(Gurobi::DoubleAttr::X), "\n" print "x2 = ", x2.get_double(Gurobi::DoubleAttr::X), "\n" print "x3 = ", x3.get_double(Gurobi::DoubleAttr::X), "\n"
See spec/ and sample/ for more examples.
-
generate document by:
$ rake yard
-
browse doc/frames.html
-
Some known memory leak exist.
-
Client/Server model is not implemented.
-
Fork it ( github.com/fuminori-ido/gurobi/fork )
-
Create your feature branch (‘git checkout -b my-new-feature`)
-
Commit your changes (‘git commit -am ’Add some feature’‘)
-
Push to the branch (‘git push origin my-new-feature`)
-
Create a new Pull Request