lingo编程练习题.doc

上传人:聆听****声音 文档编号:564562 上传时间:2023-04-29 格式:DOC 页数:35 大小:155.50KB
下载 相关 举报
lingo编程练习题.doc_第1页
第1页 / 共35页
lingo编程练习题.doc_第2页
第2页 / 共35页
lingo编程练习题.doc_第3页
第3页 / 共35页
lingo编程练习题.doc_第4页
第4页 / 共35页
lingo编程练习题.doc_第5页
第5页 / 共35页
lingo编程练习题.doc_第6页
第6页 / 共35页
lingo编程练习题.doc_第7页
第7页 / 共35页
lingo编程练习题.doc_第8页
第8页 / 共35页
lingo编程练习题.doc_第9页
第9页 / 共35页
lingo编程练习题.doc_第10页
第10页 / 共35页
lingo编程练习题.doc_第11页
第11页 / 共35页
lingo编程练习题.doc_第12页
第12页 / 共35页
lingo编程练习题.doc_第13页
第13页 / 共35页
lingo编程练习题.doc_第14页
第14页 / 共35页
lingo编程练习题.doc_第15页
第15页 / 共35页
lingo编程练习题.doc_第16页
第16页 / 共35页
lingo编程练习题.doc_第17页
第17页 / 共35页
lingo编程练习题.doc_第18页
第18页 / 共35页
lingo编程练习题.doc_第19页
第19页 / 共35页
lingo编程练习题.doc_第20页
第20页 / 共35页
亲,该文档总共35页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

lingo编程练习题.doc

《lingo编程练习题.doc》由会员分享,可在线阅读,更多相关《lingo编程练习题.doc(35页珍藏版)》请在冰点文库上搜索。

lingo编程练习题.doc

....

一、编写lingo程序求解下列方程(组)

1、

symsx;

>>x=solve(x==(cos(x)+sin(x))/4)

x=

0.31518244283873590195648706093983

2、

>>symsx;

>>x=solve(x==4-2^x)

x=

4-lambertw(0,16*log

(2))/log

(2)

>>x=eval(x)

x=

1.386166980071494

3、求方程在中的根的近似值.

Matlab:

symsx;

>>y=x^3-2*x^2-4*x-7;

>>x=eval(solve(y))

x=

3.6320+0.0000i

-0.8160-1.1232i

-0.8160+1.1232i

OR:

symsx;

>>a=[1,-2,-4,-7];

>>x=roots(a)

x=

3.6320+0.0000i

-0.8160+1.1232i

-0.8160-1.1232i

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

Matlab:

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<0

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

x=

-4.000000000000000

3.000000000000000

2.000000000000000

二、编写lingo程序求解下列最优化问题

1、

4*x1-x2+2*x3-x4=-2;

x1+x2-x3+2*x4<14;

-2*x1+3*x2+x3-x4>2;

@free(x4);

Feasiblesolutionfound.

Infeasibilities:

0.000000

Totalsolveriterations:

2

VariableValue

X10.000000

X21.000000

X30.000000

X41.000000

2、

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:

1.000000

Infeasibilities:

0.000000

Extendedsolversteps:

0

Totalsolveriterations:

0

VariableValueReducedCost

X11.000000-3.000000

X22.0000001.000000

4、

5、

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>5;

@bin(x1);

@bin(x2);

@bin(x3);

@bin(x4);

Globaloptimalsolutionfound.

Objectivevalue:

0.000000

Objectivebound:

0.000000

Infeasibilities:

0.000000

Extendedsolversteps:

0

Totalsolveriterations:

0

VariableValueReducedCost

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

2

4

6

3

3

4

2

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)););

end

Linearizationcomponentsadded:

Constraints:

24

Variables:

14

Integers:

10

Feasiblesolutionfound.

Infeasibilities:

0.000000

Extendedsolversteps:

0

Totalsolveriterations:

0

VariableValue

L(V1)0.000000

L(V2)2.000000

L(V3)4.000000

L(V4)3.000000

L(V5)6.000000

L(V6)10.00000

L(V7)15.00000

L(V8)14.00000

D(V1,V2)2.000000

D(V1,V3)5.000000

D(V1,V4)3.000000

D(V2,V3)2.000000

D(V2,V5)4.000000

D(V3,V6)6.000000

D(V4,V3)4.000000

D(V6,V5)3.000000

D(V6,V8)4.000000

D(V7,V6)2.000000

