LINGO简介
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Steps (1) Variables: Standard, Turbo (2) Objective Function: Max=100*Standard+150*Turbo
(3) Constraints: Standard <=100 Turbo 输入到窗口如下: <=120
Standard+2*Turbo <=160
Widget Capacity Data:
Warehouse Widgets On Hand 1 2 3 60 55 51
Vendor Widget Demand:
Vendor Widget Demand 1 2 3 35 37 22
4
5 6
43
41 52
4
5 6 7 8
32
41 32 43 38
二、Starting LINGO in windows (1) 开始 程序 LINGO
(2) 双击桌面上“LINGO” 的快捷方式 其窗口如下:
三、LINGO模型的构成 LINGO模型由以下三部分组成: 1. Objective Function 2. Variables—decision variables 3. Constraints 注意: 1. 在LINGO中每行以“ ;”结束.
2. 在LINGO中以“<=或<”代替“
以“>=或>”代替“ ”.
”;
3. 注释以“!”开始以“;”结 束. 4. 在LINGO中变量名不区分大小写 5. 变量名以字母(A-Z)开始,紧结可以是字母、 数字、下化线,变量名不能超过32个字符.
For example:
The CompuQuick Corporation produces two models of computers – Standard and Turbo. CompuQuick can sell every Standard unit it produces for a profit contribution of $100, and each Turbo unit for a contribution of $150. At the CompuQuick factory, the Standard computer production line produce, at most ,100 computers per day. At the same time, the Turbo computer production line can turn out 120 computers per day. Furthermore, CompuQuick has a limited supply of daily labor. In particular, there is a total of 160 hours of labor available each day. Standard computers require 1 hour of labor, while Turbo computers are relatively more labor intense requiring 2 hours of labor. The problem for CompuQuick is to determine the mix of Standard and Turbo computers to produce each day to maximize total profit without exceeding line and labor capacity limits.
建立数学模型:
用 x ij 表示从第 i 个仓库运到第 j 个商人的小机械数量
则数学模型为:
min z
c
i 1 j 1 ij
6
8
ij
x ij j 1, 2 , ,8; i 1, 2 , , 6 ; i 1, 2 , , 6 ; j 1, 2 , ,8 .
LINGO简介
一、What’s is LINGO
LINGO is a simple tool which lets you utilize the power of linear and nonlinear optimization to formulate large problems concisely,solve them,and analyze the solution.
四. 求解LINGO模型 LINGO Solve or
Solver Status Window
Sample Solution Report
Command-line Prompt
输入模型后如下:
Solving the Model from the Command-line
LINGO的进一步开发
In a similar manner, LINGO’s modeling language allows you to express the objective function in a form that is short, easy to type, and easy to understand. The equivalent LINGO statement is: MIN = @SUM( LINKS(I,J): COST(I,J) * VOLUME(I,J)); In words, this says to minimize the sum of the shipping COST per widget times the VOLUME of widgets shipped for all LINKS between the warehouses and vendors. The following table compares the mathematical notation to the LINGO syntax for our objective function. Math Notation LINGO Syntax Minimize ∑ij COST ij MIN = @SUM( LINKS( I, J): ) COST(I,J)
VOLUME ij
VOLUME(I,J)
The Constraints
With the objective function in place, the next step is to formulate the constraints. There are two sets of constraints in this model. The first set guarantees that each vendor receives the number of widgets required. We will refer to this first set of constraints as being the demand constraints. The second set of constraints, called the capacity constraints, ensures no warehouse ships out more widgets than it has on hand. Starting with the demand constraint for Vendor 1, we need to sum up the shipments from all the warehouses to Vendor 1 and set them equal to Vendor 1's demand of 35 widgets. Thus, if we were using scalar based notation, we would need to construct the following: VOLUME_1_1 + VOLUME_2_1 + VOLUME_3_1 +
If you are familiar with mathematical notation, you could express this long equation in a much more compact manner as follows: Minimize
ijCOST
ij * VOLUMEij
For brevity, we included only 9 of the 48 terms in the objective. As one can see, entering such a lengthy formula would be tedious and prone to errors. Extrapolate to the more realistic case where vendors could number in the thousands, and it becomes apparent that scalar based modeling is problematic at best.
s .t .
x
i 1 8
6
dj ri
x
j 1
ij
x ij 0
此模型用LINGO 可以解,但如果变量个数较多,约束个数 较多时,解起来比较复杂,能否用比较简单的方法来求?
LINGO的集合表达法:
The ቤተ መጻሕፍቲ ባይዱbjective Function
Our first pass at formulating the model will be to construct the objective function. As mentioned, WW wants to minimize total shipping costs. We will let the variable VOLUME_I_J denote the number of widgets shipped from warehouse I to vendor J. Then, if we were to explicitly write out our objective function using scalar variables we would have:
Shipping Cost per Widget ($): V1 V2 V3 V4 V5 V6 V7 V8
Wh1
Wh2 Wh3 Wh4 Wh5 Wh6
6
4 5 7 2 5
2
9 2 6 3 5
6
5 1 7 9 2
7
3 9 3 5 2
4
8 7 9 7 8
2
5 4 2 2 1
5
8 3 7 6 4
9
2 3 1 5 3
For our example, suppose that the Wireless Widget (WW) company has six warehouses supplying eight vendors with their widgets. Each warehouse has a supply of widgets that cannot be exceeded, and each vendor has a demand for widgets that must be satisfied. WW wants to determine how many widgets to ship from each warehouse to each vendor so as to minimize the total shipping cost. This is a classic optimization problem referred to as the transportation problem. The following diagram illustrates the problem:
MIN = 6 * VOLUME_1_1 + 2 * VOLUME_1_2 +
6 * VOLUME_1_3 + 7 * VOLUME_1_4 + 4 * VOLUME_1_5 + ... 8 * VOLUME_6_5 + VOLUME_6_6 + 4 * VOLUME_6_7 +
3 * VOLUME_6_8;