lingo编程练习题Word格式.doc
- 文档编号:13060000
- 上传时间:2022-10-04
- 格式:DOC
- 页数:35
- 大小:155.50KB
lingo编程练习题Word格式.doc
《lingo编程练习题Word格式.doc》由会员分享,可在线阅读,更多相关《lingo编程练习题Word格式.doc(35页珍藏版)》请在冰豆网上搜索。
-0.8160-1.1232i
-0.8160+1.1232i
OR:
a=[1,-2,-4,-7];
x=roots(a)
Lingo:
x^3-2*x^2-4*x-7=0;
@bnd(3,x,4);
Feasiblesolutionfound.
Infeasibilities:
0.5329071E-14
Extendedsolversteps:
5
Totalsolveriterations:
36
VariableValue
X3.631981
functiony=f(m,n)
symsxxk;
a=m;
b=n;
ff=x^3-2*x^2-4*x-7;
whileb-a>
0.00001
xk=(a+b)/2;
fx=subs(ff,x,xk);
fa=subs(ff,x,a);
iffx==0
y=xk;
break;
elseiffa*fx<
b=xk;
else
a=xk;
end
y=xk;
end
y=3.631980895996094
4、
symsx4;
x4=solve(x4^2-3*x4-4==0,x4)
x4=
4
-1
lingo
x1^2-3*x1-4=0;
x2^2-3*x2-4=0;
@free(x2);
VariableValue
X14.000000
X2-1.000000
5、
symsx1x2x3x4;
[x1,x2,x3,x4]=solve(2*x1+x2-x3+x4,3*x1-2*x2+x3-x4,x1+4*x2-3*x3+5*x4,x1,x2,x3,x4)
x1=z/7
x2=(5*z)/7
x3=z
x4=0
6、
a=[5,2,1;
-1,4,2;
2,-3,10];
b=[-12;
20;
3];
x=inv(a)*b
-4.000000000000000
3.000000000000000
2.000000000000000
二、编写lingo程序求解下列最优化问题
4*x1-x2+2*x3-x4=-2;
x1+x2-x3+2*x4<
14;
-2*x1+3*x2+x3-x4>
2;
@free(x4);
0.000000
2
X10.000000
X21.000000
X30.000000
X41.000000
3、
max=3*x1-x2;
3*x1-x2<
3;
5*x1+4*x2>
10;
2*x1+x2<
5;
@gin(x1);
@gin(x2);
Globaloptimalsolutionfound.
Objectivevalue:
1.000000
Objectivebound:
0
0
VariableValueReducedCost
X11.000000-3.000000
X22.0000001.000000
min=3*x+7*x2-x3+x4;
2*x1-x2+x3-x4>
1;
x1-x2+6*x3+4*x4>
8;
5*x1+3*x3+x4>
@bin(x1);
@bin(x2);
@bin(x3);
@bin(x4);
Globaloptimalsolutionfound.
X0.0000003.000000
X20.0000007.000000
X31.000000-1.000000
X41.0000001.000000
X11.0000000.000000
6、求图中点到各点的最短路(不可逆行).
7
4
v2
v4
v3
v1
v5
v6
v7
2
5
3
6
1
v8
model:
SETS:
points/v1,v2,v3,v4,v5,v6,v7,v8/:
L;
roads(points,points)/
v1,v2v1,v3v1,v4
v2,v3v2,v5v3,v6v4,v3
v6,v5v6,v8v7,v6v7,v4v8,v5v8,v7/:
d;
ENDSETS
DATA:
d=253
2464
342731;
L=0,,,,,,,;
ENDDATA
@FOR(points(i)|i#GT#@index(v1):
L(i)=@MIN(roads(j,i):
L(j)+d(j,i));
);
Linearizationcomponentsadded:
Constraints:
24
Variables:
14
Integers:
10
Feasiblesolutionfound.
L(V1)0.000000
L(V2)2.000000
L(V3)4.000000
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- lingo 编程 练习题
![提示](https://static.bdocx.com/images/bang_tan.gif)