Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas

LINGO - MANUAL PARA PRINCIPAIS FUNCOES, Manuais, Projetos, Pesquisas de Pesquisa Qualitativa

LINGO - MANUAL PARA PRINCIPAIS FUNCOES

Tipologia: Manuais, Projetos, Pesquisas

2019

Compartilhado em 12/08/2019

cristiano-damaceno-12
cristiano-damaceno-12 🇧🇷

1 documento

1 / 18

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
LINGO 8.0 TUTORIAL
Created by:
Kris Thornburg
Anne Hummel
Table of Contents
Introduction to LINGO 8.0………………………………………………………………………..2
Creating a LINGO Model…………………………………………………………………………3
Solving a LINGO Model………………………………………………………………………….4
Using Sets in LINGO……………………………………………………………………………..6
The LINGO Data Section…………………………………………………………………………8
Variable Types in LINGO…………………………………………………………………….…10
Navigating the LINGO Interface…………………………………………………………….…..11
LINGO Operators and Functions………………………………………………………………...14
Common LINGO Error Messages……………………………………………………………….16
LINGO Programming Examples………………………………………………………………...17
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Pré-visualização parcial do texto

Baixe LINGO - MANUAL PARA PRINCIPAIS FUNCOES e outras Manuais, Projetos, Pesquisas em PDF para Pesquisa Qualitativa, somente na Docsity!

LINGO 8.0 TUTORIAL

Created by:

Kris Thornburg

Anne Hummel

Table of Contents

Introduction to LINGO 8.0………………………………………………………………………..

Creating a LINGO Model…………………………………………………………………………

Solving a LINGO Model………………………………………………………………………….

Using Sets in LINGO……………………………………………………………………………..

The LINGO Data Section…………………………………………………………………………

Variable Types in LINGO…………………………………………………………………….…

Navigating the LINGO Interface…………………………………………………………….…..

LINGO Operators and Functions………………………………………………………………...

Common LINGO Error Messages……………………………………………………………….

LINGO Programming Examples………………………………………………………………...

Introduction to LINGO 8.

LINGO is a software tool designed to efficiently build and solve linear, nonlinear, and integer optimization models.

LINGO 8.0 includes several new features, including:

  • A new global solver to confirm that the solution found is the global optimum,
  • Multistart capability to solve problems more quickly,
  • Quadratic recognition and solver to identify quadratic programming (QP) problems,
  • A faster and more robust Dual Simplex solver,
  • An improved integer solver to enhance performance in solving many types of problems,
  • Linearization capability to transform common nonsmooth functions to a series of linear functions,
  • Infeasible and unbounded analytical tools to help identify model definition problems,
  • A decomposition feature to identify if a model contains independent submodels,
  • A threadsafe DLL for various classes of models, and
  • More fun than ever before!

Solving a LINGO Model

Once the LINGO model has been entered into the LINGO Model window, the model can be solved by clicking the Solve button on the toolbar, by selecting LINGO | Solve from the menus, or by using the ctrl + s keyboard shortcut.

LINGO will notify you of any errors it has encountered. The best way to get information about these errors is to consult the Error Messages section in the software’s proprietary tutorial.

If no errors are found, then the LINGO Solver Status window appears.

This window provides information on the number of nonlinear, integer, and total variables in the model; the nonlinear and total number of constraints used in the model; and the number of nonlinear and total nonzero variable coefficients used. The Solver Status box in this window details the model classification (LP, QP, ILP, IQP, NLP, etc.), state of the current solution (local or global optimum, feasible or infeasible, etc.), the value of the objective function, the infeasibility of the model (amount constraints are violated by), and the number of iterations required to solve the model. The Extended Solver Status box details similar information for the more advanced branch-and-bound, global, and multistart solvers.

By closing this window, you can then view the Solution Report window.

This window shows the values of each variable that will produce the optimal value of the objective function.

The reduced cost for any variable that is included in the optimal solution is always zero. For variables not included in the optimal solution, the reduced cost shows how much the value of the objective function would decrease (for a MAX problem) or increase (for a MIN problem) if one unit of that variable were to be included in the solution. For example, if the reduced cost of a certain variable was 5, then the optimal value of the MAX problem would decrease by 5 units if 1 unit of the variable were to be added.

