数学建模社区-数学中国
标题:
之前的初始数据可行解正确,换了个就没有可行解,求大神帮忙,急
[打印本页]
作者:
aliwanghl
时间:
2014-6-27 12:39
标题:
之前的初始数据可行解正确,换了个就没有可行解,求大神帮忙,急
本帖最后由 wujianjack2 于 2014-6-28 10:22 编辑
测试出来,第五行约束为@for(VIT(i): fvec(i)<=1023);时可行解正确,可改为@for(VIT(i): fvec(i)<=1024);就没有可行解了,调试信息我也看不明白。本来约束条件里应该是没有这行约束的,如果去掉程序一直运行。
但在以前的初始数据下是正确解。请大神帮忙分析下,看到底是哪里的问题:
data:
m0 = 100 0 0 0 2 2 0 0 100;
pFlag = 0 2 2 2 1 1 2 2 0;
bnd = 100 20 1 1 2 2 1 2 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
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 = 5 0 0 0 0 5 0 0 0 2 2 2;
pFlag = 0 2 2 2 2 0 2 2 2 1 1 1 ;
bnd = 5 5 5 5 5 5 5 5 5 5 5 5 ;
itFlag = 1 0 0 0 0 0 1 0 0 0 ;
wpt = 1 0 0 0 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1 0
2 0 0 0 0 0 0 1 0 0
0 0 1 0 1 0 1 0 0 0 ;
wtp = 0 1 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1 1 0
0 0 0 0 1 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1 0 0
0 0 0 0 1 0 0 0 0 0 2 0
1 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 0 0 0 1 0 1 0
0 0 0 0 0 1 0 0 0 1 0 0 ;
mvalue = -1 0 0 0 0 1 0 0 0 0
1 -1 0 -1 0 0 0 0 0 0
0 1 -1 0 0 0 0 0 0 0
0 0 0 1 -1 0 0 0 0 0
0 0 1 0 1 -1 0 0 0 0
0 0 0 0 0 0 -1 0 0 1
0 0 0 0 0 0 1 -1 0 0
0 0 0 0 0 0 0 1 -1 0
0 0 0 0 0 0 0 0 1 -1
-1 1 0 1 0 0 0 0 -1 1
-2 1 1 0 2 0 0 -1 1 0
0 0 -1 0 -1 1 -1 1 0 0 ;
@text(Minimize_Bad_Siphon.dat)= @write('the place whose value is 0 is included in a bad siphon ');
@text(Minimize_Bad_Siphon.dat)= @writefor(VIP(i)|pFlag#NE#0:@newline(1),'p',VIP(i),'=',vp(i));
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);
@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(VIT(i): fvec(i)<=1024);
@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
作者:
wujianjack2
时间:
2014-6-28 10:33
你的问题,LINDO 14与LINGO 11求解出来的全局解不一样。
原始数据的解:
Global optimal solution found.
Objective value: 9.00000000000
Objective bound: 9.00000000000
Infeasibilities: 0.00000000000
Extended solver steps: 0
Total solver iterations: 9
Elapsed runtime seconds: 0.17
Variable Value
M( 1) 5.00000000000
M( 6) 5.00000000000
M( 10) 2.00000000000
M( 11) 2.00000000000
M( 12) 2.00000000000
PS( 1) 1.23456788063
PS( 2) 1.00000000000
PS( 5) 1.00000000000
PS( 6) 1.23456788063
PS( 9) 1.00000000000
PS( 10) 1.23456788063
PS( 11) 1.23456788063
PS( 12) 1.23456788063
FVEC( 7) 1019.00000000
FVEC( 8) 1019.00000000
FVEC( 9) 1019.00000000
FVEC( 10) 1019.00000000
修改数据后的解:
Global optimal solution found.
Objective value: 6.00000000000
Objective bound: 6.00000000000
Infeasibilities: 0.00000000000
Extended solver steps: 0
Total solver iterations: 3
Elapsed runtime seconds: 0.06
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
FVEC( 1) 1022.00000000
FVEC( 2) 1022.00000000
FVEC( 3) 1022.00000000
FVEC( 4) 1022.00000000
FVEC( 5) 1022.00000000
FVEC( 6) 1022.00000000
FVEC( 7) 1022.00000000
程序太长,逻辑判断太多,看你书写的格式估计是在做个大作业或者小项目,你很难让人花大把时间去仔细看你的程序的。
不排除软件计算有误,MINLP问题求解本身是非常困难的。首先,你应该仔细检查自己的模型,有时候或许是笔误,或者思考不周,导致浪费大量时间也是有可能的。
作者:
snowwomanPeter
时间:
2014-7-18 15:15
这个程序在我的lingo中运行的结果是一样的,估计是你的软件有问题
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/)
Powered by Discuz! X2.5