lingo求排错

model:
sets:
charge/1..13/:chance, star;
person/1..18/;
assign(person,charge):cost,x;
endsets
@for(person(j):@sum(charge(i):x(j,i))>=1);
!正副主任至多参加三场会议;
@for(person(j)|j#GE#1#AND#j#LE#2:@sum(charge(i):x(j,i))<=3);
!学校参会最低要求;
@for(charge(i)|i#EQ#1:@sum(person(j):x(j,i))>=3);
@for(charge(i)|i#EQ#1:@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))>=2);
@for(charge(i)|i#EQ#2:@sum(person(j):x(j,i))>=3);
@for(charge(i)|i#EQ#2:@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))>=1);
@for(charge(i)|i#EQ#3:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#3:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#4:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#4:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#5:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#5:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#6:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#6:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#7:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#7:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#8:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#8:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#9:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#9:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#10:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#10:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#11:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#11:@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))>=1);
@for(charge(i)|i#EQ#12:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#12:@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))>=1);
@for(charge(i)|i#EQ#13:@sum(person(j):x(j,i))>=2);
@for(charge(i)|i#EQ#13:@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))>=1);
!每位老师不得参加时间冲突的两场会议;
@for(person(j):(x(j,1)+x(j,2)+x(j,6))<=1);
@for(person(j):(x(j,2)+x(j,3)+x(j,4)+x(j,6))<=1);
@for(person(j):(x(j,7)+x(j,8)+x(j,9))<=1);
@for(person(j):(x(j,9)+x(j,10))<=1);
@for(person(j):(x(j,10)+x(j,11)+x(j,12)+x(j,13))<=1);
!两位教授或副教授参会,其余参会人员只能是讲师;
@for(charge(i):@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))<=2);
@for(charge(i):@sum(person(j)|j#GE#1#AND#j#LE#13:x(j,i))<=2);

!特殊情况;
Q1=@sum(person(j):x(j,1)*x(j,3)*614.1);
Q2=@sum(person(j):x(j,1)*x(j,4)*142.7);
Q3=@sum(person(j):x(j,3)*x(j,5)*602.9);
Q4=@sum(person(j):x(j,4)*x(j,5)*2319.5);
Q5=@sum(person(j):x(j,9)*x(j,11)*446.1);
Q6=@sum(person(j):x(j,9)*x(j,13)*306.6);
Q7=@sum(person(j):x(j,4)*x(j,6)*125);
!所需经费不超过50000;
@sum(assign(j,i):x(j,i)*cost(j,i))-Q1-Q2+Q3-Q4+Q5+Q6-Q7<=50000;
!确定概率;
@for(charge(i):chance(i)=@if(@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))#GE#2,0.75,@if(@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i)#EQ#1#AND#@sum(person(j)|j#GE#6#AND#j#LE#13:x(j,i))#GE#1,0.5,@if((@sum(person(j)|j#GE#1#AND#j#LE#5:x(j,i))#EQ#1#AND#@sum(person(j)|j#GE#6#AND#j#LE#13:x(j,i))#EQ#0)#OR#@sum(person(j)|j#GE#6#AND#j#LE#13:x(j,i))#GE#2,0.35,@if(@sum(person(j):x(j,i))#LE#1,0,0.1))))));
max=@sum(charge(i):chance(i)*star(i));
@for(assign(j,i):@bin(x(j,i)));
data:
cost=6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212
6428 980 3885 4039 4596 5482 3160 2321 2802 2818 3265 4274 3212;
star=5 5 3 4 3 4 4 3 3 4 3 4 3;
enddata
end



error code 23 参数个数不符
昨晚熬夜学的lingo, 勉强编了个程序,实在发现不了问题,求大佬排错。




网友评论:
顶起来啊
用lingo做过简单的线性规划,一直不适应他们的语法。楼主可以了解下ortools,谷歌开发的用于解决运筹学问题的工具。支持c++,java,甚至提供Python的API封装。我用它解决公司的tsp问题。

—— 来自 OnePlus ONEPLUS A5010, Android 8.1.0上的 v2.0-play

标签:    发布日期:06-30