36
Process O ptim ization

Tier II: Case Studies Section 1: Lingo Optimization Software

Embed Size (px)

Citation preview

Page 1: Tier II: Case Studies Section 1: Lingo Optimization Software

Process Optimization

Page 2: Tier II: Case Studies Section 1: Lingo Optimization Software

Tier II: Case Studies

Section 1:

Lingo Optimization Software

Page 3: Tier II: Case Studies Section 1: Lingo Optimization Software

Optimization Software

• Many of the optimization methods previously outlined can be tedious and require a lot of work to solve, especially as models get more complex and move beyond two or three variables, which will often be the case

• Software can be used to solve these problems more efficiently

Page 4: Tier II: Case Studies Section 1: Lingo Optimization Software

Optimization Software

• Software that is available usually uses the same methods previously outlined, but can of course perform the calculations quicker, allowing the effect of variations in the model to be studied more easily

Page 5: Tier II: Case Studies Section 1: Lingo Optimization Software

Optimization Software

• Some optimization examples have already been shown using Excel

• Another program, Lingo, will now be demonstrated

• A trial version of this software can be downloaded at www.lindo.com/cgi/frameset.cgi?leftlingo.html;lingof.html

Page 6: Tier II: Case Studies Section 1: Lingo Optimization Software

Lingo

• Lingo is a program designed specifically for solving optimization problems

• It uses a syntax that is similar to what would be written by hand, or what would be used in Excel, not requiring variables to be declared

• For example, y = 3*x^2 is y = 3x2

Page 7: Tier II: Case Studies Section 1: Lingo Optimization Software

Lingo Operators

• Many of Lingo’s mathematical operators are similar to what Excel uses:– Addition: + - Multiplication: *– Subtraction: - - Division: /– For exponents: X^n– Equals: =– Greater than or less than: > or <

• Note: Lingo accepts ‘<’ as being ‘<=’. It does not support strictly less than or greater than.

Page 8: Tier II: Case Studies Section 1: Lingo Optimization Software

Lingo Operators, con’t

• Absolute value of x: @abs(x)

• Natural log of x: @log(x)

• Trigonometric functions: @sin(x), @cos(x), @tan(x) (x in radians)

• Exponentials: @exp(x)

• To return integer portion of decimal number: @floor(x)

• @sign(x): returns -1 if x < 0, or else 1

Page 9: Tier II: Case Studies Section 1: Lingo Optimization Software

Lingo Operators, con’t

• Find max or min value in a set: @smax(x1,x2…,xn) or @smin(x1,x2…,xn)

• To find maximum or minimum of a function: max or min

• To allow negative variables: @free(x)

• Lingo has a number of other operators, but these are the mathematical operators that are most likely to be used

Page 10: Tier II: Case Studies Section 1: Lingo Optimization Software

Using Lingo

• Other operators, like logic operators, can be found in the help file’s complete list of operators

• Now that we have the mathematical operators that are likely to be used, we can demonstrate how Lingo works with some examples

• Lingo can be used strictly as an equation solver or as an optimizer

Page 11: Tier II: Case Studies Section 1: Lingo Optimization Software

Lingo ScreenshotSolve – to solve

current problem setIf additional help is

needed

Page 12: Tier II: Case Studies Section 1: Lingo Optimization Software

Basic Equation Solver

This will find the intersection of the lines “y = 3x + 4” and

“y = 5x + 1”

Page 13: Tier II: Case Studies Section 1: Lingo Optimization Software

Solution

Note: Lingo does not distinguish between small and capital letters

Page 14: Tier II: Case Studies Section 1: Lingo Optimization Software

Equation Solver #2

Page 15: Tier II: Case Studies Section 1: Lingo Optimization Software

Solution #2

Only one solution was found! There should be two solutions to this

problem. The solver automatically stops when it finds the first solution.

Page 16: Tier II: Case Studies Section 1: Lingo Optimization Software

Solution #2

-5

0

5

10

15

20

-5 0 5 10 15

X

Y

3.2087

3.2087

7.791

7.791

Page 17: Tier II: Case Studies Section 1: Lingo Optimization Software

