作业帮 > 综合 > 作业

lingo 目标函数的代码编写

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 16:18:31
lingo 目标函数的代码编写
目标函数为

 程序为:
MODEL:
sets:
Warehouse/1..4/:a;
 Customer/1..8/:b;
prize/1..4/:p;
 qu/1..8/:q;
 Routes(Warehouse,Customer):c,x;
 
 endsets
 !here are the parameters;
 data:
 a=6,8,6,22;
 b=6,5,8,5,6,5,4,6;
 p=92,88,90,86;
 q=105,110,108,105,110,112,126,132;
 c=2,11,3,4,12,16,22,26,
 10,3,5,9,15,18,24,35,
  7,8,1,2,8,13,33,48,
  12,9,16,7,16,21,42,56;
 enddata
 !The objective;
 [OBJ]max=@sum(q*x)-@sum(p*x)-@sum(Routes:c*x); // 这边不知道该怎么写,x应该是矩阵
 !The supply constraints;
 @for(Warehouse(i):[SUP]
 @sum(Customer(j):x(i,j))=a(i););
!The demand constraints;
 @for(Customer(j):[DEM]
 @sum(Warehouse(i):x(i,j))<=b(j););
end

lingo 目标函数的代码编写
max=@sum(routes(i,j):q(j)*x(i,j)+p(i)*x(i,j)-c(i,j)*x(i,j));