lingo基础入门Day 6
lingo练习一:集合遍历函数的应用
TOTALW = @SUM(ITEM : WEIGHT);
TOTALP = @SUM(ITEM : PROFIT);
SIGMA_X = @SUM(ITEM : X);
SIGMA_W = @SUM(ITEM : WEIGHT*X);
P = @PROD(ITEM : WEIGHT);
MAX_W = @SUM(ITEM : WEIGHT);
MIN_W = @SUM(ITEM : WEIGHT);
MAX_P = @SUM(ITEM : PROFIT);
MIN_P = @SUM(ITEM : PROFIT);
举例:
!Name: 背包问题模型
!Date: 2022-03-16
!Desc: 10件货物的背包问题
;
MODEL:
SETS:
ITEM/1 2 3 4 5 6 7 8 9 10/:WEIGHT, PROFIT,X;
ENDSETS
DATA:
WEIGHT = 6 3 4 5 1 2 3 5 4 2;
PROFIT = 540 200 180 350 60 150 280 450 320 120;
ENDDATA
MAX = @SUM(ITEM(I):PROFIT(I)*x(I));
@SUM(ITEM(I):WEIGHT(I)*X(I))<=30;
@FOR(ITEM(I):@BIN(X(I)));
TOTALW = @SUM(ITEM : WEIGHT);
TOTALP = @SUM(ITEM : PROFIT);
SIGMA_X = @SUM(ITEM : X);
SIGMA_W = @SUM(ITEM : WEIGHT*X);
P = @PROD(ITEM : WEIGHT);
MAX_W = @SUM(ITEM : WEIGHT);
MIN_W = @SUM(ITEM : WEIGHT);
MAX_P = @SUM(ITEM : PROFIT);
MIN_P = @SUM(ITEM : PROFIT);
END
结果显示:
Global optimal solution found.
Objective value: 2410.000
Objective bound: 2410.000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0
Elapsed runtime seconds: 0.08
Model Class: MILP
Total variables: 12
Nonlinear variables: 0
Integer variables: 10
Total constraints: 4
Nonlinear constraints: 0
Total nonzeros: 42
Nonlinear nonzeros: 0
Variable Value Reduced Cost
TOTALW 35.00000 0.000000
TOTALP 2650.000 0.000000
SIGMA_X 8.000000 0.000000
SIGMA_W 30.00000 0.000000
P 86400.00 0.000000
MAX_W 35.00000 0.000000
MIN_W 35.00000 0.000000
MAX_P 2650.000 0.000000
MIN_P 2650.000 0.000000
WEIGHT( 1) 6.000000 0.000000
WEIGHT( 2) 3.000000 0.000000
WEIGHT( 3) 4.000000 0.000000
WEIGHT( 4) 5.000000 0.000000
WEIGHT( 5) 1.000000 0.000000
WEIGHT( 6) 2.000000 0.000000
WEIGHT( 7) 3.000000 0.000000
WEIGHT( 8) 5.000000 0.000000
WEIGHT( 9) 4.000000 0.000000
WEIGHT( 10) 2.000000 0.000000
PROFIT( 1) 540.0000 0.000000
PROFIT( 2) 200.0000 0.000000
PROFIT( 3) 180.0000 0.000000
PROFIT( 4) 350.0000 0.000000
PROFIT( 5) 60.00000 0.000000
PROFIT( 6) 150.0000 0.000000
PROFIT( 7) 280.0000 0.000000
PROFIT( 8) 450.0000 0.000000
PROFIT( 9) 320.0000 0.000000
PROFIT( 10) 120.0000 0.000000
X( 1) 1.000000 -540.0000
X( 2) 1.000000 -200.0000
X( 3) 0.000000 -180.0000
X( 4) 1.000000 -350.0000
X( 5) 0.000000 -60.00000
X( 6) 1.000000 -150.0000
X( 7) 1.000000 -280.0000
X( 8) 1.000000 -450.0000
X( 9) 1.000000 -320.0000
X( 10) 1.000000 -120.0000
Row Slack or Surplus Dual Price
1 2410.000 1.000000
2 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
lingo练习二:产生一个向量
用lingo产生一个向量[1 4 9 16 25 36]
model:
sets:
A/1..6/:x;
endsets
@for(A(i): x(i)=i^2);
end
显示结果:
Feasible solution found.
Total solver iterations: 0
Elapsed runtime seconds: 0.06
Model Class: . . .
Total variables: 0
Nonlinear variables: 0
Integer variables: 0
Total constraints: 0
Nonlinear constraints: 0
Total nonzeros: 0
Nonlinear nonzeros: 0
Variable Value
X( 1) 1.000000
X( 2) 4.000000
X( 3) 9.000000
X( 4) 16.00000
X( 5) 25.00000
X( 6) 36.00000
Row Slack or Surplus
1 0.000000
2 0.000000
3 0.000000
4 0.000000
5 0.000000
6 0.000000
用lingo产生一个60维的向量X,Xi=i^0.5
model:
sets:
A/1..60/:x;
endsets
@for(A(i): x(i)=@sqrt(i));
end
显示结果:
Feasible solution found.
Total solver iterations: 0
Elapsed runtime seconds: 0.06
Model Class: . . .
Total variables: 0
Nonlinear variables: 0
Integer variables: 0
Total constraints: 0
Nonlinear constraints: 0
Total nonzeros: 0
Nonlinear nonzeros: 0
Variable Value
X( 1) 1.000000 X( 2) 1.414214 X( 3) 1.732051
X( 4) 2.000000 X( 5) 2.236012 X( 6) 2.449490
X( 7) 2.645751 X( 8) 2.828427 X( 9) 3.000000
X( 10) 3.162278 X( 11) 3.316625 X( 12) 3.464102
X( 13) 3.605551 X( 14) 3.741657 X( 15) 3.872983
X( 16) 4.000000
X( 17) 4.123106
X( 18) 4.242641
X( 19) 4.358899
X( 20) 4.472136
X( 21) 4.582576
X( 22) 4.690416
X( 23) 4.795832
X( 24) 4.898979
X( 25) 5.000000
X( 26) 5.099020
X( 27) 5.196152
X( 28) 5.291503
X( 29) 5.385165
X( 30) 5.477226
X( 31) 5.567764
X( 32) 5.656854
X( 33) 5.744563
X( 34) 5.830952
X( 35) 5.916080
X( 36) 6.000000
X( 37) 6.082763
X( 38) 6.164414
X( 39) 6.244998
X( 40) 6.324555
X( 41) 6.403124
X( 42) 6.480741
X( 43) 6.557439
X( 44) 6.633250
X( 45) 6.708204
X( 46) 6.782330
X( 47) 6.855655
X( 48) 6.928203
X( 49) 7.000000
X( 50) 7.071068
X( 51) 7.141428
X( 52) 7.211103
X( 53) 7.280110
X( 54) 7.348469
X( 55) 7.416198
X( 56) 7.483315
X( 57) 7.549834
X( 58) 7.615773
X( 59) 7.681146
X( 60) 7.745967
lingo练习三:
用lingo产生一个10维空间向量X:Xi=i2,1<=i<=5否则Xi=i0.5
model:
sets:
A/1..10/:x;
endsets
@for(A(i)|i#LE#5:x(i)=i^2);
@for(A(i)|i#GT#5:x(i)=@sqrt(i));
end
结果:
Feasible solution found.
Total solver iterations: 0
Elapsed runtime seconds: 0.06
Model Class: . . .
Total variables: 0
Nonlinear variables: 0
Integer variables: 0
Total constraints: 0
Nonlinear constraints: 0
Total nonzeros: 0
Nonlinear nonzeros: 0
Variable Value
X( 1) 1.000000
X( 2) 4.000000
X( 3) 9.000000
X( 4) 16.00000
X( 5) 25.00000
X( 6) 2.449490
X( 7) 2.645751
X( 8) 2.828427
X( 9) 3.000000
X( 10) 3.162278
Row Slack or Surplus
1 0.000000
2 0.000000
3 0.000000
4 0.000000
5 0.000000
6 0.000000
7 0.000000
8 0.000000
9 0.000000
10 0.000000
对刚产生的10维空间向量X,求出前五个元素乘积,后五元素平方和
model:
sets:
A/1..10/:x;
endsets
@for(A(i)|i#LE#5:x(i)=i^2);
@for(A(i)|i#GT#5:x(i)=@sqrt(i));
P = @prod(A(i)|i#LE#5: x(i));
S = @sum(A(i)|i#GT#5: x(i)*x(i));
end
实现结果:
Feasible solution found.
Total solver iterations: 0
Elapsed runtime seconds: 0.07
Model Class: . . .
Total variables: 0
Nonlinear variables: 0
Integer variables: 0
Total constraints: 0
Nonlinear constraints: 0
Total nonzeros: 0
Nonlinear nonzeros: 0
Variable Value
P 14400.00
S 40.00000
X( 1) 1.000000
X( 2) 4.000000
X( 3) 9.000000
X( 4) 16.00000
X( 5) 25.00000
X( 6) 2.449490
X( 7) 2.645751
X( 8) 2.828427
X( 9) 3.000000
X( 10) 3.162278
集合遍历函数的完整格式
完整格式 |
---|
@FOR(S(I)[|logical_condition]: expression); |
@SUM(S(I)[logical_condition]: expression); |
@MAX(S(I)[logical_condition]: expression); |
@MIN(S(I)[logical_condition]: expression); |
@PROD(S(I)[logical_condition]: expression); |
lingo练习四:整数规划
五个整数,不相同,和100
如果乘积最大,五个整数应该是多少?
model:
sets:
A/1..5/:x;
endsets
max = @prod(A:x);
@sum(A:x)=100;
@for(A: @GIN(x));
X(1)>=0+1;
X(2)>=X(1)+1;
X(3)>=X(2)+1;
X(4)>=X(3)+1;
X(5)>=X(4)+1;
end
实现结果:
Local optimal solution found.
Objective value: 3160080.
Objective bound: 3160080.
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 24
Elapsed runtime seconds: 1.35
Model Class: PINLP
Total variables: 5
Nonlinear variables: 5
Integer variables: 5
Total constraints: 7
Nonlinear constraints: 1
Total nonzeros: 19
Nonlinear nonzeros: 5
Variable Value Reduced Cost
X( 1) 18.00000 -175560.0
X( 2) 19.00000 -166320.0
X( 3) 20.00000 -158004.0
X( 4) 21.00000 -150480.0
X( 5) 22.00000 -143640.0
Row Slack or Surplus Dual Price
1 3160080. 1.000000
2 0.000000 0.000000
3 17.00000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
如果乘积最小,五个整数应该是多少?
model:
sets:
A/1..5/:x;
endsets
min = @prod(A:x);
@sum(A:x)=100;
@for(A: @GIN(x));
X(1)>=0+1;
@FOR(A(I)|I#LT#5: X(I)+1);
end
实现结果:
Local optimal solution found.
Objective value: 2160.000
Objective bound: 2160.000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 35
Elapsed runtime seconds: 0.26
Model Class: PINLP
Total variables: 5
Nonlinear variables: 5
Integer variables: 5
Total constraints: 7
Nonlinear constraints: 1
Total nonzeros: 19
Nonlinear nonzeros: 5
Variable Value Reduced Cost
X( 1) 1.000000 0.000000
X( 2) 2.000000 0.000000
X( 3) 3.000000 0.000000
X( 4) 4.000000 0.000000
X( 5) 90.00000 -516.0000
Row Slack or Surplus Dual Price
1 2160.000 -1.000000
2 0.000000 -540.0000
3 0.000000 -2340.000
4 0.000000 -720.0000
5 0.000000 -180.0000
6 0.000000 0.000000
7 85.00000 0.000000
lingo练习五:二维背包问题
一个40英尺的集装箱最大载重22吨,内部最大容积54立方米,现有六种货物,每种货物一件,重量、体积和运费如下表所示,问如何装在运送货物才能使得运费收入最大(嘉定不考虑货物的形状)?
货物 | 重量/T | 体积/立方米 | 运费/元 |
---|---|---|---|
A | 6 | 12 | 500 |
B | 10 | 18 | 900 |
C | 8 | 20 | 700 |
D | 5 | 33 | 1600 |
E | 12 | 25 | 1500 |
F | 14 | 21 | 1200 |
二维背包问题:
!Name: 背包问题模型
!Date: 2022-03-16
!Desc: 10件货物的背包问题
;
MODEL:
SETS:
ITEM:WEIGHT, VOLUMN, PRICE,X;
ENDSETS
DATA:
ITEM WEIGHT VOLUMN PRICE =
A 6 12 500
B 10 18 900
C 8 20 700
D 5 33 1600
E 12 25 1500
F 14 21 1200
;
ENDDATA
MAX = @SUM(ITEM(I):PRICE(I)*X(I));
@SUM(ITEM(I):WEIGHT(I)*X(I))<=22;
@SUM(ITEM: VOLUMN*X)<=54;
@FOR(ITEM(I):@BIN(X(I)));
TOTALW = @SUM(ITEM : WEIGHT);
TOTALP = @SUM(ITEM : PRICE);
SIGMA_X = @SUM(ITEM : X);
SIGMA_W = @SUM(ITEM : WEIGHT*X);
END
实际结果:
Global optimal solution found.
Objective value: 2800.000
Objective bound: 2800.000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0
Elapsed runtime seconds: 0.08
Model Class: MILP
Total variables: 8
Nonlinear variables: 0
Integer variables: 6
Total constraints: 5
Nonlinear constraints: 0
Total nonzeros: 32
Nonlinear nonzeros: 0
Variable Value Reduced Cost
TOTALW 55.00000 0.000000
TOTALP 6400.000 0.000000
SIGMA_X 2.000000 0.000000
SIGMA_W 19.00000 0.000000
WEIGHT( A) 6.000000 0.000000
WEIGHT( B) 10.00000 0.000000
WEIGHT( C) 8.000000 0.000000
WEIGHT( D) 5.000000 0.000000
WEIGHT( E) 12.00000 0.000000
WEIGHT( F) 14.00000 0.000000
VOLUMN( A) 12.00000 0.000000
VOLUMN( B) 18.00000 0.000000
VOLUMN( C) 20.00000 0.000000
VOLUMN( D) 33.00000 0.000000
VOLUMN( E) 25.00000 0.000000
VOLUMN( F) 21.00000 0.000000
PRICE( A) 500.0000 0.000000
PRICE( B) 900.0000 0.000000
PRICE( C) 700.0000 0.000000
PRICE( D) 1600.000 0.000000
PRICE( E) 1500.000 0.000000
PRICE( F) 1200.000 0.000000
X( A) 0.000000 -500.0000
X( B) 0.000000 -900.0000
X( C) 0.000000 -700.0000
X( D) 1.000000 -1600.000
X( E) 0.000000 -1500.000
X( F) 1.000000 -1200.000
Row Slack or Surplus Dual Price
1 2800.000 1.000000
2 3.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
lingo练习六:规模较大的二维背包问题
一节某种型号的铁路车棚车厢内部最大容积130立方米,最大载重60吨,现有60中货物,每种一件,重量体积运费如下,如何装运货物才能运费收入最大(不考虑货物形状)?
货物 | 重量 | 体积 | 运费 |
---|---|---|---|
1 | 6 | 14 | 500 |
2 | 8 | 4 | 900 |
3 | 10 | 8 | 700 |
4 | 12 | 20 | 900 |
5 | 14 | 11 | 1000 |
6 | 16 | 14 | 1100 |
7 | 18 | 17 | 1200 |
8 | 6 | 20 | 1300 |
9 | 12 | 23 | 1400 |
10 | 14 | 26 | 1500 |
11 | 26 | 14 | 1600 |
12 | 28 | 16 | 1700 |
13 | 9 | 10 | 1800 |
14 | 12 | 12 | 1200 |
15 | 14 | 14 | 1600 |
16 | 16 | 16 | 800 |
17 | 18 | 18 | 800 |
18 | 20 | 6 | 600 |
19 | 22 | 12 | 1400 |
20 | 14 | 9 | 1200 |
21 | 4 | 12 | 1000 |
22 | 8 | 14 | 800 |
23 | 20 | 16 | 600 |
24 | 11 | 18 | 400 |
25 | 14 | 20 | 2800 |
26 | 17 | 22 | 3200 |
27 | 20 | 14 | 1700 |
28 | 23 | 4 | 500 |
29 | 26 | 8 | 700 |
30 | 14 | 10 | 900 |
31 | 16 | 12 | 1100 |
32 | 18 | 14 | 1300 |
33 | 20 | 16 | 1500 |
34 | 22 | 18 | 1700 |
35 | 24 | 20 | 1900 |
36 | 26 | 22 | 2100 |
37 | 28 | 24 | 2300 |
38 | 10 | 26 | 2500 |
39 | 12 | 28 | 1300 |
40 | 14 | 30 | 1500 |
41 | 16 | 12 | 1700 |
42 | 18 | 14 | 1900 |
43 | 20 | 16 | 2100 |
44 | 22 | 8 | 2300 |
45 | 24 | 10 | 2500 |
46 | 26 | 11 | 2700 |
47 | 28 | 14 | 2900 |
48 | 30 | 26 | 3100 |
49 | 12 | 28 | 3300 |
50 | 14 | 30 | 3500 |
51 | 16 | 12 | 3200 |
52 | 8 | 14 | 1500 |
53 | 10 | 16 | 1400 |
54 | 11 | 8 | 1300 |
55 | 14 | 10 | 1200 |
56 | 16 | 11 | 1100 |
57 | 11 | 14 | 1000 |
58 | 10 | 16 | 900 |
59 | 5 | 11 | 800 |
60 | 6 | 10 | 700 |
!Name: 背包问题模型
!Date: 2022-03-16
!Desc: 10件货物的背包问题
;
MODEL:
SETS:
ITEM:WEIGHT, VOLUMN, PRICE,X;
ENDSETS
DATA:
ITEM WEIGHT VOLUMN PRICE =
1 6 14 500
2 8 4 900
3 10 8 700
4 12 20 900
5 14 11 1000
6 16 14 1100
7 18 17 1200
8 6 20 1300
9 12 23 1400
10 14 26 1500
11 26 14 1600
12 28 16 1700
13 9 10 1800
14 12 12 1200
15 14 14 1600
16 16 16 800
17 18 18 800
18 20 6 600
19 22 12 1400
20 14 9 1200
21 4 12 1000
22 8 14 800
23 20 16 600
24 11 18 400
25 14 20 2800
26 17 22 3200
27 20 14 1700
28 23 4 500
29 26 8 700
30 14 10 900
31 16 12 1100
32 18 14 1300
33 20 16 1500
34 22 18 1700
35 24 20 1900
36 26 22 2100
37 28 24 2300
38 10 26 2500
39 12 28 1300
40 14 30 1500
41 16 12 1700
42 18 14 1900
43 20 16 2100
44 22 8 2300
45 24 10 2500
46 26 11 2700
47 28 14 2900
48 30 26 3100
49 12 28 3300
50 14 30 3500
51 16 12 3200
52 8 14 1500
53 10 16 1400
54 11 8 1300
55 14 10 1200
56 16 11 1100
57 11 14 1000
58 10 16 900
59 5 11 800
60 6 10 700
;
ENDDATA
MAX = @SUM(ITEM(I):PRICE(I)*X(I));
@SUM(ITEM(I):WEIGHT(I)*X(I))<=60;
@SUM(ITEM: VOLUMN*X)<=130;
@FOR(ITEM(I):@BIN(X(I)));
TOTALW = @SUM(ITEM : WEIGHT);
TOTALP = @SUM(ITEM : PRICE);
SIGMA_X = @SUM(ITEM : X);
SIGMA_W = @SUM(ITEM : WEIGHT*X);
END
实现结果:
Global optimal solution found.
Objective value: 14000.00
Objective bound: 14000.00
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0
Elapsed runtime seconds: 0.09
Model Class: MILP
Total variables: 62
Nonlinear variables: 0
Integer variables: 60
Total constraints: 5
Nonlinear constraints: 0
Total nonzeros: 302
Nonlinear nonzeros: 0
Variable Value Reduced Cost
TOTALW 959.0000 0.000000
TOTALP 92100.00 0.000000
SIGMA_X 5.000000 0.000000
SIGMA_W 60.00000 0.000000
WEIGHT( 1) 6.000000 0.000000
WEIGHT( 2) 8.000000 0.000000
WEIGHT( 3) 10.00000 0.000000
WEIGHT( 4) 12.00000 0.000000
WEIGHT( 5) 14.00000 0.000000
WEIGHT( 6) 16.00000 0.000000
WEIGHT( 7) 18.00000 0.000000
WEIGHT( 8) 6.000000 0.000000
WEIGHT( 9) 12.00000 0.000000
WEIGHT( 10) 14.00000 0.000000
WEIGHT( 11) 26.00000 0.000000
WEIGHT( 12) 28.00000 0.000000
WEIGHT( 13) 9.000000 0.000000
WEIGHT( 14) 12.00000 0.000000
WEIGHT( 15) 14.00000 0.000000
WEIGHT( 16) 16.00000 0.000000
WEIGHT( 17) 18.00000 0.000000
WEIGHT( 18) 20.00000 0.000000
WEIGHT( 19) 22.00000 0.000000
WEIGHT( 20) 14.00000 0.000000
WEIGHT( 21) 4.000000 0.000000
WEIGHT( 22) 8.000000 0.000000
WEIGHT( 23) 20.00000 0.000000
WEIGHT( 24) 11.00000 0.000000
WEIGHT( 25) 14.00000 0.000000
WEIGHT( 26) 17.00000 0.000000
WEIGHT( 27) 20.00000 0.000000
WEIGHT( 28) 23.00000 0.000000
WEIGHT( 29) 26.00000 0.000000
WEIGHT( 30) 14.00000 0.000000
WEIGHT( 31) 16.00000 0.000000
WEIGHT( 32) 18.00000 0.000000
WEIGHT( 33) 20.00000 0.000000
WEIGHT( 34) 22.00000 0.000000
WEIGHT( 35) 24.00000 0.000000
WEIGHT( 36) 26.00000 0.000000
WEIGHT( 37) 28.00000 0.000000
WEIGHT( 38) 10.00000 0.000000
WEIGHT( 39) 12.00000 0.000000
WEIGHT( 40) 14.00000 0.000000
WEIGHT( 41) 16.00000 0.000000
WEIGHT( 42) 18.00000 0.000000
WEIGHT( 43) 20.00000 0.000000
WEIGHT( 44) 22.00000 0.000000
WEIGHT( 45) 24.00000 0.000000
WEIGHT( 46) 26.00000 0.000000
WEIGHT( 47) 28.00000 0.000000
WEIGHT( 48) 30.00000 0.000000
WEIGHT( 49) 12.00000 0.000000
WEIGHT( 50) 14.00000 0.000000
WEIGHT( 51) 16.00000 0.000000
WEIGHT( 52) 8.000000 0.000000
WEIGHT( 53) 10.00000 0.000000
WEIGHT( 54) 11.00000 0.000000
WEIGHT( 55) 14.00000 0.000000
WEIGHT( 56) 16.00000 0.000000
WEIGHT( 57) 11.00000 0.000000
WEIGHT( 58) 10.00000 0.000000
WEIGHT( 59) 5.000000 0.000000
WEIGHT( 60) 6.000000 0.000000
VOLUMN( 1) 14.00000 0.000000
VOLUMN( 2) 4.000000 0.000000
VOLUMN( 3) 8.000000 0.000000
VOLUMN( 4) 20.00000 0.000000
VOLUMN( 5) 11.00000 0.000000
VOLUMN( 6) 14.00000 0.000000
VOLUMN( 7) 17.00000 0.000000
VOLUMN( 8) 20.00000 0.000000
VOLUMN( 9) 23.00000 0.000000
VOLUMN( 10) 26.00000 0.000000
VOLUMN( 11) 14.00000 0.000000
VOLUMN( 12) 16.00000 0.000000
VOLUMN( 13) 10.00000 0.000000
VOLUMN( 14) 12.00000 0.000000
VOLUMN( 15) 14.00000 0.000000
VOLUMN( 16) 16.00000 0.000000
VOLUMN( 17) 18.00000 0.000000
VOLUMN( 18) 6.000000 0.000000
VOLUMN( 19) 12.00000 0.000000
VOLUMN( 20) 9.000000 0.000000
VOLUMN( 21) 12.00000 0.000000
VOLUMN( 22) 14.00000 0.000000
VOLUMN( 23) 16.00000 0.000000
VOLUMN( 24) 18.00000 0.000000
VOLUMN( 25) 20.00000 0.000000
VOLUMN( 26) 22.00000 0.000000
VOLUMN( 27) 14.00000 0.000000
VOLUMN( 28) 4.000000 0.000000
VOLUMN( 29) 8.000000 0.000000
VOLUMN( 30) 10.00000 0.000000
VOLUMN( 31) 12.00000 0.000000
VOLUMN( 32) 14.00000 0.000000
VOLUMN( 33) 16.00000 0.000000
VOLUMN( 34) 18.00000 0.000000
VOLUMN( 35) 20.00000 0.000000
VOLUMN( 36) 22.00000 0.000000
VOLUMN( 37) 24.00000 0.000000
VOLUMN( 38) 26.00000 0.000000
VOLUMN( 39) 28.00000 0.000000
VOLUMN( 40) 30.00000 0.000000
VOLUMN( 41) 12.00000 0.000000
VOLUMN( 42) 14.00000 0.000000
VOLUMN( 43) 16.00000 0.000000
VOLUMN( 44) 8.000000 0.000000
VOLUMN( 45) 10.00000 0.000000
VOLUMN( 46) 11.00000 0.000000
VOLUMN( 47) 14.00000 0.000000
VOLUMN( 48) 26.00000 0.000000
VOLUMN( 49) 28.00000 0.000000
VOLUMN( 50) 30.00000 0.000000
VOLUMN( 51) 12.00000 0.000000
VOLUMN( 52) 14.00000 0.000000
VOLUMN( 53) 16.00000 0.000000
VOLUMN( 54) 8.000000 0.000000
VOLUMN( 55) 10.00000 0.000000
VOLUMN( 56) 11.00000 0.000000
VOLUMN( 57) 14.00000 0.000000
VOLUMN( 58) 16.00000 0.000000
VOLUMN( 59) 11.00000 0.000000
VOLUMN( 60) 10.00000 0.000000
PRICE( 1) 500.0000 0.000000
PRICE( 2) 900.0000 0.000000
PRICE( 3) 700.0000 0.000000
PRICE( 4) 900.0000 0.000000
PRICE( 5) 1000.000 0.000000
PRICE( 6) 1100.000 0.000000
PRICE( 7) 1200.000 0.000000
PRICE( 8) 1300.000 0.000000
PRICE( 9) 1400.000 0.000000
PRICE( 10) 1500.000 0.000000
PRICE( 11) 1600.000 0.000000
PRICE( 12) 1700.000 0.000000
PRICE( 13) 1800.000 0.000000
PRICE( 14) 1200.000 0.000000
PRICE( 15) 1600.000 0.000000
PRICE( 16) 800.0000 0.000000
PRICE( 17) 800.0000 0.000000
PRICE( 18) 600.0000 0.000000
PRICE( 19) 1400.000 0.000000
PRICE( 20) 1200.000 0.000000
PRICE( 21) 1000.000 0.000000
PRICE( 22) 800.0000 0.000000
PRICE( 23) 600.0000 0.000000
PRICE( 24) 400.0000 0.000000
PRICE( 25) 2800.000 0.000000
PRICE( 26) 3200.000 0.000000
PRICE( 27) 1700.000 0.000000
PRICE( 28) 500.0000 0.000000
PRICE( 29) 700.0000 0.000000
PRICE( 30) 900.0000 0.000000
PRICE( 31) 1100.000 0.000000
PRICE( 32) 1300.000 0.000000
PRICE( 33) 1500.000 0.000000
PRICE( 34) 1700.000 0.000000
PRICE( 35) 1900.000 0.000000
PRICE( 36) 2100.000 0.000000
PRICE( 37) 2300.000 0.000000
PRICE( 38) 2500.000 0.000000
PRICE( 39) 1300.000 0.000000
PRICE( 40) 1500.000 0.000000
PRICE( 41) 1700.000 0.000000
PRICE( 42) 1900.000 0.000000
PRICE( 43) 2100.000 0.000000
PRICE( 44) 2300.000 0.000000
PRICE( 45) 2500.000 0.000000
PRICE( 46) 2700.000 0.000000
PRICE( 47) 2900.000 0.000000
PRICE( 48) 3100.000 0.000000
PRICE( 49) 3300.000 0.000000
PRICE( 50) 3500.000 0.000000
PRICE( 51) 3200.000 0.000000
PRICE( 52) 1500.000 0.000000
PRICE( 53) 1400.000 0.000000
PRICE( 54) 1300.000 0.000000
PRICE( 55) 1200.000 0.000000
PRICE( 56) 1100.000 0.000000
PRICE( 57) 1000.000 0.000000
PRICE( 58) 900.0000 0.000000
PRICE( 59) 800.0000 0.000000
PRICE( 60) 700.0000 0.000000
X( 1) 0.000000 -500.0000
X( 2) 0.000000 -900.0000
X( 3) 0.000000 -700.0000
X( 4) 0.000000 -900.0000
X( 5) 0.000000 -1000.000
X( 6) 0.000000 -1100.000
X( 7) 0.000000 -1200.000
X( 8) 0.000000 -1300.000
X( 9) 0.000000 -1400.000
X( 10) 0.000000 -1500.000
X( 11) 0.000000 -1600.000
X( 12) 0.000000 -1700.000
X( 13) 0.000000 -1800.000
X( 14) 0.000000 -1200.000
X( 15) 0.000000 -1600.000
X( 16) 0.000000 -800.0000
X( 17) 0.000000 -800.0000
X( 18) 0.000000 -600.0000
X( 19) 0.000000 -1400.000
X( 20) 0.000000 -1200.000
X( 21) 0.000000 -1000.000
X( 22) 0.000000 -800.0000
X( 23) 0.000000 -600.0000
X( 24) 0.000000 -400.0000
X( 25) 0.000000 -2800.000
X( 26) 0.000000 -3200.000
X( 27) 0.000000 -1700.000
X( 28) 0.000000 -500.0000
X( 29) 0.000000 -700.0000
X( 30) 0.000000 -900.0000
X( 31) 0.000000 -1100.000
X( 32) 0.000000 -1300.000
X( 33) 0.000000 -1500.000
X( 34) 0.000000 -1700.000
X( 35) 0.000000 -1900.000
X( 36) 0.000000 -2100.000
X( 37) 0.000000 -2300.000
X( 38) 1.000000 -2500.000
X( 39) 0.000000 -1300.000
X( 40) 0.000000 -1500.000
X( 41) 0.000000 -1700.000
X( 42) 0.000000 -1900.000
X( 43) 0.000000 -2100.000
X( 44) 0.000000 -2300.000
X( 45) 0.000000 -2500.000
X( 46) 0.000000 -2700.000
X( 47) 0.000000 -2900.000
X( 48) 0.000000 -3100.000
X( 49) 1.000000 -3300.000
X( 50) 1.000000 -3500.000
X( 51) 1.000000 -3200.000
X( 52) 1.000000 -1500.000
X( 53) 0.000000 -1400.000
X( 54) 0.000000 -1300.000
X( 55) 0.000000 -1200.000
X( 56) 0.000000 -1100.000
X( 57) 0.000000 -1000.000
X( 58) 0.000000 -900.0000
X( 59) 0.000000 -800.0000
X( 60) 0.000000 -700.0000
Row Slack or Surplus Dual Price
1 14000.00 1.000000
2 0.000000 0.000000
3 20.00000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
使用集合的意义
- 现实优化问题往往规模比较大,具体变量多,约束条件很多
- lingo中引入集合,大大简化了大规模优化问题的模型表述,也提高了lingo自身表述模型的能力,使得lingo在众多数学优化软件脱颖而出。
- 原始集合是比较简单地集合,也是集合的基础
总结
本小节主要讲了lingo定义原始集合及其属性的语法规则,还有在数据段给常量赋值的多种形式、还有五个集合遍历函数及在集合遍历函数中使用条件筛选集合元素其简化形式、纯粹的语法问题,虽然简单但仍需要认真掌握。