Non-linear Difficulties

• Lingo is not designed to deal with non-linear equations

• It cannot find multiple solutions

• There is a problem with solving non-linear problems, especially if the solution is in the negative domain

Page 18: Tier II: Case Studies Section 1: Lingo Optimization Software

Maximum and Minimum

• The maximum and minimum functions are the most important functions needed for optimization problems

• These functions are used as follows:

max = objective function;

min = objective function;

Page 19: Tier II: Case Studies Section 1: Lingo Optimization Software

Solving Optimization Problems

• Several optimization examples that were worked through in previous sections will now be solved using Lingo

• The first example is from the introduction section

Page 20: Tier II: Case Studies Section 1: Lingo Optimization Software

Chemical Plant Example

• Objective: Maximize 1000x1 + 1500x2

• Constraints:4x1 + 2x2 <= 80

2x1 + 5x2 <= 60

4x1 + 4x2 <= 75

x1, x2 >= 0

Page 21: Tier II: Case Studies Section 1: Lingo Optimization Software

Chemical Plant Example

Page 22: Tier II: Case Studies Section 1: Lingo Optimization Software

Lingo Solution

Solution, including value of objective

function at optimum and optimum point

Page 23: Tier II: Case Studies Section 1: Lingo Optimization Software

Transportation Scheme Problem

Page 24: Tier II: Case Studies Section 1: Lingo Optimization Software

Problem #2 Solution

Page 25: Tier II: Case Studies Section 1: Lingo Optimization Software

Negative Values

• Lingo cannot automatically solve for a negative variable value

• If it is suspected that a solution will be negative, then that variable will need to be specifically declared as free:

@free(x);• It is a good idea to declare all variables

like this, unless of course a negative value is infeasible

Page 26: Tier II: Case Studies Section 1: Lingo Optimization Software

Attempting to Obtain a Negative Solution

• The following example will demonstrate what happens if a negative value is required to get an optimum solution

• Lingo will automatically solve for the optimum solution obtained from only positive variables, even if this is not the true optimum

Page 27: Tier II: Case Studies Section 1: Lingo Optimization Software

Attempting to Obtain a Negative Solution

Page 28: Tier II: Case Studies Section 1: Lingo Optimization Software

Attempting to Obtain a Negative Solution

This solution is viable if the

variable values must be positive,

but this is not the true optimum

Page 29: Tier II: Case Studies Section 1: Lingo Optimization Software

Attempting to Obtain a Negative Solution

These statements allow negative values to be used for

these variables

Page 30: Tier II: Case Studies Section 1: Lingo Optimization Software

Attempting to Obtain a Negative Solution

Now the true optimum is

obtained, with negative variables

Page 31: Tier II: Case Studies Section 1: Lingo Optimization Software

Greater Than or Less Than

• Another potential problem that will be encountered using Lingo is that it treats < the same as <=, and > the same as >=

• Thus, if a variable must be strictly greater than a value, the constraint is best treated as follows:– For x > A, where A is a solution otherwise, use

x > A + b; where b is an arbitrary value, like 0.1, that covers a portion where the solution will not lie

Page 32: Tier II: Case Studies Section 1: Lingo Optimization Software

Example of < or >

Page 33: Tier II: Case Studies Section 1: Lingo Optimization Software

Example of < or >

Clearly this is not correct as X1 was constrained to be

greater than 0!

Page 34: Tier II: Case Studies Section 1: Lingo Optimization Software

Example of < or >

This will now force X1 and X2 to be greater than 0. We can do this because we know X1 and X2 are also greater than

0.1.

Page 35: Tier II: Case Studies Section 1: Lingo Optimization Software

Example of < or >

Variables now obey desired constraints.

Objective just happens to be the same in this case.

Page 36: Tier II: Case Studies Section 1: Lingo Optimization Software

Conclusions

• Lingo is effective and efficient for solving optimization problems if they are linear

• It is not designed to deal with non-linear problems

• It is not very good at dealing with non-linear problems, so these must be approached with caution

• It does not handle multiple maximum or minimum points very well in non-linear cases