Lingo运筹学,数学必学的基础软件

合集下载

2024年度LINGO软件

2024年度LINGO软件

结果分析
对求解结果进行分析,验证模型的有 效性和可行性。
模型调整
根据结果分析,对模型进行调整和优 化,提高模型的实用性和准确性。
24
05 LINGO软件在各 个领域的应用案 例
2024/3/23
25
生产计划与调度问题
2024/3/23
生产线平衡
LINGO可以用于解决生产线平衡问题,通过优化生产线上 各个工位的任务分配,提高生产效率和资源利用率。
一些学术机构和研究团队也会分享他们的 LINGO使用经验和案例,为学习者提供更多 的学习资源和合作机会。
37
THANKS
感谢观看
2024/3/23
38
LINGO可用于金融市场预测和决策分析,通过建立预测模型和分析工具
,揭示金融市场的运行规律和趋势,为投资决策提供支持。
29
06 LINGO软件与其 他工具的集成与 应用
2024/3/23
30
与Excel的集成与应用
2024/3/23
数据交换
LINGO可以直接从Excel中导入数据,也可以将结果导出到Excel ,实现数据的无缝对接。
2024/3/23
28
金融工程与投资组合优化问题
01
投资组合优化
LINGO可以用于解决投资组合优化问题,通过优化投资组合中各个资产
的配置比例,实现风险和收益的平衡。
02
期权定价与风险管理
利用LINGO建立期权定价模型,可以准确计算期权的价值,为风险管理
提供决策依据。
2024/3/23
03
金融市场预测与决策分析
2024/3/23
整数规划算法
分支定界法、割平面法等适用于整数规划问 题的求解。

运筹学___的LINGO软件

运筹学___的LINGO软件
§2 LINGO 快速入门
当你在 windows 下开始运行 LINGO 系统时,会得到一个窗口: 外层是主框架窗口,包含了所有菜单命令和工具条,其它所有的窗口将被包含在主 窗口之下。在主窗口内的标题为 LINGO Model – LINGO1 的窗口是 LINGO 的默认模型窗 口,建立的模型都都要在该窗口内编码实现。下面举两个例子。 例 2.1 如何在 LINGO 中求解如下的 LP 问题:
§3 LINGO 中的集
对实际问题建模的时候,总会遇到一群或多群相联系的对象,比如工厂、消费者群 体、交通工具和雇工等等。LINGO 允许把这些相联系的对象聚合成集(sets)。一旦把 对象聚合成集,就可以利用集来最大限度的发挥 LINGO 建模语言的优势。
-316-
3.1 什么是集 集是一群相联系的对象,这些对象也称为集的成员。一个集可能是一系列产品、卡 车或雇员。每个集成员可能有一个或多个与之有关联的特征,我们把这些特征称为属性。 属性值可以预先给定,也可以是未知的,有待于 LINGO 求解。例如,产品集中的每个产 品可以有一个价格属性;卡车集中的每辆卡车可以有一个牵引力属性;雇员集中的每位 雇员可以有一个薪水属性,也可以有一个生日属性等等。 LINGO 有两种类型的集:原始集(primitive set)和派生集(derived set)。 一个原始集是由一些最基本的对象组成的。 一个派生集是用一个或多个其它集来定义的,也就是说,它的成员来自于其它已存 在的集。
(iii)LINGO 可以用来求解线性,非线性和整数规划问题。 (iv)LINGO NL (LINGO2) 可以用来求解线性,非线性和整数规划问题。 与 LINDO 和 GINO 不同的是,LINGO 和 LINGO NL (LINGO2) 包含了內置的建模 语言,允许以简练,直观的方式描述较大规模的优化问题,模型中所需的数据可以以一 定格式保存在独立的文件中。 (v)“what’s best!” 组件主要用于数据文件是由电子表格软件(如 LUTOS1-2-3 和 MS OFFICE 等)生成的情形。 LINDO 软件包有多种版本,但其软件內核和使用方法基本上是类似的。下面介绍 LINGO 组件的基本使用方法。

