Brief Introduction to Modeling and Optimization Software Chapter 3-4

advertisement
Brief Introduction to Modeling and Optimization
Software
(CPLEX, LINDO, LINGO, AMPLE, EXCEL Solver)
Based on
Chapter 3-4
Introduction to Mathematical Programming: Operations Research, Volume 1
4th edition, by Wayne L. Winston and Munirpallam Venkataramanan
Lewis Ntaimo
See the NEOS website for a list of state-of-the-art optimization software:
http://www-neos.mcs.anl.gov/neos/
1
L. Ntaimo (c) 2005 INEN420 TAMU
Input File Formats: LP, MPS, etc
LP Format for linear/integer programs:
OBJECTIVE
objective function
SUBJECT TO
constraints
END
Max 3x1 + 2x2
s.t. 2x1 + 5x2 <= 8
3x1 + 7x2 <= 10
End
Note that the non-negative
restrictions are implied by default.
Input file must be saved as: filename.lp for LP Format
filename.mps for MPS Format
2
L. Ntaimo (c) 2005 INEN420 TAMU
Example Using LINDO
Q. Solve the Dakota Problem using LINDO and Perform Sensitivity Analysis
Max 60x1 + 30x2 + 20x3
s.t. 8x1 + 6x2 +
x3 <= 48
4x1 + 2x2 + 1.5x3 <= 20
2x1 + 1.5x2 + 0.5x3 <= 8
END
1.
Create your text input file and save it as dakota.lp (LINDO allows you to save it
as dakota.ltx)
2.
Start LINDO
3.
Click on File and select Open to open your input file
4.
Click on Solve and select Solve to solve the LP
5.
LINDO will then ask: “Do range (sensitivity) analysis)?” Click on Yes.
6.
LINDO will the show the solution report!
3
L. Ntaimo (c) 2005 INEN420 TAMU
LINDO Solution Report for the Dakota Problem
LP OPTIMUM FOUND AT STEP 2
OBJECTIVE FUNCTION VALUE
1)
280.0000
VARIABLE
VALUE
REDUCED COST
X1
2.000000
0.000000
X2
0.000000
5.000000
X3
8.000000
0.000000
ROW SLACK OR SURPLUS DUAL PRICES
2)
24.000000
0.000000
3)
0.000000
10.000000
4)
0.000000
10.000000
NO. ITERATIONS=
2
RANGES IN WHICH THE BASIS IS UNCHANGED:
OBJ COEFFICIENT RANGES
VARIABLE
CURRENT
ALLOWABLE
ALLOWABLE
COEF
INCREASE
DECREASE
X1
60.000000
20.000000
4.000000
X2
30.000000
5.000000
INFINITY
X3
20.000000
2.500000
5.000000
ROW
2
3
4
RIGHTHAND SIDE RANGES
CURRENT
ALLOWABLE
ALLOWABLE
RHS
INCREASE
DECREASE
48.000000
INFINITY
24.000000
20.000000
4.000000
4.000000
8.000000
2.000000
1.333333
4
L. Ntaimo (c) 2005 INEN420 TAMU
Example Using CPLEX
Q. Solve the Dakota Problem using LINDO and Perform Sensitivity Analysis
Max 60x1 + 30x2 + 20x3
s.t. 8x1 + 6x2 +
x3 <= 48
4x1 + 2x2 + 1.5x3 <= 20
2x1 + 1.5x2 + 0.5x3 <= 8
END
1.
Create your text input file and save it as dakota.lp in some directory (e.g. c:\
INEN420Project). Note that for large models you may need to write a program in C, C++,
Java, etc, to create your input file in LP format.
2.
Open a DOS command window (Click on Start, Run and type cmd).
3.
Change from the default directory to c:\INEN420Project (Use Dos command cd).
4.
Start CPLEX by typing cplex at the Dos prompt.
5.
Once CPLEX is started, you can type help to get a list of commands.
6.
Type read dakota.lp. CPLEX reads in your LP data and is now ready to optimize it.
7.
Type opt or primopt to optimize your LP.
8.
Type display to display model data or solution (plus sensitivity analysis info) of your LP.
9.
Type write dakota.txt and CPLEX will write the solution report for you!
5
L. Ntaimo (c) 2005 INEN420 TAMU
CPLEX Solution Report for the Dakota Problem
PROBLEM NAME dakota.lp
DATA NAME
OBJECTIVE VALUE 280
STATUS
OPTIMAL SOLN
ITERATION
2
OBJECTIVE
RHS
RANGES
BOUNDS
obj
(MAX)
SECTION 1 - ROWS
NUMBER ......ROW....... AT ...ACTIVITY... SLACK ACTIVITY ..LOWER LIMIT. ..UPPER LIMIT. .DUAL ACTIVITY
1
2
3
4
obj
Lumb
Fini
Carp
BS
BS
UL
UL
280
24
20
8
-280
24
0
0
NONE
NONE
NONE
NONE
NONE
48
20
8
1
0
-10
-10
SECTION 2 - COLUMNS
NUMBER .....COLUMN..... AT ...ACTIVITY... ..INPUT COST.. ..LOWER LIMIT. ..UPPER LIMIT. .REDUCED COST.
5
6
7
x1
x2
x3
BS
LL
BS
2
0
8
60
30
20
0
0
0
NONE
NONE
NONE
0
-5
0
6
L. Ntaimo (c) 2005 INEN420 TAMU
LINGO, AMPLE, EXCEL
• Many LPs solved in practice contain 1000’s of constraints and decision variables.
• Few users of linear programming want to input the constraints and variables each time
such an LP is solved.
• For this reason most actual applications of LP use a matrix generators to simply
inputting of the LP data.
• Also, you can write your own program in C, C++, JAVA, etc, to read data and create
your input files (LP or MPS files).
• The packages LINGO and AMPLE are examples of sophisticated matrix generators
(and much more!)
• These packages are the so called optimization modeling languages that enable the
user to create many constraints or object function terms by typing one line.
• Excel has the capability to solve linear (and often nonlinear) programming problems
• Excel uses the Excel Solver
7
L. Ntaimo (c) 2005 INEN420 TAMU
Go out there and learn how to use different
optimization software!
Use HELP documentation to get started
INDIVIDUAL ASSIGNMENT: Due Tues, April 12, 2005
Reading:
LINDO: Section 4.9 page 158
LINGO: Section 410 page 163
EXCEL Section 4.17 page 202
Problem Solving:
Solve Example 6 of Chapter 3 (Diet Problem) on page 69 and perform sensitivity
analysis. Use the following software and compare the results:
(a)
LINDO
(b)
LINGO
(c)
CPLEX
(d)
EXCEL
8
L. Ntaimo (c) 2005 INEN420 TAMU
Download