COPYRIGHT
The LINGO software and its related documentation are copyrighted. You may not copy the LINGO
software or related documentation except in the manner authorized in the related documentation or
with the written permission of LINDO Systems Inc.
TRADEMARKS
LINGO is a trademark, and LINDO is a registered trademark, of LINDO Systems Inc. Other product
and company names mentioned herein are the property of their respective owners.
DISCLAIMER
LINDO Systems, Inc. warrants that on the date of receipt of your payment, the software provided
contains an accurate reproduction of the LINGO software and that the copy of the related
documentation is accurately reproduced. Due to the inherent complexity of computer programs and
computer models, the LINGO software may not be completely free of errors. You are advised to verify
your answers before basing decisions on them. NEITHER LINDO SYSTEMS, INC. NOR ANYONE
ELSE ASSOCIATED IN THE CREATION, PRODUCTION, OR DISTRIBUTION OF THE LINGO
SOFTWARE MAKES ANY OTHER EXPRESSED WARRANTIES REGARDING THE DISKS OR
DOCUMENTATION AND MAKES NO WARRANTIES AT ALL, EITHER EXPRESSED OR
IMPLIED, REGARDING THE LINGO SOFTWARE, INCLUDING THE IMPLIED WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR OTHERWISE.
Further, LINDO Systems, Inc. reserves the right to revise this software and related documentation and
make changes to the content hereof without obligation to notify any person of such revisions or
changes.
Copyright © 2018 by LINDO Systems Inc. All rights reserved.
Published by
1415 North Dayton Street
Chicago, Illinois 60642
Technical Support: (312) 988-9421
E-mail: tech@lindo.com
WWW: http://www.lindo.com
Contents
Contents ................................................................................................................................................ iii
Preface ................................................................................................................................................. vii
New Features ........................................................................................................................................ xi
for LINGO 18.0 ...................................................................................................................................... xi
1 Getting Started with LINGO ............................................................................................................ 1
Getting Started on Windows ............................................................................................................. 1
Getting Started on a Mac ................................................................................................................. 9
Getting Started on Linux ................................................................................................................. 20
Creating and Solving a Model in LINGO ........................................................................................ 32
Examining the Solution Report ....................................................................................................... 46
Intro to LINGO’s Modeling Language ............................................................................................. 48
Additional Modeling Language Features ........................................................................................ 60
Indicating Convexity and Concavity ............................................................................................... 64
Maximum Problem Dimensions ...................................................................................................... 65
How to Contact LINDO Systems .................................................................................................... 66
2 Using Sets ...................................................................................................................................... 67
Why Use Sets? ............................................................................................................................... 67
What Are Sets? .............................................................................................................................. 67
The Sets Section of a Model .......................................................................................................... 68
The DATA Section .......................................................................................................................... 74
Set Looping Functions .................................................................................................................... 75
Set-Based Modeling Examples ...................................................................................................... 82
Summary .......................................................................................................................................101
3 Using Variable Domain Functions ..............................................................................................103
Integer Variables ...........................................................................................................................103
Free Variables ...............................................................................................................................124
Bounded Variables ........................................................................................................................129
SOS Variables ...............................................................................................................................130
Cardinality .....................................................................................................................................134
Semicontinuous Variables .............................................................................................................134
Positive Semi-Definite Matrices .....................................................................................................136
4 Data, Init and Calc Sections ........................................................................................................141
The DATA Section of a Model .......................................................................................................141
The INIT Section of a Model ..........................................................................................................146
The CALC Section of a Model .......................................................................................................147
Summary .......................................................................................................................................153
iv CONTENTS
5 Menu Commands ..........................................................................................................................155
Accessing Menu Commands .........................................................................................................155
Menu Commands In Brief ..............................................................................................................158
Menu Commands In Depth ...........................................................................................................162
1. File Menu...................................................................................................................................162
2. Edit Menu ..................................................................................................................................180
3. Solver Menu ..............................................................................................................................193
4. Window Menu ............................................................................................................................316
5. Help Menu .................................................................................................................................320
6 Command-Line Commands .........................................................................................................326
The Commands In Brief ................................................................................................................326
The Commands In Depth ..............................................................................................................328
7 LINGO’s Operators and Functions..............................................................................................429
Standard Operators .......................................................................................................................429
Mathematical Functions ................................................................................................................433
Financial Functions .......................................................................................................................436
Probability Functions .....................................................................................................................436
Variable Domain Functions ...........................................................................................................439
Set Handling Functions .................................................................................................................440
Set Looping Functions ...................................................................................................................445
Interface Functions ........................................................................................................................447
Distributions...................................................................................................................................448
Report Functions ...........................................................................................................................454
Date, Time and Calendar Functions ..............................................................................................465
Matrix Functions ............................................................................................................................469
Miscellaneous Functions ...............................................................................................................483
8 Interfacing with External Files .....................................................................................................487
Cut and Paste Transfers ...............................................................................................................487
Text File Interface Functions .........................................................................................................489
LINGO Command Scripts ..............................................................................................................497
Specifying Files in the Command-line ...........................................................................................500
RunLingo .......................................................................................................................................502
Redirecting Input and Output ........................................................................................................505
Managing LINGO Files ..................................................................................................................505
9 Interfacing With Spreadsheets ....................................................................................................507
Importing Data from Spreadsheets................................................................................................507
Exporting Solutions to Spreadsheets ............................................................................................512
OLE Automation Links from Excel .................................................................................................520
Embedding LINGO Models in Excel ..............................................................................................524
Embedding Excel Sheets in LINGO ..............................................................................................530
Summary .......................................................................................................................................534
CONTENTS v
10 Interfacing with Databases ..........................................................................................................535
ODBC Data Sources .....................................................................................................................536
Importing Data from Databases with @ODBC ..............................................................................543
Importing Data with ODBC in a PERT Model ................................................................................545
Exporting Data with @ODBC ........................................................................................................547
Exporting Data with ODBC in a PERT Model ................................................................................550
11 Interfacing with Other Applications ............................................................................................555
The LINGO Dynamic Link Library..................................................................................................555
User Defined Functions .................................................................................................................599
12 Developing More Advanced Models ...........................................................................................603
Production Management Models ...................................................................................................604
Logistics Models ............................................................................................................................620
Financial Models ...........................................................................................................................627
Queuing Models ............................................................................................................................644
Marketing Models ..........................................................................................................................652
13 Programming LINGO ....................................................................................................................661
Programming Features ..................................................................................................................661
Programming Example: Binary Search .........................................................................................708
Programming Example: Markowitz Efficient Frontier .....................................................................712
Programming Example: Cutting Stock...........................................................................................719
Programming Example: Accessing Excel ......................................................................................725
Summary .......................................................................................................................................732
14 Stochastic Programming ...........................................................................................................733
Multistage Decision Making Under Uncertainty .............................................................................733
Recourse Models ..........................................................................................................................735
Scenario Tree ................................................................................................................................737
Monte Carlo Sampling ...................................................................................................................739
Setting up SP Models ....................................................................................................................740
Language Features for SP Models ................................................................................................741
Declaring Distributions ..................................................................................................................743
Gas Buying Example .....................................................................................................................750
Stock Option Example ...................................................................................................................761
Investing Under Uncertainty Example ...........................................................................................770
Chance-Constrained Programs (CCPs) ........................................................................................777
15 On Mathematical Modeling ..........................................................................................................791
Solvers Used Internally by LINGO.................................................................................................791
Type of Constraints .......................................................................................................................792
Local Optima vs. Global Optima ....................................................................................................794
Smooth vs. Nonsmooth Functions.................................................................................................800
Guidelines for Nonlinear Modeling ................................................................................................801
评论23