数学软件matlab和lingo基础(特色) 论语

数学软件matlab和lingo基础(特色) 论语

数学软件matlab和lingo基础(特色) 论语Matlab 和 Lingo 都是广泛用于数学建模和优化问题的软件。

Matlab 是一个用于数学和工程计算的高级程序语言和交互式环境,
它被广泛用于各种工程和科学领域。

Matlab 的主要特色是其高效的数学
算法和矩阵操作能力,它能够简化许多复杂的数学计算,并能够可视化结
果以帮助用户更好地理解和分析数据。

Matlab 也拥有许多工具箱和函数库,其中包括信号处理、控制系统、图像处理、优化工具等等。

这些工具
箱使得 Matlab 可以被广泛应用于工业、学术、和科学领域,例如工程、
生物学、金融、和物理等领域。

Lingo 是一个商业线性规划软件,这意味着它被用于解决复杂的最优
化问题,其中线性规划问题是其中一类。

Lingo 主要特色是它强大的数
学算法和求解器。

Lingo 可以用于解决多元线性规划问题,其定义的问题
可以包括多目标函数、约束条件和决策变量。

Lingo 的界面提供用户友好
的输入和处理问题的方法,使得它可以被广泛用于各种商业和产业应用中,例如生产规划、库存管理、运输管理、和售货员工作调度等领域。

总之,Matlab 和 Lingo 都是强大的数学软件工具,分别适用于数学
建模和优化问题的不同领域。

Matlab 适用于各种工程和科学领域中的数
学计算和可视化,而 Lingo 主要用于商业应用中的最优化问题求解。


论学术上还是在商业上,都需要这些工具来解决各种数学问题。

Lingo软件在运筹学中的应用

Lingo软件在运筹学中的应用

Lingo软件在运筹学中的应用Lingo软件在运筹学中的应用随着信息技术的不断发展,计算机软件在各个领域中的应用越来越广泛,尤其是在运筹学领域。

运筹学是研究在复杂决策环境下,如何高效地进行决策的学科。

Lingo软件作为一款运筹学建模和求解工具,为运筹学的研究和应用带来了很大的便利和效率。

本文将介绍Lingo软件在运筹学中的应用,并通过实例来说明其实际效果。

首先,Lingo软件在线性规划问题中的应用非常广泛。

线性规划是一种数学优化技术,用于在给定的约束条件下最大化或最小化线性目标函数。

Lingo软件提供了直观的图形用户界面,使得用户可以轻松地建立线性规划模型,并通过内置的求解器进行求解。

用户只需输入决策变量、约束条件和目标函数,Lingo就能自动找到最优解。

这对于一些复杂的决策问题,如生产规划、资源调度和供应链优化等,提供了很大的帮助。

其次,Lingo软件在整数规划和混合整数规划问题中也有着广泛的应用。

整数规划是在线性规划的基础上,将决策变量限制为整数解的优化问题。

混合整数规划在整数规划的基础上,允许部分决策变量取非整数解。

这种类型的决策问题在实际中很常见,如生产工作安排、旅行路线规划和仓储优化等。

Lingo软件提供了强大的分支定界算法和割平面算法,能够有效地求解整数规划和混合整数规划问题。

用户只需调整问题的参数,Lingo就能快速找到最优解,大大减少了优化问题的求解时间。

此外,Lingo软件还可以用于非线性规划问题的建模和求解。

非线性规划是在线性规划的基础上,将决策变量限制为非线性函数的优化问题。

非线性规划在许多实际问题中都有着广泛的应用,如投资组合优化、工程设计和市场定价等。

Lingo软件提供了多种求解算法,如牛顿法、拟牛顿法和遗传算法等,能够有效地求解非线性规划问题。

用户只需选择合适的算法和调整参数,Lingo就能找到最优解或是近似最优解。

最后,Lingo软件还具有灵活的扩展性和集成性。