D(V7,V4)7.000000

D(V8,V5)3.000000

D(V8,V7)1.000000

三、先建立问题的数学模型,再编写lingo程序求解

1、某厂每日8小时的产量不低于1800件.为了进行质量控制,计划聘请两种不同水平的检验员.一级检验员的标准为:

速度25件/小时,正确率98%,计时工资4元/小时;二级检验员的标准为:

速度15小时/件,正确率95%,计时工资3元/小时.检验员每错检一次,工厂要损失2元.为使总检验费用最省,该工厂应聘一级、二级检验员各几名?

min=8*x1*(4+0.02*25*2)+8*x2*(3+0.05*15*2);

8*x1*25+8*x2*15>=1800;

@gin(x1);

@gin(x2);

Globaloptimalsolutionfound.

Objectivevalue:

360.0000

Objectivebound:

360.0000

Infeasibilities:

0.000000

Extendedsolversteps:

0

Totalsolveriterations:

0

VariableValueReducedCost

X19.00000040.00000

X20.00000036.00000

2、某饲料场饲养动物出售,设每头动物每天至少需700克蛋白质、30克矿物质、100毫克维生素.现有5种饲料可供选用,各种饲料每公斤营养成分含量及单价如表所示:

饲料

蛋白质(g)

矿物质(g)

维生素(mg)

价格(元/kg)

1

2

3

4

5

3

2

1

6

18

1

0.5

0.2

2

0.5

0.5

1.0

0.2

2

0.8

0.2

0.7

0.4

0.3

0.8

要求确定既满足动物生长的营养需要,又使费用最省的选用饲料的方案.

model:

sets:

f/1..5/:

x,p;

e/1..3/;

s(f,e):

c;

endsets

data:

p=0.20.70.40.30.8;

c=310.5

20.51

10.20.2

622

180.50.8;

enddata

min=@sum(f(i):

p(i)*x(i));

@sum(f(i):

c(i,1)*x(i))>700;

@sum(f(i):

c(i,2)*x(i))>30;

@sum(f(i):

c(i,3)*x(i))>100;

Globaloptimalsolutionfound.

Objectivevalue:

32.43590

Infeasibilities:

0.000000

Totalsolveriterations:

2

VariableValueReducedCost

X

(1)0.0000000.5961538E-01

X

(2)0.0000000.5935897

X(3)0.0000000.3525641

X(4)39.743590.000000

X(5)25.641030.000000

P

(1)0.20000000.000000

P

(2)0.70000000.000000

P(3)0.40000000.000000

P(4)0.30000000.000000

P(5)0.80000000.000000

3、某医院护士值班班次、每班工作时间及各班所需护士数如表所示.每班护士值班开始时向病房报到,并连续工作8小时.试决定该医院最少需要多少名护士,以满足轮班需要.

班次

工作时间

所需护士数

1

2

3

4

5

6

6:

00~10:

00

10:

00~14:

00

14:

00~18:

00

18:

00~22:

00

22:

00~2:

00

2:

00~6:

00

60

70

60

50

20

30

min=x1+x2+x3+x4+x5+x6;

x1+x6>=60;

x2+x1>=70;

x2+x3>=60;

x3+x4>=50;

x5+x4>=20;

x5+x6>=30;

@gin(x1);

@gin(x2);

@gin(x3);

@gin(x4);

@gin(x5);

@gin(x6);

Globaloptimalsolutionfound.

Objectivevalue:

150.0000

Objectivebound:

150.0000

Infeasibilities:

0.000000

Extendedsolversteps:

0

Totalsolveriterations:

4

VariableValueReducedCost

X160.000001.000000

X210.000001.000000

X350.000001.000000

X40.0000001.000000

X530.000001.000000

X60.0000001.000000

4、一艘货轮分前、中、后三个舱位,它们的容积与最大允许载重量如表1所示.现有三种货物待运,已知有关数据列于表2.为了航运安全,前、中、后舱的实际载重量上大体保持各舱最大允许载重量的比例关系.具体要求:

前、后舱分别与中舱之间载重量比例上偏差不超过15%,前后舱之间不超过10%.问该货轮应装载A,B,C各多少件运费收入才最大?

表1

前舱

中舱

后舱

最大允许载重量(t)

容积(m3)

2000

4000

3000

5400

1500

1500

表2

商品

数量(件)

每件体积(m3/件)

每件重量(t/件)

运价(元/件)

A

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2