intprog.m 代码
(2013-04-13 23:30:17)
标签:
intprogmatlab代码it |
function[x,fval,exitflag]=intprog(f,A,b,Aeq,beq,lb,ub,M,TolXInteger)
options=optimset('display','off');
bound=inf;
[x0,fval0]=linprog(f,A,b,Aeq,beq,lb,ub,[],options);
[x,fval,exitflag,b]=rec_BranchBound(f,A,b,Aeq,beq,lb,ub,x0,fval0,M,TolXInteger,bound);
function[xx,fval,exitflag,bb]=rec_BranchBound(f,A,b,Aeq,beq,lb,ub,x,v,M,TolXInteger,bound)
options=optimset('display','off');
[x0,fval0,exitflag0]=linprog(f,A,b,Aeq,beq,lb,ub,[],options);
if exitflag0<=0||fval0>bound
end
ind=find(abs(x0(M)-round(x0(M)))>TolXInteger);
if isempty(ind)
end
[row col]=size(ind);
br_var=M(ind(1));
br_value=x(br_var);
flag=abs(br_value-floor(br_value)-0.5);
for i=2:col
end
if isempty(A)
else
end
A1=[A;zeros(1,c)];
A1(end,br_var)=1;
b1=[b;floor(br_value)];
A2=[A;zeros(1,c)];
A2(end,br_var)=-1;
b2=[b;-ceil(br_value)];
[x1,fval1,exitflag1,bound1]=rec_BranchBound(f,A1,b1,Aeq,beq,lb,ub,x0,fval0,M,TolXInteger,bound);
exitflag=exitflag1;
if
exitflag1>0&&bound1
else
end
[x2,fval2,exitflag2,bound2]=rec_BranchBound(f,A2,b2,Aeq,beq,lb,ub,x0,fval0,M,TolXInteger,bound);
if
exitflag2>0&&bound2
end