《运筹学实验报告》论文Word文档下载推荐.docx
《《运筹学实验报告》论文Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《《运筹学实验报告》论文Word文档下载推荐.docx(23页珍藏版)》请在冰豆网上搜索。
10%。
三、实验内容
1、线性规划
例运筹学74页14题
Minz=-2x1-x2
s.t.2x1+5x2≤60
x1+x2≤18
3x1+x2≤44
X2≤10
X1,x2≥0
用matlab运行后得到以下结果:
theprogramiswiththelinearprogramming
Pleaseinputtheconstraintsnumberofthelinearprogrammingm=6
m=
6
Pleaseinputthevariantnumberofthelinearprogrammingn=2
n=
2
Pleaseinputcostarrayoftheobjectivefunctionc(n)_T=[-2,-1]'
c=
-2
-1
PleaseinputthecoefficientmatrixoftheconstraintsA(m,n)=[2,5;
1,1;
3,1;
0,1;
-1,0;
0,-1]
A=
25
11
31
01
-10
0-1
Pleaseinputtheresourcearrayoftheprogramb(m)_T=[60,18,44,10,0,0]'
b=
60
18
44
10
0
Optimizationterminated.
Theoptimizationsolutionoftheprogrammingis:
x=
13.0000
5.0000
Theoptimizationvalueoftheprogrammingis:
opt_value=
-31.0000
LINDO程序
在命令窗口键入以下内容:
max-2x-y
subjectto
2x+5y<
=60
x+y<
=18
3x+y<
=44
y<
=10
end
按solve键在reportswindow出现:
Globaloptimalsolutionfound.
Objectivevalue:
0.000000
Totalsolveriterations:
VariableValueReducedCost
X0.0000002.000000
Y0.0000001.000000
RowSlackorSurplusDualPrice
10.0000001.000000
260.000000.000000
318.000000.000000
444.000000.000000
510.000000.000000
2、整数规划
课本第二章79页1题
Maxz=100x1+180x2+70x3
s.t.40x1+50x2+60x3≤10000
3x1+6x2+2x3≤600
x1≤130
X2≤80
x3≤200
x1x2x3≥0
程序运行及结果:
biprogram
the
program
is
with
binary
linear
programming
Please
input
constraints
number
of
programming
m=5
m
=
5
variant
n=5
n
cost
array
objective
function
c(n)_T=[100,180,70]'
c
100
180
70
coefficient
matrix
A(m,n)=[40,50,60;
3,6,2;
1,0,0;
0,1,0;
0,0,1]
A
40
50
60
3
6
2
1
0
1
resource
b(m)_T=[10000;
600;
130;
80;
200]
b
10000
600
130
80
200
Optimization
terminated.
The
optimization
solution
is:
x
value
opt_value
程序名:
intprogramb程序说明:
%
programm
integer
use
branch
and
bound
method!
%这个程序是用分支定界法解决整数规划问题
please
parameters
in
main
command
winows
%请在命令窗口输入这个主要定义函数的参数
[x,f]=ILp(c,A,b,vlb,vub,x0,neqcstr,pre)
min
f=c'
*x,s.t.
A*x<
=b,vlb<
=x<
=vub
f的最小值等于c的转置乘以x,A乘以x小于等于b,x大于等于vlb小于等于vub
vectors
required
as
integers
whole
x是整个的整数需要
x0
initialization,'
[]'
also
ok
x0是初始值,"
[]"
也可以是。
neqcstr
equational
constraints,when
can
be
delete
neqcstr是平均约束条件的数目,当0能删除时
pre
concise
rate
pre是简明率
f
optimal
value
x是整数规划,f
是最优值
%%%%%%%%%%%%%%%%
if
nargin<
8,pre=0;
nargin
factually
variants
(这个参数是实际输入的变量个数)
7,neqcstr=0;
6,x0=[];
5,vub=[];
4,vlb=[];
%%%%%%%%%%%%%%%%%%
set
to
column
vectors
%建立列向量
x0=x0(:
);
c=c(:
b=b(:
vlb=vlb(:
vub=vub(:
mm=1;
j=1;
nvars=length(c'
variants(变量的个数)
fvub=inf;
xall=[];
fall=[];
x_f_b=[];
[xtemp,ztemp,how]=lp(c,A,b,vlb,vub,x0,neqcstr,-1);
ftemp=c'
*xtemp;
%%%%%%%%%%%%%%%%%%%%%%%
strcmp(how,'
ok'
)
compare
between
how
ok(how和ok之间的比较)
temp0=round(xtemp);
%临时变量四舍五入
temp1=floor(xtemp);
%取比其小的整数
temp2=find(abs(xtemp-temp0)>
pre);
mtemp=length(temp2);
~isempty(temp2)
x_f_b=[xtemp;
ftemp;
vlb;
vub];
while
j<
=mm
i=1;
i<
=mtemp
%%%%%%%%%%%%%%%%%%%%%
x_f_b(nvars+1,j)<
=fvub
vlbl=x_f_b(nvars+2:
2*nvars+1,j);
vubl=x_f_b(2*nvars+2:
3*nvars+1,j);
vubl(temp2(i))=temp1(temp2(i));
[xtemp,z,how]=lp(c,[A;
c'
],[b;
fvub],vlbl,vubl,x0,neqcstr,-1);
)
templ0=round(xtemp);
templ1=floor(xtemp);
templ2=find(abs(xtemp-templ0)>
isempty(templ2)
xall=[xall,xtemp];
fall=[fall,ftemp];
fvub=min([fvub,fall]);
elseif
ftemp<
x_f_b=[x_f_b,[xtemp;
vlbl;
vubl]];