LINGO分段函数怎么求!
sets:position/1..7/:x,f;society/1..15/:r,Y;endsetsdata:r=21436948121011614936;f=96.52...
sets:
position/1..7/:x,f;
society/1..15/:r,Y;
endsets
data:
r=2 14 3 6 9 4 8 12 10 11 6 14 9 3 6;
f=9 6.5 20 14.5 19 13 10.5;
enddata
max=@sum(society(i):y(i));
Y(1)=@if(x(1)#eq#1,0.7*r(1),0);
Y(2)=@if((x(1)+x(2))#le#0,0,@if((x(1)+x(2))#gt#1),r(2),0.7*r(2));
!这里设置成的分段函数哪里错了,求大神指点,下面的程序都是一样的,这边改了,后面也就一样了;
Y(3)=@if(x(2)#eq#1,0.7*r(3),@if(x(2)#eq#0),0);
Y(4)=@if(x(1)+x(3)#eq#1,0.7*r(4),@if(x(1)+x(3)#eq#0),0,@if(x(1)+x(3)#eq#2,r(4)));
Y(5)=@if(x(2)+x(4)#eq#1,0.7*r(5),@if(x(2)+x(4)#eq#0),0,@if(x(2)+x(4)#eq#2,r(5)));
Y(6)=@if(x(4)#eq#1,0.7*r(6),@if(x(4)#eq#0),0);
Y(7)=@if(x(3)+x(6)#eq#1,0.7*r(7),@if(x(3)+x(6)#eq#0),0,@if(x(3)+x(6)#eq#2,r(7)));
Y(8)=@if(x(3)+x(4)+x(5)#eq#1,0.7*r(8),@if(x(3)+x(5)+x(4)#eq#0),0,@if(x(3)+x(5)+x(4)#ge#2,r(8)));
Y(9)=@if(x(4)+x(5)#eq#1,0.7*r(9),@if(x(4)+x(5)#eq#0),0,@if(x(4)+x(5)#eq#2,r(9)));
Y(10)=@if(x(3)+x(5)#eq#1,0.7*r(10),@if(x(3)+x(5)#eq#0),0,@if(x(3)+x(5)#eq#2,r(10)));
Y(11)=@if(x(6)#eq#1,0.7*r(11),@if(x(6)#eq#0),0);
Y(12)=@if(x(6)+x(7)#eq#1,0.7*r(12),@if(x(6)+x(7)#eq#0),0,@if(x(6)+x(7)#eq#2,r(12)));
Y(13)=@if(x(7)#eq#1,0.7*r(13),@if(x(7)#eq#0),0);
Y(14)=@if(x(7)#eq#1,0.7*r(14),@if(x(7)#eq#0),0);
Y(15)=@if(x(6)+x(7)#eq#1,0.7*r(15),@if(x(6)+x(7)#eq#0),0,@if(x(6)+x(7)#eq#2,r(15)));
@for(position(i):@bin(x));
@sum(position(i):x(i)*f(i))<=50;
输入结果如下 展开
position/1..7/:x,f;
society/1..15/:r,Y;
endsets
data:
r=2 14 3 6 9 4 8 12 10 11 6 14 9 3 6;
f=9 6.5 20 14.5 19 13 10.5;
enddata
max=@sum(society(i):y(i));
Y(1)=@if(x(1)#eq#1,0.7*r(1),0);
Y(2)=@if((x(1)+x(2))#le#0,0,@if((x(1)+x(2))#gt#1),r(2),0.7*r(2));
!这里设置成的分段函数哪里错了,求大神指点,下面的程序都是一样的,这边改了,后面也就一样了;
Y(3)=@if(x(2)#eq#1,0.7*r(3),@if(x(2)#eq#0),0);
Y(4)=@if(x(1)+x(3)#eq#1,0.7*r(4),@if(x(1)+x(3)#eq#0),0,@if(x(1)+x(3)#eq#2,r(4)));
Y(5)=@if(x(2)+x(4)#eq#1,0.7*r(5),@if(x(2)+x(4)#eq#0),0,@if(x(2)+x(4)#eq#2,r(5)));
Y(6)=@if(x(4)#eq#1,0.7*r(6),@if(x(4)#eq#0),0);
Y(7)=@if(x(3)+x(6)#eq#1,0.7*r(7),@if(x(3)+x(6)#eq#0),0,@if(x(3)+x(6)#eq#2,r(7)));
Y(8)=@if(x(3)+x(4)+x(5)#eq#1,0.7*r(8),@if(x(3)+x(5)+x(4)#eq#0),0,@if(x(3)+x(5)+x(4)#ge#2,r(8)));
Y(9)=@if(x(4)+x(5)#eq#1,0.7*r(9),@if(x(4)+x(5)#eq#0),0,@if(x(4)+x(5)#eq#2,r(9)));
Y(10)=@if(x(3)+x(5)#eq#1,0.7*r(10),@if(x(3)+x(5)#eq#0),0,@if(x(3)+x(5)#eq#2,r(10)));
Y(11)=@if(x(6)#eq#1,0.7*r(11),@if(x(6)#eq#0),0);
Y(12)=@if(x(6)+x(7)#eq#1,0.7*r(12),@if(x(6)+x(7)#eq#0),0,@if(x(6)+x(7)#eq#2,r(12)));
Y(13)=@if(x(7)#eq#1,0.7*r(13),@if(x(7)#eq#0),0);
Y(14)=@if(x(7)#eq#1,0.7*r(14),@if(x(7)#eq#0),0);
Y(15)=@if(x(6)+x(7)#eq#1,0.7*r(15),@if(x(6)+x(7)#eq#0),0,@if(x(6)+x(7)#eq#2,r(15)));
@for(position(i):@bin(x));
@sum(position(i):x(i)*f(i))<=50;
输入结果如下 展开
展开全部
去掉指的那个右括号就行了
更多追问追答
追问
大神又是你!真是谢谢了。改了还是不行啊,能帮完整的写一句吗?其实就是x1+x2=0时,y(2)=0;x1+x2=2时,y(2)=r(2);x1+x2=1时,y2=0.7*r(2)。
追答
Y(2)=@if((x(1)+x(2))#le#0,0,@if((x(1)+x(2))#gt#1,r(2),0.7*r(2)));
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询