The Slack or Surplus column in the Solution Report shows how tight the constraint is. If a constraint is completely satisfied as an equality, then slack/surplus is zero. If slack/surplus is positive, then this tells you how many more units of the variable could be added to the optimal solution before the constraint becomes an equality. If slack/surplus is negative, then the constraint has been violated.

The Dual Price column describes the amount to which the value of the objective function would improve if the constraining value is increased by one unit.

Several set looping functions are also available for use in LINGO. These functions are as follows:

  • @FOR – generates constraints over members of a set.
  • @SUM – sums an expression over all members of the set.
  • @MIN – computes the minimum of an expression over all members of the set.
  • @MAX – computes the maximum of an expression over all members of the set.

Each of the above looping functions has a similar form of syntax and the looping functions can even be nested. Examples of expressions using each type of looping function are as follows:

  • This @FOR statement sets the hauling capacity for all 27 delivery trucks in the Trucks set to at most 3000 pounds:

@FOR(Trucks(T): Capacity(T)<=3000);

  • This @SUM statement calculates the total hauling capacity from the individual trucks:

TOTAL_HAUL=@SUM(Trucks(J): Capacity(J));

  • These @MIN and @MAX statements find the extreme hauling capacity levels from the individual delivery trucks:

MIN_HAUL = @MIN(Trucks(J): Capacity(J)); MAX_HAUL = @MAX(Trucks(J): Capacity(J));

The LINGO Data Section

LINGO provides a separate section called the DATA section in which values can be defined for different variables. Set members can be initialized in this section, attributes of the sets can be defined, or scalar variable parameters can be assigned values as well.

The DATA section is defined after the SETS section is defined in the model. The section begins with the tag DATA: and ends with the tag ENDDATA. Statements within the DATA section follow the syntax: object_list = value_list;

The object list contains the names of the attributes or of the set whose values are being initialized. The value list assigns the values to the specified members of the object list.

The following examples show two ways to use the DATA section in LINGO. In each example, the X and Y attributes of SET1 are being initialized to [1, 2, 3] and [4, 5, 6], respectively. The first example defines values for each attribute separately:

SETS: SET1 /A, B, C/: X, Y; ENDSETS

DATA: X = 1, 2, 3; Y = 4, 5, 6; ENDDATA

The next example shows how one statement can be used to assign values to the two attributes simultaneously. Each row assigns different values to the X, Y pair:

SETS: SET1 /A, B, C/: X, Y; ENDSETS

DATA: X, Y = 1, 4, 2, 5, 3, 6; ENDDATA

Variable Types in LINGO

All variables in a LINGO model are considered to be non-negative and continuous unless otherwise specified. LINGO’s four variable domain functions can be used to override the default domain for given variables. These variable domain functions are:

  • @GIN – any positive integer value
  • @BIN – a binary value (ie, 0 or 1)
  • @FREE – any positive or negative real value
  • @BND – any value within the specified bounds

Similar syntax is used for the @GIN, @BIN, and @FREE variable domain functions. The general form for the declaration of a variable x using any of these functions is @FUNCTION(X);

The @BND function has a slightly modified syntax, which includes the upper and lower bounds for the acceptable variable values. The general form for the declaration of a variable x between a lower bound and an upper bound is given by @BND(lowerBound, X, upperBound);

Navigating the LINGO Interface

Operations in LINGO can be carried out using commands from the menus, toolbars, or shortcut keys.

There are five menus in the main LINGO window. They are the File, Edit, LINGO, Window, and Help menus.

The following list details the commands in the File menu. Shortcut keys are included in parentheses when available:

New (F2) Open a new model window Open (F3) Open a saved file Save (F4) Save a current model Save As (F5) Save a current model to a new filename Close (F6) Close the current model Print (F7) Prints the current window’s content Print Setup (F8) Configures printer preferences Print Preview (Shift+F8) Displays the window content as it would look if printed Log Output (F9) Opens a log file to log output to the command window Take Commands (F11) Runs a command script contained in a file Import LINDO File (F12) Converts a LINDO file into a LINGO model Export File Exports a model in MPS or MPI file format License Prompts user for new license password to upgrade system Database User Info Prompts for a user id and password for database access via the @ODBC() function Exit (F10) Closes LINGO

The Edit menu contains the following commands:

