LINGO练习题-1及答案LINGO测试-1
1、用LINGO软件解方程组(1)221212222359 x x x x?+=??-=-??。
model:
x^2+2*y^2=22;
3*x-5*y=-9;
end
Solution is locally infeasible Infeasibilities:0.5417411E-04
Extended solver steps:5
Total solver iterations:20
Variable Value
X 2.000005
Y 3.000003
Row Slack or Surplus
1-0.5417411E-04
20.000000
2、用LINGO软件解线性规划问题
model:
max=2*x+3*y;
4*x+3*y<=10;
3*x+5*y<=12;
x>0;y>0;
end
Global optimal solution found.
Objective value:7.454545
Infeasibilities:0.000000
Total solver iterations:2
Variable Value Reduced Cost
X 1.2727270.000000
Y 1.6363640.000000
Row Slack or Surplus Dual Price
max23,..4310,3512,,0.z x y s t x y x y x y=++≤+≤≥17.454545 1.000000
20.0000000.9090909E-01
30.0000000.5454545
4 1.2727270.000000
5 1.6363640.000000
3、用LINGO软件二次规划问题
(1)min2212z=x-3-2x+()()
22121212..-50,
24,
,0s t
x x x x x x+≤+≤≥。
model:
min=(x1-3)^2+(x2-2)^2;
x1^2+x2^2-5<=0;
x1+2*x2<=4;
x1>=0;
x2>=0;
end
Local optimal solution found. Objective value: 2.000000 Infeasibilities:0.5384996E-06 Extended solver steps:5
Total solver iterations:64 Variable Value Reduced Cost
X1 2.0000000.000000
X20.99999990.000000
Row Slack or Surplus Dual Price 1 2.000000-1.000000
2-0.5384996E-060.3333331
30.0000000.6666670
4 2.0000000.000000
50.99999990.000000
(2)
model:22221212334412132344
max23x x x2x x5x,..25,
12,
,{0,1},2,0.z x x s t x x x x x x x x=-+-++-≤≤≤∈Z∈≥>
max=x1^2-2*x2^2+3*x1*x2-x3^2+2*x3*x4+5*x4^2;
x1-2*x2<=5;
1<=x1;
x1<=2;
x3/x4>=2;
x4>0;
@gin(x2);
@bin(x3);
end
Linearization components added:
Constraints:4
Variables:1
Local optimal solution found.
Objective value:9.250000
Objective bound:9.250000
Infeasibilities:0.000000
Extended solver steps:2
Total solver iterations:39
Variable Value Reduced Cost X1 2.0000000.000000X2 1.000000-1.999996X3 1.000000199997.5X40.5000000 0.000000
Row Slack or Surplus Dual Price
19.250000 1.000000
2 5.0000000.000000
3 1.0000000.000000
40.0000007.000003
50.000000-1.749997
60.50000000.000000
4、用LINGO软件分别产生序列
(1){1,3,5,7,9,11};
model:
sets:
set1/1..6/:x;
endsets
@for(set1(i):x(i)=2*i-1);
end
Feasible solution found.
Total solver iterations:0
Variable Value
X(1) 1.000000
X(2) 3.000000
X(3) 5.000000
X(4)7.000000
X(5)9.000000
X(6)11.00000
Row Slack or Surplus
10.000000
20.000000
30.000000
40.000000
50.000000
60.000000
(2)
1111{1,,,,}6122030
model:
sets:
set2/1..5/:x;
endsets
@for(set2(i):x(i)=1/(i*(i+1))); end
Feasible solution found.
Total solver iterations:0
Variable Value
X(1)0.5000000
X(2)0.1666667
X(3)0.8333333E-01X(4)0.5000000E-01X(5) 0.3333333E-01
Row Slack or Surplus
10.000000
20.000000
30.000000
40.000000
50.000000
5、已知向量c={1,3,0.5,7,5,2},用LINGO软件解答下列问题。
(1)求向量c前5个数中的最大值;(2)求向量c后4个数平方中的最小值;(3)求向量c中所有数的和。
model:
data:
N=7;
enddata
sets:
number/1..N/:x;
endsets
data:
x=1305752;
enddata
maxv=@max(number(I)|I#le#5:x);
minv=(@min(number(I)|I#ge#N-3:x))^2; sumv=@sum(number(I)|I#ge#1:x);
end
Feasible solution found.
Total solver iterations:0
Variable Value
N7.000000
MAXV7.000000
MINV 4.000000
SUMV23.00000
X(1) 1.000000
X(2) 3.000000
X(3)0.000000
X(4) 5.000000
X(5)7.000000
X(6) 5.000000
X(7) 2.000000
Row Slack or Surplus 10.000000
20.000000
30.000000。