










Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Os melhores documentos à venda: Trabalhos de alunos formados
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Comunidade
Peça ajuda à comunidade e tire suas dúvidas relacionadas ao estudo
Descubra as melhores universidades em seu país de acordo com os usuários da Docsity
Guias grátis
Baixe gratuitamente nossos guias de estudo, métodos para diminuir a ansiedade, dicas de TCC preparadas pelos professores da Docsity
LINGO - MANUAL PARA PRINCIPAIS FUNCOES
Tipologia: Manuais, Projetos, Pesquisas
1 / 18
Esta página não é visível na pré-visualização
Não perca as partes importantes!
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:
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:
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:
@FOR(Trucks(T): Capacity(T)<=3000);
TOTAL_HAUL=@SUM(Trucks(J): Capacity(J));
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:
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:
The logical operators are used in set looping functions to define true/false conditions:
The relational operators are used when defining the constraints for a model. They are as follows:
Common LINGO Error Messages
LINGO provides a variety of error messages useful for debugging a developing model. The most common errors include the following:
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));