我正在尝试在 Cplex/OPL 中运行此模型,以找到给定商店距离的最佳路径,以及每个商店中不同产品的数量+价格。问题是我得到了脱节路径的结果 - “岛屿”。我需要添加什么约束才能只获得一个在节点 1 开始和结束的封闭路径?这是模型:
dvar float+ x[products,stores];
dvar boolean y[stores,stores];
minimize ((sum(i in products, j in stores) prices[i,j]*x[i,j]) + (sum(j in stores, k
in stores) gas*distance[j,k]*y[j,k]));
subject to {
sum(k in stores) y[1,k] == 1;
sum(j in stores) y[j,1] == 1;
forall(j in stores)
sum(i in products) x[i,j] <= M*sum(k in stores) y[j,k];
forall(j in stores)
sum(i in products) x[i,j] <= M*sum(k in stores) y[k,j];
forall(i in products) sum(j in stores) x[i,j] == demand[i];
forall(i in products, j in stores) x[i,j] <= quantity[i,j];
forall(j in stores, k in stores) y[j,k] + y[k,j] <= 1;
forall(j in stores) sum(k in stores) y[j,k] == sum(k in stores) y[k,j];
}
谢谢!