Jump to content

GLPK/Ruby

From Wikibooks, open books for an open world

Ruby is a general-purpose object-oriented programming language.

rglpk

[edit | edit source]

rglpk is a Ruby language binding for GLPK. It is licensed under the GNU Lesser General Public License, version 2.1. Rglpk is available as a gem (a packaged Ruby library) hosted on http://rubygems.org/gems/rglpk. The project homepage is http://rglpk.rubyforge.org/rglpk/.

Prerequisites

[edit | edit source]

Before installing rglpk, an appropriate version of GLPK must be installed. Use the following procedure to find out which version of GLPK is required

  • open http://rubygems.org/gems/rglpk
  • follow the download link (cookies must be enabled) and save the file
  • unpack the gem file — it is in tar.gz.tar file format (you can unpack it with 7-zip or tar)
  • unzip data.tar.gz
  • read file ChangLog.md

For instance, GLPK 4.44 is needed for rglpk-0.26.

Installation on GNU Linux

[edit | edit source]

rglpk is installed using the following command

gem install rglpk

Under Debian Wheezy, the following also worked

sudo apt-get install ruby1.9.1 ruby1.9.1-dev glpk
sudo gem install rglpk

Installation on Windows

[edit | edit source]

Prerequisites

[edit | edit source]

The development kit must be set up as described at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.

C:\Ruby193\bin\setrbvars.bat
cd C:\DevKit
ruby dk.rb init
ruby dk.rb install

Building GLPK

[edit | edit source]

As noted above, the GLPK version must match the rglpk version.

The following instructions worked for Ruby Installer 1.9.3-p0. Adjust the directories to suit your system

C:\DevKit\msys.bat
cd /C/temp/glpk-4.44
./configure
make
make check
make install
cp include/glpk.h /C/Ruby193/include/ruby-1.9.1
cp src/.libs/libglpk.a /C/Ruby193/lib
exit

Building rglpk

[edit | edit source]

Building and installing the gem is straightforward

gem install rglpk

Checking the installation

[edit | edit source]

You can check the installation by issuing

gem query local

Ffi-glpk

[edit | edit source]

Ruby-FFI is a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code.[1]. You can install ffi with

gem install ffi

Ffi-glpk[2] uses FFI to load the GLPK library and supplies wrapping for some of the API functions. It is published under a BSD license.

Ffi-glpk can be downloaded from [1].

References

[edit | edit source]
  1. "ffi". RubyGems.org. Retrieved 15 October 2011.
  2. "[annonce] ffi-glpk extension demonstrator for jruby". lists.gnu.org. Retrieved 15 October 2011.