• 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 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 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, andA 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 theProgramming 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 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 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 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 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 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 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 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 @FILEreferences 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 incorporate uncertainty and random variables?

    LINGO 12.0, with the appropriate option, allows users to integrate uncertainty in their models.
    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 check the Stochastic Programming section of the LINGO Online Users Manual (.chm) for more information.

  • 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 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 INITsections 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 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.

  • How do I Print my work or results? [Windows]

    Use the File|Print to 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 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 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 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 solve multiple models in a loop?

    LINGO has two looping statements, @FORand @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.
    @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 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.

    2. Add size and complexity slowly.

    3. As you add each new complication to the model, test it to make sure the solution, and thus probably the model,  make sense.   

    4. Use row names so output is easier to identify and connect to your model.

    5. 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.

    6. If you are using sets, click on: LINGO | Generate | Display model, to see model in explicit/scalar form.

    7. Click on: LINGO | Options | Model Generator | Fixed var reduction | None to prevent LINGO from removing any trivial constraints, else generated output may be confusing.

    8. Click on: LINGO | Debug     to see which rows are causing infeasibilities.

    9. Click on: LINGO | Options | Interface | Output level | Verbose to see as much information as possible.

  • Solve a model? [Windows]

    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.

  • What are the Barrier, Nonlinear and Global options? Do I need them?

    The Base versions of each product include Primal and Dual Simplex algorithms for linear models and includes integer programming capabilities. We offer a few different options that extend the capabilities of the base versions. Whether or not you need an option depends upon the types of models that you wish to solve. If your models are linear (with or without integer restrictions) no options are required.

    The Barrier option adds a Barrier/Interior Point solver. If you have a quadratic model (i.e., an model with a quadratic objective function and/or quadratic constraints with all other terms being linear) then the Barrier option will provide the best performance. Quadratic models can be solved with the general Nonlinear solver but it will generally take longer. The Barrier option can also be used to solve linear models with no integer restrictions. In some cases using the Barrier algorithm may be significantly faster that using the Primal and Dual Simplex algorithms available in the base versions. This is typically true on sparse models with more than 5,000 constraints or highly degenerate models.

    The Nonlinear option can allow you to solve general nonlinear models to a local optimum using a Generalized Reduced Gradient (GRG) algorithm. If your models are nonlinear and convex (i.e., only one local optimum) then you can use the Nonlinear option to solve your models. However, many classes of nonlinear models are non-convex (i.e., have more than one local optimum). Using the Nonlinear option alone, the solver will stop at the first locally optimal solution it finds. Other local optimum may exist that are significantly better than the local optimum returned. For nonconvex models you may want to use the Nonlinear option in conjunction with the Global option.

    The Global option provides two additional techniques for solving nonlinear models – a Global solver and a Multistart capability. Rather than stopping after the first local optimum is found, the Global solver will search until the global optimum is confirmed. When limited time makes searching for the global optimum prohibitive, the Multistart capability can be a powerful tool for finding good solutions more quickly. This capability intelligently selects different starting points and solves each to a local optimum and then returns the best solution found. For non-convex nonlinear models, the quality of the solution returned using the Multistart capability will be superior to that of the general nonlinear solver. The Global option requires the Nonlinear option.

  • 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.

  • 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 General tab, and in the Generator Memory Limit box 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.

  • What's the difference between the three products?

    What’sBest, LINGO and LINDO API all utilize the same set of underlying solvers and can solve the same types of problems. They primarily differ in terms of how models are expressed and how you interface with them.

    What’sBest is an add-on to Microsoft Excel. Models can be expressed in a free form fashion in an Excel file using standard spreadsheet equations. What’sBest may be the easiest product to learn and begin using for users comfortable using Excel. 

    With LINGO the user can utilize a modeling language to express the model. The modeling language supports summations and subscripted variables to allow you to express large models quickly. LINGO can also read data from and write solution information to Excel and Windows databases such as Microsoft Access. LINGO includes a user interface for interactive use and a callable programming interface that allows you to embed LINGO in your own application.

    LINDO API does not have a traditional user interface. It only has a programming interface. Of the three products, it gives the application developer the most control over the optimization process and can allow the user to tailor the algorithm to a particular model or even develop a new algorithm.