Module: LPSolve

Extended by:
FFI::Library
Defined in:
lib/lp_select/lp_solve.rb

Overview


This module uses Ruby's DL library to dynamically load
the liblpsolve library, which is a linear equation solver.

The sourceforge summary says:
Mixed Integer Linear Programming (MILP) solver lp_solve solves pure linear, 
(mixed) integer/binary, semi-cont and special ordered sets (SOS) models.  
lp_solve is written in ANSI C and can be compiled on many different platforms 
like Linux and WINDOWS

Read more at http://sourceforge.net/projects/lpsolve/

This module mostly serves to load the file and attach to the 
API functions

Constant Summary collapse

LE =

Constants used when assigning constraints

1
EQ =

<=

3
GE =

2
CRITICAL =

Constants used for verbosity

1
SEVERE =
2
IMPORTANT =
3
NORMAL =
4
DETAILED =
5
FULL =
6
NOMEMORY =

Constants used for solve results

-2
OPTIMAL =
0
SUBOPTIMAL =
1
INFEASIBLE =
2
UNBOUNDED =
3
DEGENERATE =
4
NUMFAILURE =
5
USERABORT =
6
TIMEOUT =
7
PRESOLVED =
9
PROCFAIL =
10
PROCBREAK =
11
FEASFOUND =
12
NOFEASFOUND =
13

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.versionObject



144
145
146
147
148
149
150
151
152
# File 'lib/lp_select/lp_solve.rb', line 144

def self.version
  maj_ptr = FFI::MemoryPointer.new(:pointer, 1)
  min_ptr = FFI::MemoryPointer.new(:pointer, 1)
  rel_ptr = FFI::MemoryPointer.new(:pointer, 1)
  bld_ptr = FFI::MemoryPointer.new(:pointer, 1)
  LPSolve::lp_solve_version(maj_ptr, min_ptr, rel_ptr, bld_ptr)
  
  "#{maj_ptr.read_int}.#{min_ptr.read_int}.#{rel_ptr.read_int} build #{bld_ptr.read_int}"
end

Instance Method Details

#op_to_s(op_int) ⇒ Object

>=



39
40
41
42
43
44
45
# File 'lib/lp_select/lp_solve.rb', line 39

def op_to_s(op_int)
  case op_int
    when LPSelect::GE then ">="
    when LPSelect::LE then "<=" 
    when LPSelect::EQ then "=="
  end
end