如何声明联合集? CPLEX
How to declare set of union? CPLEX
我正在尝试在 CPLEX OPL 上构建模型并面临声明一组并集的问题
5 set of union I have to declare
我是 CPLEX 的新手,我已经使用了与文档相同的方法来声明一个集合:
{float} all_nodes = hubs_nodes union suppliers_nodes union clients_nodes;
{float} IH = hubs_nodes union suppliers_nodes;
{float} A1[IH][IH];
{float} JH = clients_nodes union suppliers_nodes;
{float} A2[JH][JH];
{float} A3[hubs][hubs];
{float} A[all_nodes][all_nodes];
我的模型声明:
minimize sum(k in hubs) operating_hub_cost[k]*allocation_variable[k][k]
+ sum(i in suppliers, k in A3, l in A3) cih*distance[k][l]*total_quantity_flow[i]*fraction_flow_shipped[i][k][l]
+ sum(i, j in A1) cc*distance[i][j]*vehicle_traverses[i][j] + sum(i, j in A2) cd*distance[i][j]*vehicle_traverses[i][j]
+ sum(i in suppliers, k in hubs) one_unit_cost[k]*total_quantity_flow[i]*allocation_variable[i][k]
+ sum(i in suppliers, k,l in A3) one_unit_cost[l]*total_quantity_flow[i]*fraction_flow_shipped[i][k][l]
+ sum(k in hubs, i in suppliers || i in clients) vehicle_cost*vehicle_traverses[k][i];
它告诉我错误:
Cannot use the type {float}[hubs][hubs] with "in".
如何在我的代码中设置不出现 A、A1、A2、A3 错误的情况下声明模型?多谢指教
对于 A 你可以这样写
range N=1..4;
tuple arc
{
int i;
int j;
};
{arc} A={<i,j> | i,j in N};
execute
{
A;
}
我正在尝试在 CPLEX OPL 上构建模型并面临声明一组并集的问题
5 set of union I have to declare
我是 CPLEX 的新手,我已经使用了与文档相同的方法来声明一个集合:
{float} all_nodes = hubs_nodes union suppliers_nodes union clients_nodes;
{float} IH = hubs_nodes union suppliers_nodes;
{float} A1[IH][IH];
{float} JH = clients_nodes union suppliers_nodes;
{float} A2[JH][JH];
{float} A3[hubs][hubs];
{float} A[all_nodes][all_nodes];
我的模型声明:
minimize sum(k in hubs) operating_hub_cost[k]*allocation_variable[k][k]
+ sum(i in suppliers, k in A3, l in A3) cih*distance[k][l]*total_quantity_flow[i]*fraction_flow_shipped[i][k][l]
+ sum(i, j in A1) cc*distance[i][j]*vehicle_traverses[i][j] + sum(i, j in A2) cd*distance[i][j]*vehicle_traverses[i][j]
+ sum(i in suppliers, k in hubs) one_unit_cost[k]*total_quantity_flow[i]*allocation_variable[i][k]
+ sum(i in suppliers, k,l in A3) one_unit_cost[l]*total_quantity_flow[i]*fraction_flow_shipped[i][k][l]
+ sum(k in hubs, i in suppliers || i in clients) vehicle_cost*vehicle_traverses[k][i];
它告诉我错误:
Cannot use the type {float}[hubs][hubs] with "in".
如何在我的代码中设置不出现 A、A1、A2、A3 错误的情况下声明模型?多谢指教
对于 A 你可以这样写
range N=1..4;
tuple arc
{
int i;
int j;
};
{arc} A={<i,j> | i,j in N};
execute
{
A;
}