Windows platforms: | Unix platforms: | All platforms: |
Command, Database, DLL, Error Code, Help, License, Print, Problem Size, Sample Model, Save, Solve, Spreadsheet, |
Command, Enter Model, Error Code, Get Started, Help, License, Print, Problem Size, Save, Solve, |
Debugging, Developing, Error Messages, Export Data, Import Data, Loop, New Features, Random Variables, Sets, Technical Support, Textfiles, Uncertainty, |
Windows platforms:
How do I enter a small model? [Windows]
How do I open a sample model in LINGO? [Windows]
How do I Print my work or results? [Windows]
How do I Save my work? [Windows]
How do I get help on a LINGO command? [Windows]
How do I call LINGO as a DLL? [Windows]
How do I interface with a spreadsheet? [Windows]
How do I interface with a database? [Windows]
How can I determine the largest problem I can solve? [Windows]
How do I find out where my Lingo license file is located? [Windows]
Unix platforms:
How do I get started with LINGO on a Unix - like platform? [UNIX]
How do I enter a small model? [UNIX]
How do I solve a model? [UNIX]
How do I Save and Print my work? [UNIX]
How do I get help on a LINGO command? [UNIX]
How can I determine the largest problem I can solve? [UNIX]
How do I find out where my Lingo license file is located? [UNIX]
What should I do when Lingo displays error code 0, "The model generator ran out of memory"? [UNIX]
All platforms:
How should I go about developing and debugging a LINGO model?
How do I enter a set base model?
How do I include data from external textfiles?
How do I export data to a textfile?
How do I incorporate uncertainty and random variables?
How do I solve multiple models in a loop?
How do I get help on an error message?
How to contact Technical Support?
Windows platforms:
How do I enter a small model? [Windows]
In general, an optimization model will consist of the following three items:
- Objective Function: The objective function is a formula that expresses exactly what it is you want to optimize.
- Variables (or decision variables): These are the quantities you have under your control. You must decide what the best values of the variables are. The goal of optimization is to find the values of a model's variables that generate the best value for the objective function, subject to any limiting conditions placed on the variables.
- Constraints: Almost without exception, there will be some limit on the values the variables in a model can assume--at least one resource will be limited (e.g., time, raw materials, your department's budget, etc.).
Please check for example models included under /Samples/ of your LINGO installation directory as explained below. You can also refer to the LINGO Online Users Manual (.chm) (Getting Started with LINGO/Getting Started in Windows/Developing a LINGO Model) included on your CD or downloaded .zip installation package.
How do I open a sample model in LINGO? [Windows]
On Windows versions of Lingo run the File|Open command, and then look for the 'Samples' directory that is stored directly off the many LINGO directory. You may then select a model in the Samples folder and press the Open button from the dialog box.
On Windows platforms, you may solve the model using the LINGO|Solve command or by pressing the solve button on the toolbar. button on the toolbar.
How do I Print my work or results? [Windows]
Use the File|Printto print the active (frontmost) window, or click on the Print button. You may print any window, including both model and report windows. If you wish to print just a portion of a window, use the Cut and Paste commands in the Edit menu to put the desired text in a new window before printing.
How do I Save my work? [Windows]
To save your model to a disk file, use the File|Save command, or press the Save button in the toolbar. Unless you specify otherwise, LINGO will automatically append a .LG4 extension to your file name.
How do I get help on a LINGO command? [Windows]
Please check the Windows Commands|Windows Commands In Brief section of the LINGO Online Users Manual (.chm) included in your LINGO installation package.
How do I call LINGO as a DLL? [Windows]
Windows and Linux versions of LINGO include a callable DLL.
The interface to the LINGO DLL is relatively simple and gives you the ability to run a LINGO command script from within your application. Given that you can access all the major features of LINGO from a command script, the LINGO DLL interface is very powerful. You will, however, need to familiarize yourself with LINGO's command language in order to build useful command scripts. For more details on the commands available in the command language, see the Command-line Commands section, and A Command Script Example from the LINGO Online Users Manual (.chm).
When you call the LINGO DLL, you can pass it a list of memory pointers. @POINTER( n) refers to the n-th pointer in the passed pointer list.
The @POINTER function only makes sense in a model when accessing LINGO through the DLL or OLE interfaces.
When LINGO is installed, a number of examples on calling the DLL are installed, too. These examples may be found in the Programming Samples folder below the main LINGO folder. Please also refer to your manual: Interfacing with Other Applications|The LINGO Dynamic Link Library
How do I interface with a spreadsheet? [Windows]
One solution offered by LINGO is to use the @OLE function to either import or export data to/from Excel.
- Using @OLE to Import Data from Excel:
@OLE is an interface function for moving data back and forth from Excel using OLE based transfers. OLE transfers are direct memory transfers and do not make use of intermediate files. When using @OLE, LINGO loads Excel, tells Excel to load the desired spreadsheet, and requests ranges of data from the sheet. The @OLE function may be used in the DATA and INIT sections to import data.
The syntax for using @OLE to import data is:
object_list = @OLE( ['spreadsheet_file'] [, range_name_list]);
Example:
COST, CAPACITY = @OLE( 'SPECS.XLS', 'COST01', 'CAP01');
Conversely, the syntax for using @OLE to export solutions to Excel is:
@OLE( ['spreadsheet_file’] [, range_name_list]) = object_list;
Example:
@OLE( '\XLS\DEVELOP.XLS', 'BUILD_IT', 'HOW_BIG') = BUILD, SQ_FEET;
How do I interface with a database? [Windows]
LINGO can access any database that supports ODBC (Open DaraBase Connectivity).
The @ODBC function is used to import data from and export data to any ODBC data source. @ODBC is currently available only in Windows versions of LINGO. Make sure that your ODBC data source has been properly created. You might need assistance from your database administrator for this purpose.
The syntax for using @ODBC to import data inside a data section is:
object_list = @ODBC([‘data_source’[, ‘table_name’ [,’column_name_1’[, ‘column_name_2’ …]]]]);
How can I determine the largest problem I can solve? [Windows]
You can determine the limits of your version by selecting the About LINGO command from the Help menu in Windows.
Be aware that large models may require more memory to solve than is available on your system, or they may require more time to solve than one would normally be willing to wait.If you determine you need a larger version of LINGO, upgrades are available from LINDO Systems. Please feel free to contact us for pricing and availability.
How do I find out where my Lingo license file is located? [Windows]
In Windows versions of Lingo, you can run the Help|About command and then look in the License Locationbox to determine the location of the license.
What should I do when Lingo displays error code 0, "The model generator ran out of memory"? [Windows]
LINGO’s model generator ran out of working memory. The model generator converts the text of your LINGO model to an expanded form suitable for an appropriate solver engine. On most platforms you can increase the amount of working memory allocated to the model generator. Note that memory set aside for LINGO’s model generator will not be available to LINGO’s various solver engines. Given this, you should not allocate an overly excessive amount of memory to the generator.
In Windows versions, select the LINGO|Options command, then the Generaltab, and in the Generator Memory Limitbox increase the amount of working memory. Press the Save button and then restart LINGO. You can verify the new memory allotment by issuing the Help|About LINGO command.
Unix platforms:
How do I get started with LINGO on a Unix - like platform? [UNIX]
If you are running LINGO on a platform other than a Windows based PC, then you will interface with LINGO through the means of a command-line prompt. All instructions are issued to LINGO in the form of text command strings. When you start a command-line version of LINGO, you will see a colon command prompt.
The colon character (:) at the bottom of the screen in LINGO’s prompt for input.
How do I enter a small model? [UNIX]
When you enter a model in the command-line interface, you must first specify to LINGO that you are ready to begin entering the LINGO statements. This is done by entering the MODEL: command at the colon prompt. LINGO will then give you a question mark prompt and you begin entering the model line by line.
Example:
: MODEL:
? MAX = 100 * STANDARD + 150 * TURBO;
? STANDARD <= 100;
? TURBO <= 120;
? STANDARD + 2 * TURBO <= 160;
? END
:
The END command tells LINGO you are finished inputting the model. Once you enter the END command and return to the colon prompt, the model is in memory and ready to be solved.
How do I solve a model? [UNIX]
Type the GO command at the colon prompt and press the enter key. LINGO will begin compiling the model. If the LINGO model doesn’t pass these tests, you will be informed by an error message.
If there are no formulation errors, LINGO will invoke the appropriate internal solver to begin searching for the optimal solution to your model. When LINGO is done solving, it will send a solution report to your screen.
How do I Save and Print my work? [UNIX]
The DIVERT file command may be used to send all LINGO reports to a file rather than to the screen. You may then route this file to a printer or load it into a word processing program for printing.
For example, to create a text file for printing that contains a copy of your model and solution, issue the commands:
DIVERT MYFILE!Opens an output file called MYFILE;
LOOK ALL!Sends formulation to the file;
GO!Sends solution to the file;
RVRT!Closes down output file;
To save your model to disk, issue the SAVE command followed by the name of a file to store your model under. For example, the command SAVE MYFILE.LNG saves a copy of the current model to the file titled MYFILE.LNG. The model may be retrieved for use later with the TAKE command.
How do I get help on a LINGO command? [UNIX]
Please check the Command-Line Commands section of the LINGO Online Users Manual (.chm) included in your LINGO installation package.
How can I determine the largest problem I can solve? [UNIX]
You can determine the limits of your version by typing HELP at the command-line prompt .
Be aware that large models may require more memory to solve than is available on your system, or they may require more time to solve than one would normally be willing to wait.If you determine you need a larger version of LINGO, upgrades are available from LINDO Systems. Please feel free to contact us for pricing and availability.
How do I find out where my Lingo license file is located? [UNIX]
On Unix based platforms, Lingo will automatically display the license location at startup.
What should I do when Lingo displays error code 0, "The model generator ran out of memory"? [UNIX]
LINGO’s model generator ran out of working memory. The model generator converts the text of your LINGO model to an expanded form suitable for an appropriate solver engine. On most platforms you can increase the amount of working memory allocated to the model generator. Note that memory set aside for LINGO’s model generator will not be available to LINGO’s various solver engines. Given this, you should not allocate an overly excessive amount of memory to the generator.
On Unix based platforms, use the following commands:
SET MAXMEMB n
FREEZE
where n is the new memory allotment in megabytes. Exit LINGO and restart. Once LINGO restarts, you can verify the new memory allotment with the MEM command.
All platforms:
How should I go about developing and debugging a LINGO model?
Some useful development and debugging guidelines are:
1) Most importantly: Start with a small and simple model.
Add size and complexity slowly.
As you add each new complication to the model, test it to make
sure the solution, and thus probably the model, make sense.
2) Use row names so output is easier to identify and connect to your model.
3) If you're not already using Lingo's set-based modeling capabilities,
then consider doing so. The set based approach allows you to
isolate a model's data from it's equation/logical/mathematical structure.,
Set-based models are much easier to "scale up", debug, and maintain.
4) If you are using sets, click on:
LINGO | Generate | Display model, to see model in explicit/scalar form.
5) Click on:
LINGO | Options | Model Generator | Fixed var reduction | None
to prevent LINGO from removing any trivial constraints, else
generated output may be confusing.
5) Click on:
LINGO | Debug to see which rows are causing infeasibilities.
6) Click on:
LINGO | Options | Interface | Output level | Verbose
to see as much information as possible.
How do I enter a set base model?
Whenever you are modeling some situation in real life, you will typically find there are one or more sets of related objects. Examples would be such things as factories, customers, vehicles, and employees. Usually, if a constraint applies to one member of a set, then it will apply equally to each other member of the set. This simple concept is at the core of the LINGO modeling language. LINGO allows you to define the sets of related objects in the SETS section.
The sets section begins with the keyword SETS: on a line by itself and ends with ENDSETS on a line by itself.
Once your set members are defined, LINGO has a group of set looping functions (e.g., @FOR), which apply operations to all members of a set using a single statement. See the Using Sets section of the LINGO Online Users Manual (.chm) for more information.
How do I include data from external textfiles?
Use the @FILE interface function in LINGO to include data from external text files anywhere in your model.
The syntax is:
@FILE( 'filename')
where filename is the name of the file to include text from. When this function is encountered in a model, LINGO will continue to take text from this file until it encounters either the end-of-file mark or a LINGO end-of-record mark (~). For subsequent @FILE references in the same model that use the same file name, LINGO resumes taking input from the file at the point where it left off. Embedding an @FILE in a file that is itself called by @FILE is not allowed.
Example:CAPACITY = @FILE( 'WIDGETS2.LDT');
How do I export data to a textfile?
The @TEXT interface function is used for exporting solutions to text files. The @TEXT function can export both set members and attribute values.
The syntax is:
@TEXT( ['filename', [‘a’]])
where filename is the name of the file you want to export the solution to. If filename is omitted, the solution data will be sent to the standard output device (this is typically the screen). If the second argument of ‘a’ is present, then LINGO will append output to the file, otherwise it will create a new file for subsequent output, erasing any existing file. The @TEXT function may only appear on the left-hand side of a data statement in the data section of a model.
Example:@TEXT( 'RESULTS.TXT') = X;
Sends the value(s) for variable X to the file RESULTS.TXT. Any existing version of the file is overwritten.
How do I incorporate uncertainty and random variables?
LINGO 12.0, with the appropriate option, allows users to integrate uncertainty in their models.
A stochastic program (SP) is a mathematical program (linear, nonlinear or mixed-integer) in which some of the model parameters are not known with certainty, and the uncertainty can be expressed with known probability distributions.There are four steps to setting up an SP model:
1) Defining core model; entered like any other deterministic LINGO model.
2) Identifying the random variables; done by using the function: @SPSTGRNDV
3) Identifying the initial decision and recourse variables; done by using: @SPSTGVAR
4) Declaring distributions by using one of the following functions:
-Scalar-based Outcome Tables:@SPTABLESHAPE,@SPTABLEOUTC,@SPTABLEINST,@SPTABLERNDV
-Vector-based Outcome Tables:@SPDISTTABLE
-Parametic Distributions Outcome Tables: @SPDIST<TYPE>,@SPSAMPSIZE,@SPCORR<METHOD>
Please checkthe Stochastic Programming section of the LINGO Online Users Manual (.chm) for more information.
How do I solve multiple models in a loop?
LINGO has two looping statements, @FOR and @WHILE, equivalent to the classic for and while loop constructs in programming languages.When used in a CALC section, these statements allow you to solve multiple models in a loop, with one model’s outputs passed to a subsequent model as inputs.
The following example shows a @FOR loop extracted from a portfolio model.The loop is used to solve the portfolio model for a number of different levels of desired return.For each level of return, the model minimizes variance, and the variance is stored for later use.
@FOR( POINTS( I):
! Compute new return level;
RET_LIM = RET_MIN + (I-1)*INTERVAL;
! Re-solve the model;
@SOLVE();
! Store the return value;
YRET( I) = RET_LIM;
! Store the variance too;
XSTD( I) = VARIANCE^0.5;
);
The @WHILE statement is used for looping over a group of statements until some termination criterion is met.The syntax is as follows:
@WHILE( <conditional-exp>: statement_1[; …; statement_n;]);
As long as the conditional expression is true, the @WHILE function will keep looping over its block of statements.
As an example, the following code uses an @WHILE loop to search for a key value in an array as part of a binary search procedure:
@WHILE( KEY #NE# X( LOC):
INEW = @FLOOR( ( IE + IB) / 2);
@IFC ( KEY #EQ# X( INEW):
LOC = INEW;
@ELSE
@IF ( KEY #LT# X( INEW):
IE = INEW - 1;
@ELSE
IB = INEW + 1;
);
);
);
In this case, the loop executes until the current value selected from the array,X(LOC), is equal to the key value, KEY.
A @BREAK statement can be used to break out of the current loop.Execution resumes at the first statement immediately following the end of the current loop.The @BREAK statement is valid only within @FOR and @WHILE loops in CALC sections and does not take any arguments
How do I get help on an error message?
All of LINGO's error messages are listed in Error Messages section of the LINGO Online Users Manual (.chm) included in your LINGO installation package with explanations and suggestions for resolution.
How to contact Technical Support?
LINDO Systems can be reached at the following addresses and telephone numbers:
LINDO Systems, Inc.
1415 North Dayton Street
Chicago, IL 60622
Tel: 312-988-7422
Fax: 312-988-9065
Email: info @ lindo . com
For sales and product information, please contact us at:
Tel: 1-800-441-2378 or 312-988-7422
Email: sales @ lindo . com
For technical support, we prefer you send your model and questions by electronic mail to tech @ lindo . com. You may also speak to our technical support staff at 312-988-9421. Our technical support staff can help you with questions regarding the installation and operation of LINGO. If you have simple modeling questions, we can generally help get you pointed in the right direction. If you have extensive modeling questions, we can recommend third party consultants well versed in the specifics of LINGO and mathematical modeling in general, who can assist you in your modeling efforts.
Please refer to the following link to view LINGO enhancements: click here