8
1 L. Ntaimo (c) 2005 INEN420 TAMU 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/

Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

  • Upload
    lediep

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

1

L. Ntaimo (c) 2005 INEN420 TAMU

Brief Introduction to Modeling and Optimization Software

(CPLEX, LINDO, LINGO, AMPLE, EXCEL Solver)

Based onChapter 3-4

Introduction to Mathematical Programming: Operations Research, Volume 14th 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/

Page 2: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

2

L. Ntaimo (c) 2005 INEN420 TAMU

Input File Formats: LP, MPS, etc

OBJECTIVE objective function

SUBJECT TO

constraints

END

LP Format for linear/integer programs:

Max 3x1 + 2x2 s.t. 2x1 + 5x2 <= 8

3x1 + 7x2 <= 10End

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

Page 3: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

3

L. Ntaimo (c) 2005 INEN420 TAMU

Example Using LINDO

Q. Solve the Dakota Problem using LINDO and Perform Sensitivity Analysis

Max 60x1 + 30x2 + 20x3s.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 LINDO3. Click on File and select Open to open your input file4. Click on Solve and select Solve to solve the LP5. LINDO will then ask: “Do range (sensitivity) analysis)?” Click on Yes.6. LINDO will the show the solution report!

Page 4: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

4

L. Ntaimo (c) 2005 INEN420 TAMU

LINDO Solution Report for the Dakota Problem

LP OPTIMUM FOUND AT STEP 2OBJECTIVE FUNCTION VALUE1) 280.0000

VARIABLE VALUE REDUCED COSTX1 2.000000 0.000000X2 0.000000 5.000000X3 8.000000 0.000000ROW SLACK OR SURPLUS DUAL PRICES2) 24.000000 0.0000003) 0.000000 10.0000004) 0.000000 10.000000

NO. ITERATIONS= 2RANGES IN WHICH THE BASIS IS UNCHANGED:

OBJ COEFFICIENT RANGESVARIABLE CURRENT ALLOWABLE ALLOWABLE

COEF INCREASE DECREASEX1 60.000000 20.000000 4.000000X2 30.000000 5.000000 INFINITYX3 20.000000 2.500000 5.000000

RIGHTHAND SIDE RANGESROW CURRENT ALLOWABLE ALLOWABLE

RHS INCREASE DECREASE2 48.000000 INFINITY 24.0000003 20.000000 4.000000 4.0000004 8.000000 2.000000 1.333333

Page 5: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

5

L. Ntaimo (c) 2005 INEN420 TAMU

Example Using CPLEXQ. Solve the Dakota Problem using LINDO and Perform Sensitivity Analysis

Max 60x1 + 30x2 + 20x3s.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!

Page 6: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

6

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 obj (MAX)RHS RANGES BOUNDS

SECTION 1 - ROWS

NUMBER ......ROW....... AT ...ACTIVITY... SLACK ACTIVITY ..LOWER LIMIT. ..UPPER LIMIT. .DUAL ACTIVITY

1 obj BS 280 -280 NONE NONE 12 Lumb BS 24 24 NONE 48 03 Fini UL 20 0 NONE 20 -104 Carp UL 8 0 NONE 8 -10

SECTION 2 - COLUMNS

NUMBER .....COLUMN..... AT ...ACTIVITY... ..INPUT COST.. ..LOWER LIMIT. ..UPPER LIMIT. .REDUCED COST.

5 x1 BS 2 60 0 NONE 06 x2 LL 0 30 0 NONE -57 x3 BS 8 20 0 NONE 0

Page 7: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

7

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

Page 8: Brief Introduction to Modeling and Optimization Softwareise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Optimization... · Brief Introduction to Modeling and Optimization Software

8

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, 2005Reading:

LINDO: Section 4.9 page 158LINGO: Section 410 page 163EXCEL 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