Undo (ctrl+z) Undoes the last action Redo (ctrl+y) Redoes the last undo command Cut (ctrl+x) Copies and deletes highlighted text Copy (ctrl+c) Copies highlighted text to the clipboard Paste (ctrl+v) Pastes the clipboard’s contents into the document Paste Special Pastes the clipboard’s content into the document, in a user- specified manner Select All (ctrl+a) Selects all of the contents of the current window Find (ctrl+f) Searches the document for a specific text string Find Next (ctrl+n) Searches the document for the next occurrence of a specific text string Replace (ctrl+h) Replaces a specific text string with a new string Go To Line (ctrl+t) Moves the cursor to a certain line number Match Parenthesis (ctrl+p) Finds the selected parenthesis’s mate

A single toolbar located at the top of the main LINGO window contains many of the same commands as listed above. These commands can be accessed simply by using the mouse to click on the icon representing them. The following pictures detail which icons correspond to which commands.

New Save Cut Paste Redo

Open Print Copy Undo

Match Close Help Find Parenthesis Solution Options All Topics

Go To Line Solve Matrix Send to Tile Help Picture Back

LINGO Operators and Functions

LINGO provides a vast array of operators and functions, making it a useful problem-solving tool. A selection of the primary operators and functions is given below.

There are three types of operators that LINGO uses: arithmetic, logical, and relational operators. The arithmetic operators are as follows:

  • Exponentiation: ^
  • Multiplication: *
  • Division: /
  • Addition: +
  • Subtraction: -

The logical operators are used in set looping functions to define true/false conditions:

  • #LT#: TRUE if the left argument is strictly less than the right argument, else FALSE
  • #LE#: TRUE if the left argument is less-than-or-equal-to the right argument, else FALSE
  • #GT#: TRUE if the left argument is strictly greater than the right argument, else FALSE
  • #GE#: TRUE if the left argument is greater-than-or-equal-to the right argument, else FALSE
  • #EQ#: TRUE if both arguments are equal, else FALSE
  • #NE#: TRUE if both arguments are not equal, else FALSE
  • #AND#: TRUE only if both arguments are TRUE, else FALSE
  • #OR#: FALSE only if both arguments are FALSE, else TRUE
  • #NOT#: TRUE if the argument immediately to the right is FALSE, else FALSE

The relational operators are used when defining the constraints for a model. They are as follows:

  • The expression is equal: =
  • The left side of the expression is less than or equal to the right side: <=
  • The left side of the expression is greater than or equal to the right side: >=

Common LINGO Error Messages

LINGO provides a variety of error messages useful for debugging a developing model. The most common errors include the following:

  • 7: Unable to open file: filename o Retype filename correctly
  • 11: Invalid input: A syntax error has occurred o Check the line LINGO suggests for missing semi-colons, etc.
  • 12: Unmatched parenthesis o Close the parenthesis set
  • 15: No relational operator found o Make sure all constraints contain =, <=, >=
  • 44: Unterminated condition o Put a colon at the end of each conditional statement in a set operator
  • 50: Improper use of the @FOR() function o @FOR() functions cannot be nested inside other set operators
  • 68: Multiple objective functions in model o Only one is allowed, please
  • 71: Improper use of a variable domain function (eg, @GIN, @BIN, @FREE, @BND) o Check the syntax
  • 81: No feasible solution found o Check model’s consistency and constraints
  • 82: Unbounded solution o Add constraints
  • 102: Unrecognized variable name: variable name o Check spelling
  • 108: The model’s dimensions exceed the capacity of this version o Upgrade to full version or use Excel
  • 164: Invalid LINGO name o Create a name to conform to LINGO’s naming conventions

LINGO Programming Examples

A common programming model is the Knapsack problem, which deals with maximizing the utility of loading capacity. This example shows how to properly set up a knapsack problem.

SETS: ITEMS / ANT_REPEL, BEER, BLANKET, BRATWURST, BROWNIES, FRISBEE, SALAD, WATERMELON/: INCLUDE, WEIGHT, RATING; ENDSETS

DATA: WEIGHT RATING = 1 2 3 9 4 3 3 8 3 10 1 6 5 4 10 10; KNAPSACK_CAPACITY = 15; ENDDATA

MAX = @SUM( ITEMS: RATING * INCLUDE);

@SUM( ITEMS: WEIGHT * INCLUDE) <= KNAPSACK_CAPACITY;

@FOR( ITEMS: @BIN( INCLUDE));