2Lingo Optimization Software Tier II: Case StudiesSection 1:Lingo Optimization Software
3Optimization 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 caseSoftware can be used to solve these problems more efficiently
4Optimization 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
5Optimization Software Some optimization examples have already been shown using ExcelAnother program, Lingo, will now be demonstratedA trial version of this software can be downloaded at
6LingoLingo is a program designed specifically for solving optimization problemsIt 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 declaredFor example, y = 3*x^2 is y = 3x2
7Lingo OperatorsMany of Lingo’s mathematical operators are similar to what Excel uses:Addition: + - Multiplication: *Subtraction: - - Division: /For exponents: X^nEquals: =Greater than or less than: > or <Note: Lingo accepts ‘<’ as being ‘<=’. It does not support strictly less than or greater than.
8Lingo Operators, con’t Absolute value of x: @abs(x) Natural log of@tan(x) (x in radians)To return integer portion of decimal@sign(x): returns -1 if x < 0, or else 1
9Lingo Operators, con’tFind max or min value in aTo find maximum or minimum of a function: max or minTo allow negativeLingo has a number of other operators, but these are the mathematical operators that are most likely to be used
10Using LingoOther operators, like logic operators, can be found in the help file’s complete list of operatorsNow that we have the mathematical operators that are likely to be used, we can demonstrate how Lingo works with some examplesLingo can be used strictly as an equation solver or as an optimizer
11Solve – to solve current problem set Lingo ScreenshotIf additional help is neededSolve – to solve current problem set
12Basic Equation SolverThis will find the intersection of the lines “y = 3x + 4” and “y = 5x + 1”
13Note: Lingo does not distinguish between small and capital letters SolutionNote: Lingo does not distinguish between small and capital letters
17Non-linear Difficulties Lingo is not designed to deal with non-linear equationsIt cannot find multiple solutionsThere is a problem with solving non-linear problems, especially if the solution is in the negative domain
18Maximum and MinimumThe maximum and minimum functions are the most important functions needed for optimization problemsThese functions are used as follows:max = objective function;min = objective function;
19Solving Optimization Problems Several optimization examples that were worked through in previous sections will now be solved using LingoThe first example is from the introduction section
25Negative ValuesLingo cannot automatically solve for a negative variable valueIf 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
26Attempting to Obtain a Negative Solution The following example will demonstrate what happens if a negative value is required to get an optimum solutionLingo will automatically solve for the optimum solution obtained from only positive variables, even if this is not the true optimum
28Attempting to Obtain a Negative Solution This solution is viable if the variable values must be positive, but this is not the true optimum
29Attempting to Obtain a Negative Solution These statements allow negative values to be used for these variables
30Attempting to Obtain a Negative Solution Now the true optimum is obtained, with negative variables
31Greater 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
33Example of < or >Clearly this is not correct as X1 was constrained to be greater than 0!
34Example 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.
35Example of < or >Variables now obey desired constraints. Objective just happens to be the same in this case.
36ConclusionsLingo is effective and efficient for solving optimization problems if they are linearIt is not designed to deal with non-linear problemsIt is not very good at dealing with non-linear problems, so these must be approached with cautionIt does not handle multiple maximum or minimum points very well in non-linear cases