它可以与其他优化软件和模拟软件进行集成,提供更强大的求解能力和模型分析能力。

运筹学lingo实验报告

运筹学lingo实验报告

运筹学lingo实验报告
运筹学lingo实验报告
一、引言
实验目的
本次实验旨在探索运筹学lingo在解决实际问题中的应用,了解lingo的基本使用方法和解题思路。

实验背景
运筹学是一门研究决策和规划的学科,其能够帮助我们优化资源分配、解决最优化问题等。

lingo是一种常用的运筹学工具,具有强大的求解能力和用户友好的界面,被广泛应用于各个领域。

二、实验步骤
准备工作
•安装lingo软件并激活
•熟悉lingo界面和基本功能
确定问题
•选择一个运筹学问题作为实验对象,例如线性规划、整数规划、网络流等问题
•根据实际问题,使用lingo的建模语言描述问题,并设置变量、约束条件和目标函数
运行模型
•利用lingo的求解器,运行模型得到结果
结果分析
•分析模型求解结果的合理性和优劣,对于不符合要求的结果进行调整和优化
结论
•根据实验结果,总结lingo在解决该问题中的应用效果和局限性,对于其他类似问题的解决提出建议和改进方案
三、实验总结
实验收获
•通过本次实验,我熟悉了lingo软件的基本使用方法和建模语言,增加了运筹学领域的知识和实践经验。

实验不足
•由于时间和条件的限制,本次实验仅涉及了基本的lingo应用,对于一些复杂问题的解决还需要进一步学习和实践。

•在以后的学习中,我将继续深入研究lingo的高级功能和应用场景,以提升运筹学问题的求解能力。

以上就是本次实验的相关报告内容,通过实验的实践和总结,我对lingo在运筹学中的应用有了更深入的理解,为今后的学习和研究奠定了基础。

4-1 LINGO软件简介

4-1 LINGO软件简介

例4 max z=6x1+5x2

3.3 利用LINGO求解整数规划问题
例4 max z=6x1+5x2
st 2x1+x2<=9 5x1+7x2<=35 x1>=0, x2>=0
定义一般整数的方法:
书写格式 Max=6*x1+5*x2; 2*x1+x2<=9;
5*x1+7*x2<=35;
@GIN(x1); @GIN(x2);
@GIN( variable_name);
最优解
x1=4, x2=1, z=29
3.4 案例分析

某开发公司选择建造两房、三房和四房的住宅,现 需要确定每种房型的数量,以获得利润最大。 约束条件: 工程总预算不超过900万元 为使经济上可行,总单元数必须不少于350套
模型的建立

令x1、x2、x3分别代表两、三、四房住宅的套数 目标函数:Max Z=0.2x1+0.3x2+0.4x3
1.4 结果分析

求解器状态窗口 计算结果窗口
模型 类型 LP, QP, ILP,
NLP …
求解器状态窗口
变量数
约束数 非零系数的数目
内存使用更新时 间间隔Fra bibliotek计算结果
表示2次迭代后得到全局最优解
变量微小变动时, 目标函数的变化
最优值
最优解
第1行表示目标函数 第2、3、...行分别对 应第1、2、…个约束 松驰变量的值 对偶价格
对本例而言: (约束1)在500~900范围内变化时,对 偶价格(边际值)不变=100 (约束2)在702.8 ~1265范围内变化时, (边际值)不变=50

运筹学软件介绍

运筹学软件介绍

