2. Overview
• What is Linear Programming?
• Why one would like to use it?
• What is SCPSolver (not)?
• Demo
– Modelling for Beginners
– Modelling for Advanced Users
Hannes Planatscher 2
3. Linear Optimization
• „Linear Programming is a technique for the
optimization of a linear objective function
subject to linear objective function
n-dimensional linear constraints.“
n
max ci xi
i 1
subject to m linear constraints
n
aij xi b j ,1 j m
i 1
Hannes Planatscher 3
7. Location of global optima
If the linear program is
feasible and not
unbounded, the
optimum can be found
potential optimum
at a vertex, in special
x2 cases also at an
edge, of the polytope.
potential optimum potential optimum
feasible region
potential optimum
x1
Hannes Planatscher 7
8. Location of global optima
If the linear program is
feasible and not
unbounded, the
optimum can be found
optimum
at a vertex, in special
x2 cases also at an
edge, of the polytope.
x1
Hannes Planatscher 8
9. Location of global optima
If the linear program is
feasible and not
unbounded, the
optimum can be found
optimum
at a vertex, in special
x2 cases also at an
edge, of the polytope.
x1
9
10. Simplex
The Simplex
Algorithm visits one
vertex after another
until the optimum is
optimum
found.
x2
potential optimum potential optimum
feasible region
potential optimum
x1
10
11. Interior Point
Interior point
algorithms try find to
optimum starting from
within the feasible
optimum
region.
x2
potential optimum potential optimum
feasible region
potential optimum
x1
11
13. Why use Linear Programming?
• Even if the Simplex Algorithm has exponential
worst case complexity, it is very fast in most
real world scenarios.
• Very efficient solvers, which can solve linear
(integer) programs with several 100.000
variables and constraints, exist.
• If possible, always try to reformulate your
optimization problem as a Linear Program.
Hannes Planatscher 13
14. Linear Programming in Java
• Using existing Linear Programming Solvers in
Java programs is a pain, because of:
– platform dependency (.dll, .so, .jnilib)
– bad API s
– difficult deployment (where to put the libraries)
• You have to stick with its (usually bad)
API, once you have chosen a solver.
Hannes Planatscher 14
15. SCPSolver
• Main goals
– make it easy to develop
– keep the API lean
– get „platform
independent“
– automate binary library
deployment
– separate modelling from
the solver
• Not a goal: Write a new
Solver in Java!
Hannes Planatscher 15
18. Solver Packs
• Solvers
Solver Pack Jar
– lpsolve (Open Source)
– GLPK (Open Source) JNI Interface to solver
– CPLEX (closed
solver_x64.jnilib
• Platforms
– Linux 32/64-bit (tested: solver_x86.so
Ubuntu, Scientific Linux)
– Mac Os X 64-bit (> 10.5) solver_x86.dll
– Windows 32-bit(tested:
XP)
Hannes Planatscher 18
19. Solver Packs
• All libraries are as
statically linked as Solver Pack Jar
possible
JNI Interface to solver
• Minimal dependencies on
execution environment.
solver_x86.jnilib
• Advantage
– packs runs instantly on
solver_x86.so
many systems
• Disadvantage
solver_x86.dll
– the solver packs are pretty
large (lpsolve 1.3 MB, GLPK
2.3 MB, CPLEX 19 MB)
Hannes Planatscher 19
20. Farming
• Need to decide how much tons of wheat and/or rye to
produce.
• Rye earns 198 Euro/ton, wheat 226 Euro/ton
• Rye needs 0.2 ha/ton, wheat 0.15 ha/ton
• Rye needs 50 labour-units/ton, wheat 80 labour-
units/ton.
• 50 ha and 5000 labour-units available
• There are two barns, which can store up to 30 and 65
tons of one type of crop.
• Because of EU-Regulations we have to produce exact
integer tons of both crops.
Hannes Planatscher 20