急求解!请大神帮帮我!
本帖最后由 wujianjack2 于 2014-6-27 13:25 编辑以下程序是在Lingo11下运行,Integer Solver中这个选项的值调到如1e-010,结果集中
M( 8) 0.000000
但
PS( 8) 1.000000
而约束中已经限制 @for(VIP(i)|pFlag(i)#EQ#2: ps(i)=@if(m(i)#gt#0,1,0));
我想可能是精度的问题,改了一下@for(VIP(i)|pFlag(i)#EQ#2: ps(i)=@if(@floor(m(i))#gt#0,1,0));
这下没有可行解了,但如果加上m(3)>1,却得到了正确的一组可行解
为什么呢?既然在多加了约束的条件下能得到一组可行解,为什么去掉了这个约束却没有可行解了呢?
其他的约束我测了在m给定值的前提下是没有问题的,当将m的初始值去掉,希望由下面这几个约束来给出m的值时,计算出的m值不是期望值,
@for(VIP(i)|pFlag(i)#EQ#2: ps(i)=@if(m(i)#gt#0,1,0));
@sum(VIP(i)|pFlag(i)#EQ#2: ps(i))>1;
@for(VIP(i): m(i)>=0);
@for(VIT(i):fvec(i)>=0);
@for(VIP(i):m(i)= m0(i)+@sum(VIT(j):mvalue(i,j)*fvec(j)));;
其中影响m取值的最重要因素是如下两个约束:
@for(VIP(i)|pFlag(i)#EQ#2: ps(i)=@if(m(i)#gt#0,1,0));
@sum(VIP(i)|pFlag(i)#EQ#2: ps(i))>1;
我想表达的在是在pFlag(i)等于2的前提下,m(i)中只要有一个值是大于1,这组m的值就被采用,其中m是一个严格的整数,我的写法有问题吗?
model:
sets:
!place m0 - initial marking;
!pFlag: 0==idle place, 1==resource, 2==working place;
!bnd - the place's boundness, m - reachable marking;
VIP:m0,pFlag,bnd,m,ps;
!transition itFlag: 1==initial transition, 0 == others;
!fvec - the firing vector of transitions;
VIT:itFlag, fvec;
!the arc from place to transition;
Pre(VIP,VIT):wpt;
!the arc from transition to place;
Post(VIT,VIP):wtp;
!incidence matirx;
Matrix(VIP,VIT):mvalue;
BadMarkedSiphon(VIP):vp;
EnabledTrans(VIT):et;
EnabledResourse(VIP,VIT): ert;
endsets
data:
m0 = 100 0 0 0 2 2 0 0 100;
pFlag = 0 2 2 2 1 1 2 2 0;
bnd = 100 100 100 100 100 100 100 100 100;
itFlag = 1 0 0 0 1 0 0;
wpt = 1 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 1 0 0 0
1 0 0 0 0 2 0
0 1 1 0 1 0 0
0 0 0 0 0 0 1
0 0 0 0 0 1 0
0 0 0 0 1 0 0;
wtp = 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0
1 0 0 0 0 2 0 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 1 1 0 0
0 0 0 0 2 0 0 0 1;
mvalue = -1 0 0 1 0 0 0
1 -1 0 0 0 0 0
0 1 -1 0 0 0 0
0 0 1 -1 0 0 0
-1 0 1 0 0 -2 2
0 -1 -1 2 -1 1 0
0 0 0 0 0 1 -1
0 0 0 0 1 -1 0
0 0 0 0 -1 0 1;
enddata
max = @sum(BadMarkedSiphon(i)|pFlag(i)#NE#0:vp(i));
!constrants (1);
@for(VIP(i):
@for(VIT(j)| pFlag(i)#NE#0 #AND# wtp(j,i)#NE#0 : vp(i) >= @sum(VIP(z):@if(wpt(z,j)#NE#0,1,0)*vp(z))-
@sum(VIP(z):@if(wpt(z,j)#NE#0,1,0))+1);
);
!constrants (2);
@sum(VIP(i)|pFlag(i)#NE#0 : vp(i)) < @sum(VIP(i) : @if(pFlag(i)#NE#0,1,0))-0.00001;
!constrants (3);
@for(VIT(i) :
@for(VIP(j) | itFlag(i)#NE#1 #AND# wpt(j,i)#NE#0 #AND# pFlag(j)#EQ#2 : m(j) >= et(i));
);
!constrants (4);
@for(VIT(i) :
@for(VIP(j) | itFlag(i)#NE#1 #AND# wpt(j,i)#NE#0 #AND# pFlag(j)#EQ#2 : et(i) >= m(j)/bnd(j));
);
!constrants (5);
@for(VIP(i) :
@for(VIT(j) | pFlag(i)#EQ#1 #AND# itFlag(j)#NE#1 #AND# wpt(i,j)#NE#0: (m(i)/wpt(i,j)+vp(i)) >= ert(i,j));
);
!constrants (6);
@for(VIP(i) :
@for(VIT(j) | pFlag(i)#EQ#1 #AND# itFlag(j)#NE#1 #AND# wpt(i,j)#NE#0: ert(i,j) >= (m(i)-wpt(i,j)+1)/(m0(i)-wpt(i,j)+1));
);
!constrants (7);
@for(VIP(i) :
@for(VIT(j) | pFlag(i)#EQ#1 #AND# itFlag(j)#NE#1 #AND# wpt(i,j)#NE#0: ert(i,j) >= vp(i));
);
!constrants (8);
@for(VIT(i) | itFlag(i)#NE#1: @sum(EnabledResourse(j,i)| pFlag(j)#EQ#1 #AND# wpt(j,i)#NE#0: ert(j,i))+0.00001 < @sum(VIP(z)| pFlag(z)#EQ#1: @if(wpt(z,i)#NE#0,1,0))+1-et(i) );
!constrants (9);
@for(VIP(i) | pFlag(i)#NE#0 : @bin(vp(i)));
!constrants (10);
@for(VIT(i) | itFlag(i)#NE#1 : @bin(et(i)));
!constrants (11);
@for(VIP(i) :
@for(VIT(j)| pFlag(i)#EQ#1 #AND# itFlag(j)#NE#1 #AND# wpt(i,j)#NE#0 :@bin(ert(i,j)));
);
!constrants (12);
!m(3)>1;
@for(VIP(i)|pFlag(i)#EQ#2: ps(i)=@if(m(i)#gt#0,1,0));
@sum(VIP(i)|pFlag(i)#EQ#2: ps(i))>1;
@for(VIP(i): m(i)>=0);
@for(VIT(i):fvec(i)>=0);
@for(VIP(i):m(i)= m0(i)+@sum(VIT(j):mvalue(i,j)*fvec(j)));
@for(VIP(i):@gin(m(i)));
@for(VIT(i):@gin(fvec(i)));@for(VIP(i)|pFlag(i)#EQ#2: @bin(ps(i)););
end 我用最新的LINDO API 8.0.1694.551给你计算了下,发现Default Local Nonlinear Solver报错说局部不可行,Debug说你这里面有数值不稳定性。
用Global Solver在默认设置下,线程数为2,居然有全局最优,而且速度还很快...........
Solution Report:
Global optimal solution found.
Objective value: 6.00000000000
Objective bound: 6.00000000000
Infeasibilities: 0.00000000000
Extended solver steps: 0
Total solver iterations: 11
Elapsed runtime seconds: 0.13
Variable Value
M( 1) 100.000000000
M( 5) 2.00000000000
M( 6) 2.00000000000
M( 9) 100.000000000
PS( 1) 1.23456788063
PS( 4) 1.00000000000
PS( 5) 1.23456788063
PS( 6) 1.23456788063
PS( 7) 1.00000000000
PS( 9) 1.23456788063
本帖最后由 wujianjack2 于 2014-6-29 13:58 编辑
我之前给你建议在LINGO 11中将Absolute Integrality Tolerance调到1e-10只是为了显示数据时的一个建议,你这个MINLP问题程序还是太长了,我也没有时间给你仔细看。
不排除是LINGO软件计算有问题,或者你的模型中有表达不太贴切之处。
LINGO求解MINLP以CONOPT和Branch and Bound为Subroutine,CONOPT的应用有自己的一些要求与限制的。
我现在觉得,还是尽量先从优化模型本身着手。如果LINGO求解效果不太好的话,对于MINLP问题,可以尝试Ziena Knitro和BARON。
页:
[1]