3. Excel
Microsoft Excel是美国微软公司开发的 是美国微软公司开发的Windows环境下的电子 是美国微软公司开发的 环境下的电子 表格系统,它是目前应用最为广泛的办公室表格处理软件之一。 表格系统,它是目前应用最为广泛的办公室表格处理软件之一。 规划求解是excel提供的一个加载宏, 提供的一个加载宏, 规划求解是 提供的一个加载宏 用途:整数规划、线性规划、非线性规划、动态规划、运输问题、 用途 整数规划、线性规划、非线性规划、动态规划、运输问题、 整数规划 最短路、最大流等运筹模型。 最短路、最大流等运筹模型。 非线性规划工具取自得克萨斯大学奥斯汀分校的Leon Lasdon和 非线性规划工具取自得克萨斯大学奥斯汀分校的 和 共同开发的Generalized 克里夫兰州立大学的 Allan Waren共同开发的 共同开发的 Reduced Gradient (GRG2)非线性最优化代码。线性和整数规划 非线性最优化代码。 非线性最优化代码 公司的John Watson和 Dan 问题取自 Frontline Systems公司的 公司的 和 Fylstra提供的有界变量单纯形法和分支边界法。 提供的有界变量单纯形法和分支边界法。 提供的有界变量单纯形法和分支边界法 网址: 网址: /china/office/preview/programs/ex cel/
LINDO软件LP的注意事项
1.目标函数及各约束条件之间一定要有 目标函数及各约束条件之间一定要有 "Subject to (ST) "分开 分开. 分开 2.变量名不能超过8个字符 变量名不能超过8 变量名不能超过 个字符. 3.变量与其系数间可以有空格,单不能有任何 变量与其系数间可以有空格, 变量与其系数间可以有空格 运算符号(如乘号 如乘号"*"等 运算符号 如乘号 等). 4. 要输入 或>=约束,相应以 或>代替即可 要输入<=或 约束 相应以<或 代替即可 约束, 代替即可. 5.一般 一般LINDO 中不能接受括号 中不能接受括号"()"和逗号 和逗号",", 一般 和逗号 需写成400X1+400X2;10,000 例:400(X1+X2) 需写成 需写成10000. 需写成 6.表达式应当已经过简化。不能出现 表达式应当已经过简化。 表达式应当已经过简化 2X1+3X2-4X1,而应写成 而应写成-2X1+3X2. 而应写成

LINGO软件介绍

LINGO软件介绍

LINGO 程序设计介绍在运筹学中中会遇到如规划类的题型,在这种模型中总存在着一个目标,并希望这个目标的取值尽可能的大或小,同时与这个目标有关的一系列变量之间存在一些约束。

在构造出目标函数和约束条件的表达式后,我们需要对求出这个最值和各变量的取值。

一般我们用LINGO 来对模型进行求解,本文将通过举一个简单的例子,围绕这个例子逐步学习LINGO 的使用。

LINGO 只是一个求解工具,我们主要的任务还是模型的建立!当你在windows 下开始运行LINGO 系统时,会得到类似下面的一个窗口:外层是主框架窗口,包含了所有菜单命令和工具条,其它所有的窗口将被包含在主窗口之下。

在主窗口内的标题为LINGO Model – LINGO1的窗口是LINGO 的默认模型窗口,建立的模型都都要在该窗口内编码实现。

一.变量、常量定义在lingo 中变量在使用前是无需定义也可以使用的。

在描述类似ij i a x ,带有下标的变量时,我们可以在使用时一一例举,即,x1,x2,x3….x8, 但这样显然很麻烦(刚接触LINGO 的时候大部分是这样使用的)。

Lingo 中可以使用sets 来预先定义这些变量,然后就可以在loop 语句方便地访问这一组变量,也可以用小x(2), a(2,3)的形式访问个别变量,这和C 语言中的数组是类似的。

1.SETS 的使用:为了定义ij i a x ,那么首先要确定下标i 和j 的取值范围。

在lingo 中用sets 来表示。

代码:SETS :Xb1 /1..8/ ;Xb2 /1..6/ ;ENDSETS其中xb1、xb2分别为下标1..8 ,1..6的名字(sets_name),这些名字在loop语句中要使用。

对于sets_name一般将它命名为有意义的名称,这个sets_name必须以字母或下划线(_)开始。

