CPLEX OPL软目标,将高优先股分组
OPL模型的目标是选择以最低成本的总成本来履行所有订单,我有一个软优化目标 Objective1
尝试将所有订单与 categoryPriority 在一个货运或尽可能少的货物上。但是如何编码该目标呢? (在下面的示例中,订单2和3是在同一卡车上的最佳选择)
当前.mod文件(型号文件)
tuple TFreightTypes {
key string Destination;
key string VehicleType;
int TotalWeight;
key string Company;
int Cost;
};
tuple TOrders {
key int OrderNumber;
float Weight;
string ClientId;
string Destination;
string MaterialCategory;
int CategoryPriority;
};
{TFreightTypes} FreightTypes = ...;
{TOrders} Orders = ...;
dvar boolean Assignment[Orders][FreightTypes];
//choose freight with total minimum cost
dexpr float objective =
sum(o in Orders, f in FreightTypes)
Assignment[o][f] * f.Cost;
//try to put all orders with CategoryPriority=1 on one truck
//dexpr float objective1 =
//how to do that?
minimize 0.95*objective+0.05*objective1;
subject to{
//c1: all order must be fulfilled
forall(o in Orders)
sum(f in FreightTypes) Assignment[o][f]==1;
}
.dat文件(数据文件)
FreightTypes = {
<"LONDON","Type1",20000,"SP TRANSPORTS",40000>,
<"LONDON","Type2",20000,"SP TRANSPORTS",40000>,
<"DURHAM","Type3",10000,"SP TRANSPORTS",30000>,
};
Orders = {
<1,5000,"Client1","LONDON","A",0>,
<2,1000,"Client2","DURHAM","B",1>,
<3,2000,"Client3","LONDON","C",1>,
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是加权总和
最小化0.95 目标+0.05 Objective1;
您可以使用词典学:
最小化静态(objective,objective1);
完整示例
在您的模型中看起来像以下内容
instead of weighted sum
minimize 0.95objective+0.05objective1;
you can use lexicographic :
minimize staticLex(objective,objective1);
Full example https://github.com/AlexFleischerParis/zooopl/blob/master/zoomultiobjective.mod
which could look like the following with your model