M
Management t
Optimization Solvers
1
Learning Objectives & Reference
Master two optimization software packages:
Microsoft Excel Solver
AMPL (A
( Mathematical
h i l Programming
i Language))
References
Fourer, R. D., Gay, D. and Kernighan (2003) AMPL, A Modeling
Language for Mathematical Programming, 2nd edition.
Brooks/Cole-Thomson.
Handout for AMPL
Handout for Excel Solver
2
Contents
Introduction
oduc o too algorithms
go s solving
so v g LP,, N
NLP and
d IP
Microsoft Excel Solver
AMPL
3
Linear Programming Models – Algorithms
Simplex Method (G. B. Dantzig, 1947)
– An iterative method
x2
– From one vertex to another one 5
2x1+x2=5
– Terminated in the limited iterations 4
D
Example (1,3)
3 C
max f (x ) = 3x 1 + 2x 2 -x1+4x2=2
2
s.t.
B
x1 + x 2 ≤ 4 1 A x1+x2=4
2x 1 + x 2 ≤ 5 x1
−x 1 + 4x 2 ≥ 2 -2
2 -1
1 1 2 3 4 5
x 1, x 2 ≥ 0 3x1+2x2=2 3x1+2x2=4 3x1+2x2=9
4
Linear Programming Models – Algorithms (cont’d)
(cont d)
x1 x1
I t i point
Interior i t algorithm
l ith (Karmarkar,
(K k 1984)
N. Karmarkar. A new polynomial-time algorithm for linear programming. In
Proceedings of the Sixteenth Annual ACM Symposium on Theory of
Computing, pp. 302-311, Washington, D.C., 1984.
5
N li
Nonlinear Programming
P i Models
M d l – Optimal
O ti l Solutions
S l ti
Global minimum of a NLP (minimization problems)
x* is a feasible solution in the set Ω and we have f(x*)≤f(x) for any x in the
set Ω
Local minimum of a NLP (minimization problems)
x* is a feasible solution in the set Ω and we have f(x*)≤ f(x) for any x in
neighborhood
i hb h d off x* *
Optimality conditions
─ Karush-Kuhn-Tucker (KKT) conditions
Kuhn, H. W. and Tucker, A. W. (1951) Nonlinear Programming. J. Neyman (ed.)
Proceedings of the Second Berkeley Symposium on Mathematical Statistics and
Probabilities. University of California, Berkeley, pp. 481-492.
Karush, W. (1939) Minima of Functions of Several Variables with Inequalities as
Side Conditions
Conditions, MSc
MS Th
Thesis,
i D Department
t t off M
Mathematics,
th ti University
U i it off Chicago,
Chi
Chicago.
6
Nonlinear Programming Models – Algorithms
Gradient based algorithms
x2
min f (x ) = 3x 1 + 2x 2 Ω Set
Ω: S off ffeasible
ibl solutions
l i
4
s.t.
x1 + x 2 ≤ 4 Direction:∇f ( x ) = ( 3,
3 2)
(1)
3
2x 1 + x 2 ≤ 5 x(1)
2
−x 1 + 4x 2 ≥ 2
x 1, x 2 ≥ 0 1
Contour of the objective function d1
x1
Idea behind an algorithm for a NLP 1 2 3 4
3x1+2x2=5 3x +2x =9
3x1+2x2=2 1 2
– Given a feasible solution x(1)= (0.5, 1.75),
gradient of the objective function: ∇f ( x (1) ) = ( 3,
3 2)
–Observation: the objective function value will decrease if we move along the
negative gradient direction at point x(1) from that point
x(2)= x(1)+α1d1 where α1 is the step size
7
Integer Programming Models - Algorithms
Differences between solving a LP and an ILP
Example 1. A LP problem x2 Optimum: x1=3.75,
x2=1.25, f=23.75
max f ( x ) = 5 x1 + 4 x2 5
s.t.
4
x1 + x2 ≤ 5
10 x1 + 6 x2 ≤ 45 3
x1 , x2 ≥ 0 2
Example
E l 2.
2 An
A ILP problem
bl 1
x1
max f ( x ) = 5 x1 + 4 x2
0 1 2 3 4 5
s.t.
Optimum: x1=3,
x1 + x2 ≤ 5 x2=2, f = 23
10 x1 + 6 x2 ≤ 45 It seems that rounding off the optimal solution for
x1 , x2 ≥ 0 and integer Example 1 can yield the optimal solution for Example 2
8
Integer Programming Models – Algorithms (cont’d)
(cont d)
Example
p 3. A LP Problem
max f ( x1 , x2 ) = x1 + x2
Optimum:
s.t.
x1*=4,
* 4 x2*=4.5
* 45
−2 x1 + 2 x2 ≥ 1
−8 x1 + 10 x2 ≤ 13 f(x1*,x2*)=8.5
x1 , x2 ≥ 0
Example 4. An ILP Problem
max f ( x1 , x2 ) = x1 + x2
Optimum: It is necessary to
s.t.
x1*=1, x2*=2 develop dedicated
−2 x1 + 2 x2 ≥ 1
algorithms for IP
−8 x1 + 10 x2 ≤ 13 f(x1*,x2*)=3
x1 , x2 ≥ 0 and integer
9
Integer Programming Models – Algorithms (cont’d)
(cont d)
Existing
s g algorithms
go s
Cutting plane methods
Enumerative methods
10
O ti i ti Solvers
Optimization S l
Software Packages
CPLEX (http://www.ilog.com/products/cplex/)
LINDO (http://www.lindo.com/)
p )
AMPL (http://www.ampl.com/)
Add-in Solver in Microsoft Excel
(http://www.solver.com/)
11
Add-in Solver of Microsoft Excel
Solver in Microsoft Excel
A powerful add-in tool in Microsoft Excel, which is of capability in solving
− Linear p
programming
g g models
− Nonlinear programming models
− Integer programming models
Figure 1
Step 2.2: Move the mouse to the Set Target Cell portion of the dialog box and
click on the target cell (objective function) defined in Step 1 and select
min or max 13
Add-in Solver of Microsoft Excel (cont’d)
(cont d)
Step
p 2.3: Move the mouse to the By y Changing
g g Cells pportion of the dialog
g box
and click the changing cells (decision variables) defined in Step 1.
Step 2.4:
2 4: Click on the Add button to add constraints
constraints. The following screen will
appear. Move the Cell Reference part of the Add constraint dialog box
to add a constraint.
S 22.6:
Step 6 Click
Cli k on the
h Solve
S l button
b off Figure
Fi 1
14
Add-in Solver of Microsoft Excel (cont’d)
(cont d)
Three
ee Examples
p es
max z = 5 x1 + 4 x2 max z = 3 x1 + x2
subject to subject
bj t to
t
6 x1 + 4 x2 ≤ 24 17 x1 + 11x2 ≤ 86.5
− x1 + x2 ≤ 1 x1 + 2 x2 ≤ 10.2
10 2
x2 ≤ 2 x1 ≤ 3.87
x1 ≥ 0, x2 ≥ 0 x1 is a non-negative integer
x2 ≥ 0
15
Add-in Solver of Microsoft Excel (cont’d)
(cont d)
Example 3. PIP Example 4. NLP
6
min z = xi min f ( x ) = 0.04 x1 + 0.1x2 + 0.07 x3
i =1
subject to
subject to x1 + x2 + x3 = 100
x1 + x2 ≥ 1 0.01x2 + 0.001x22 ≤ 0.5
x1 + x2 + x6 ≥ 1 0.35 x1 − 0.04 x2 − 0.002 x12 ≥ −1
x3 + x4 ≥ 1 0.1x1 + 0.06 x2 − 0.3 x3 + 0.01x1 x2 + 0.05 x22 + 0.001x32 ≥ −9
0.1x1 + 0.06 x2 − 0.3 x3 + 0.01x1 x2 + 0.05 x22 + 0.001x32 ≤ 1
x3 + x4 + x5 ≥ 1
x1 ≥ 25
x4 + x5 + x6 ≥ 1
x1 ≤ 60
x2 + x5 + x6 ≥ 1 x2 ≥ 0
xi = 0 or 1,
1 i = 1,
1 22,,66 x3 ≥ 50
16
AMPL - Introduction
A modeling
ode g language
gu ge for
o mathematical
e c programming
p og g
AMPL is notable for the similarity of its arithmetic expressions to
customary algebraic notation,
AMPL is notable for the generality and power of its set and subscripting
expression.
AMPL was designed and implemented by Fourer, R. (Northwestern
University), Gay, G., and Kernighghan, B. W. (Princeton University) around
1985.
Editor
Edit
Notepad
Running environment
DOS
17
AMPL – A Rudimentary Format
Example
p e 1:: LP
AMPL Code
max z ( x ) = 5 x1 + 4 x2
var x1 >=0;
0;
subject var x2 >=0;
6 x1 + 4 x2 ≤ 24 maximize z: 5*x1+4*x2;
subject to
x1 + 2 x2 ≤ 6 c1: 6*x1+4*x2<=24;
c2: x1+2*x2<=6;
− x1 + x2 ≤ 1
c3
3: -x1+x2<=1;
1+ 2< 1
x2 ≤ 2 c4: x2<=2;
solve;
x1 , x2 ≥ 0 display z,x1,x2;
18
#--------------------------------------------AMPL model
param m;
AMPL – An Algebraic param n;
Model param c{1..n};
{1 }
param b{1..m};
max z ( x ) = x1 − x2 #
#------- Example -NLP
NLP
var x1>=0 :=10; #inital value = 10
subject to
var x2>=0 :=10; #initial value = 10
3 x14 + x2 ≤ 243
maximize z: x1-x2;
x1 + 2 x22 ≤ 32 subject to
x1 ≥ 2.1 c1:
1 3*x1^4+x2<=243;
3* 1^4+ 2< 243
c2: x1+2*x2^2<=32;
x2 ≥ 3.5 c3: x1>=2.1;
c4: x2>=3.5;
Remark:
solve;
An initial feasible solution display z,x1,x2;
should be provided by users
21