lingo 0-1规划代码求不出最优解,是为什么啊?是不是代码哪里出问题了?下面是代码谢谢! 5
求17个景点的旅游方案,每个景点有最佳旅游时间和费用,景点和景点之间有路途时间和费用,总的旅游时间有约束,不管怎么说肯定是有一个最短路径才对啊,不知道哪里出问题了,用了g...
求17个景点的旅游方案,每个景点有最佳旅游时间和费用,景点和景点之间有路途时间和费用,总的旅游时间有约束,不管怎么说肯定是有一个最短路径才对啊,不知道哪里出问题了,用了global solver之后能算出来答案但是明显就不对.....求大神看一下!!!
model:
sets:
m/1..17/;
n/1..17/:stay,p;
link(m,n):d,t,x;
endsets
data:
!(stay,p,d,t都是有数据的只有x是变量)
enddata
[obj]min=@sum(link(i,j):d(i,j)*0.4)+@sum(link(i,j):x(i,j)*p(j)*stay(j));
@for(link(i,j):@sum(link(i,j):x(i,j)*stay(j)+x(i,j)*t(i,j))<=31*12;);
@for(m(i):@sum(n(j):x(i,j))<=1;);
@for(n(j):@sum(m(i):x(i,j))<=1;);
@for(m(i):@sum(n(j):x(1,j))=1;);
@for(n(j):@sum(m(i):x(i,1))=1;);
@for(link(i,j):x(i,j)*x(j,i)=0;);
@for(link(i,j):@bin(x(i,j));x(i,j)>=0;);
end 展开
model:
sets:
m/1..17/;
n/1..17/:stay,p;
link(m,n):d,t,x;
endsets
data:
!(stay,p,d,t都是有数据的只有x是变量)
enddata
[obj]min=@sum(link(i,j):d(i,j)*0.4)+@sum(link(i,j):x(i,j)*p(j)*stay(j));
@for(link(i,j):@sum(link(i,j):x(i,j)*stay(j)+x(i,j)*t(i,j))<=31*12;);
@for(m(i):@sum(n(j):x(i,j))<=1;);
@for(n(j):@sum(m(i):x(i,j))<=1;);
@for(m(i):@sum(n(j):x(1,j))=1;);
@for(n(j):@sum(m(i):x(i,1))=1;);
@for(link(i,j):x(i,j)*x(j,i)=0;);
@for(link(i,j):@bin(x(i,j));x(i,j)>=0;);
end 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询