二维下标是在两个一维下标定义的基础上给定的,定义a(i,j)下标的代码如下:SETS :Xb1 /1..8/;Xb2 /1..6/ ;Xb3 (xb1,xb2);ENDSETS现在下标已经定义完成了,定义数组变量时则需在下标后加上冒号再写上变量名,代码如下:SETS :Xb1 /1..8/:x,c,b ;Xb2 /1..6/ ;Xb3 (xb1,xb2):a;ENDSETS2.DATA的使用(常量定义):在lingo中把常量理解为已经被给定某常数的变量,在DATA 中对一些变量赋值,使之成为常量。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

LINGO 8.0 TUTORIALCreated by:Kris ThornburgAnne HummelTable of ContentsIntroduction 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)Introduction to LINGO 8.0LINGO 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!Creating a LINGO ModelAn optimization model consists of three parts:•Objective function – This is single formula that describes exactly what the model should optimize. A general manufacturing example of an objective function would be tominimize the cycle time for a given product.•Variables – These are the quantities that can be changed to produce the optimal value of the objective function. For example, when driving a car, the duration of the trip (t) andthe speed at which it is taken (v) determine the distance (d) that can be traveled.•Constraints – These are formulas that define the limits on the values of the variables. If an ice cream store is determining how many flavors it should offer, only a positivenumber of flavors is feasible. This constraint could be expressed asFlavors >= 0;A sample model for cookie production by two bakers at a bakery is given by:! A cookie store can produce drop cookies and decorated cookies, which sell for $1 and $1.50 apiece, respectively. The two bakers each work 8 hours per day and can produce up to 400 drop cookies and 200 decorated cookies. It takes 1 minute to produce each drop cookie and 3 minutes to produce each decorated cookie. What combination of cookies produced will maximize the baker's profit? ;MAX = 1*Drop + 1.5*Deco;Drop <= 400;Deco <= 200;1/60*Drop + 3/60*Deco <=16;Several other items must be noted about this model:•Comments in the model are initiated with an exclamation point (!) and appear in green text.•LINGO specified operators and functions appear in blue text.•All other text is shown in black.•Each LINGO statement must end in a semi-colon (;).•Variable names are not case-sensitive and must begin with a letter (A-Z). Other characters in the variable name may be letters, numbers (0-9), or the underscore character (_). Variable names can be up to 32 characters in length.Solving a LINGO ModelOnce 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 wouldimprove if the constraining value is increased by one unit.Using Sets in LINGOLINGO allows you to group many instances of the same variable into sets. For example, if a model involved 27 delivery trucks, then these 27 trucks could be described more simply as a single set. Sets may also include attributes for each member, such as the hauling capacity for each delivery truck.Sets may be either primitive or derived. A primitive set is one that contains distinct members. A derived set, however, contains other sets as its members.To use sets in a model, the special section called the SETS section must be defined before any of the set members are used in the model’s constraints. This section begins with the tag SETS: and ends with the tag ENDSETS.A primitive set could be defined as follows:SETS:Trucks/TR1..TR27/:Capacity;ENDSETSThis set is given the setname “Trucks” and contains 27 members, identified by TR1 – TR27. The attributes for each member are called “Capacity.”The derived set is defined similarly, but must also include the parent set list. An example of a derived set could be:SETS:Product/X Y/;Machine/L M/;Make(Product Machine)/X L, X M,Y M/;ENDSETSThis set declaration defines two primitive sets, Product and Machine, and one derived set called Make. The Make set is derived from the parent sets Product and Machine. Members are specified as shown. Notice that a fourth Product-Machine combination, Y L, could be theoretically possible. This example does not allow for such a combination. If all combinations of the parent sets are possible, then no member set need be defined. An attribute list for the derived set can also be included in the same way as for a primitive set.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 SectionLINGO 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;ENDSETSDATA:X = 1, 2, 3;Y = 4, 5, 6;ENDDATAThe 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;ENDSETSDATA:X, Y = 1, 4,2, 5,3, 6;ENDDATAWhen parameters or attributes are defined in the DATA section of a model, a feature called What-if Analysis can be used to examine the effects of varying the value of the parameter or attribute. For example, if the inflation rate is most likely going to fall between 2% and 6%, the parameter can be defined as follows in the DATA section:DATA:INFLATION_RATE = ?;ENDDATAWhen LINGO encounters the ? in the DATA section, it will prompt the user to enter a value for the parameter. The user can then enter values between 2% and 6%, and LINGO will solve the model using that “what-if” value.All the elements of an attribute can be initialized to a single value using the DATA section as well. The following example shows how to assign the value of 20 to all seven members of the NEEDS attribute and 100 to all seven members of the COST attribute:SETS:DAYS / MO, TU, WE, TH, FR, SA,SU/: NEEDS, COST;ENDSETSDATA:NEEDS, COST = 20, 100;ENDDATAData values can also be omitted from the DATA section of a LINGO model to indicate that LINGO is free to determine the values of those attributes itself. The following example shows that the first two values of the attribute CAPACITY have been initialized to 34, but the last three variables have not been defined:SETS:YEARS /1..5/: CAPACITY;ENDSETSDATA:CAPACITY = 34, 34, , , ;ENDDATAVariable Types in LINGOAll 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 boundsSimilar 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 InterfaceOperations 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 windowOpen (F3) Open a saved fileSave (F4) Save a current modelSave As (F5) Save a current model to a new filenameClose (F6) Close the current modelPrint (F7) Prints the current window’s contentPrint Setup (F8) Configures printer preferencesPrint Preview (Shift+F8) Displays the window content as it would look if printedLog Output(F9)Opens a log file to log output to the command windowTake Commands (F11)Runs a command script contained in a fileImport LINDO File (F12)Converts a LINDO file into a LINGO modelExport File Exports a model in MPS or MPI file formatLicense Prompts user for new license password to upgrade system Database User Info Prompts for a user id and password for database access via thefunction@ODBC()LINGOExit (F10) ClosesThe Edit menu contains the following commands:Undo (ctrl+z)Undoes the last actionRedo (ctrl+y)Redoes the last undo commanddeletes highlighted textandCut (ctrl+x) Copieshighlightedtext to the clipboardCopy (ctrl+c) Copiesclipboard’s contents into the documentthePaste(ctrl+v) PastesPaste Special Pastes the clipboard’s content into the document, in a user-specified mannerSelect All (ctrl+a)Selects all of the contents of the current windowFind (ctrl+f)Searches the document for a specific text stringFind Next(ctrl+n)Searches the document for the next occurrence of a specific textstringReplace (ctrl+h)Replaces a specific text string with a new stringGo To Line(ctrl+t)Moves the cursor to a certain line numberMatch Parenthesis (ctrl+p) Finds the selected parenthesis’s matePaste Function Pastes a syntax template for a specific LINGO @function Select Font(ctrl+j)Configures the font for a selected portion of textInsert New Object Puts an OLE object in the documentobjectsexternaltolinksLinks CreatesObject P roperties Defines the properties of an embedded objectThe LINGO menu contains the following commands:modelSolve(ctrl+s) SolvestheSolution(ctrl+o)Makes a solution report window for the current modelRange (ctrl+r)Creates a range analysis report for the current windowoptionssystemOptions(ctrl+i)SetsGenerate Generates the algebraic form of the modelPicture(ctrl+k)Displays a graphic of the model’s matrixDebug(ctrl+d)Identifies errors in infeasible and unbounded modelsModel Statistics (ctrl+e)Reports the technical details the modelreport for the current windowformulationaLook(ctrl+l) CreatesThe Window menu contains the following commands:Command Window (ctrl+1) Opens a window for command-line operation of LINGO Status Window(ctrl+2)Opens the solver's status windowSend to Back(ctrl+b)Places the current window behind all other open windows Close All (ctrl+3)Closes all open windowsTile (ctrl+4)Places open windows in a tiled arrangementCascade (ctrl+5)Places all open windows in a cascaded arrangementArrange Icons(ctrl+6)Aligns icon windows at the bottom of the main LINGO window The Help window contains the following commands:LINGO’smanualHelp Topics OpensRegister Registers your version of LINGO onlineto download software updatesAutoUpdate ProvidespromptsAbout LINGO Displays software informationA single toolbar located at the top of the main LINGO window contains many of the samecommands 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 RedoOpen Print Copy UndoMatch Close HelpFind Parenthesis Solution Options All TopicsGo To Line Solve Matrix Send to Tile HelpPicture BackLINGO Operators and FunctionsLINGO 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 FALSEThe 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: >=The following list contains a sampling of mathematical functions that can be used in LINGO: •@ABS(X) – returns the absolute value of X•@SIGN(X) – returns -1 if X is negative and +1 if X is positive•@EXP(X) – calculates e X•@LOG(X) – calculates the natural log of X•@SIN(X) – returns the sine of X, where X is the angle in radians•@COS(X) – returns the cosine of X•@TAN(X) – returns the tangent of XLINGO also contains a plethora of financial, probability, and import/export functions. These are commonly used in more advanced models, which are beyond the intended scope of this tutorial.Common LINGO Error MessagesLINGO provides a variety of error messages useful for debugging a developing model. The most common errors include the following:•7: Unable to open file: filenameo Retype filename correctly•11: Invalid input: A syntax error has occurredo Check the line LINGO suggests for missing semi-colons, etc.•12: Unmatched parenthesiso Close the parenthesis set•15: No relational operator foundo Make sure all constraints contain =, <=, >=•44: Unterminated conditiono Put a colon at the end of each conditional statement in a set operator •50: Improper use of the @FOR() functiono@FOR() functions cannot be nested inside other set operators •68: Multiple objective functions in modelo 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 foundo Check model’s consistency and constraints•82: Unbounded solutiono Add constraints•102: Unrecognized variable name: variable nameo Check spelling•108: The model’s dimensions exceed the capacity of this versiono Upgrade to full version or use Excel•164: Invalid LINGO nameo Create a name to conform to LINGO’s naming conventionsLINGO Programming ExamplesA 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;ENDSETSDATA:WEIGHT RATING =1 23 94 33 83 101 65 410 10;KNAPSACK_CAPACITY = 15;ENDDATAMAX = @SUM( ITEMS: RATING * INCLUDE);@SUM( ITEMS: WEIGHT * INCLUDE) <=KNAPSACK_CAPACITY;@FOR( ITEMS: @BIN( INCLUDE));Another common programming model is the transportation problem. Transportation problems deal with transporting goods from one location to another at minimal cost. This example shows how to model a simple transportation problem.MODEL:! A 6 Warehouse 8 Vendor Transportation Problem;SETS:WAREHOUSES / WH1 WH2 WH3 WH4 WH5 WH6/: CAPACITY;VENDORS / V1 V2 V3 V4 V5 V6 V7 V8/ : DEMAND;LINKS( WAREHOUSES, VENDORS): COST, VOLUME;ENDSETS! The objective;MIN = @SUM( LINKS( I, J):COST( I, J) * VOLUME( I, J));! The demand constraints;@FOR( VENDORS( J):@SUM( WAREHOUSES( I): VOLUME( I, J)) =DEMAND( J));! The capacity constraints;@FOR( WAREHOUSES( I):@SUM( VENDORS( J): VOLUME( I, J)) <=CAPACITY( I));! Here is the data;DATA:CAPACITY = 60 55 51 43 41 52;DEMAND = 35 37 22 32 41 32 43 38;COST = 6 2 6 7 4 2 5 94 95 3 8 5 8 25 2 1 9 7 4 3 37 6 7 3 9 2 7 12 3 9 5 7 2 6 55 5 2 2 8 1 4 3;ENDDATAEND。

相关文档
最新文档