CPLEX 我如何编写此类索引的方程式
CPLEX how do i write the equation for such indexing
我正在尝试在 cplex ide 中编写以下约束。
x_ij +x_ji == 1
(汽车i
前面的汽车j
或汽车j
前面的汽车i
)对于所有i
和j
这样 i<j
他们都被分配了起始位置,bently是1honda是2bmw是3audi是4
我试过的..
{string} cars = ["bently" "honda" "bmw" "audi"];
dvar int x[cars][cars] in 0..1;
forall(i in cars)
forall(j in cars:i<j)
x[i][j] + x[j][i] == 1;
提前致谢..
可以
{string} cars = {"bently" ,"honda" ,"bmw" ,"audi"};
dvar int x[cars][cars] in 0..1;
subject to
{
forall(ordered i,j in cars)
x[i][j] + x[j][i] == 1;
}
帮助?
或
using CP;
{string} cars = {"bently" ,"honda" ,"bmw" ,"audi"};
dvar int position[cars] in 0..3;
subject to
{
allDifferent(position);
}
?
如果你标记你的约束,你会得到放松,这将帮助你调试:
forall(i in cars)
ctA:-aps <= ((numcars - sum(i in cars, j in cars:i < j) x[i][j]) - inicarposition[i]);
forall(i in cars)
ctB:((numcars - sum(i in cars, j in cars:i < j) x[i][j]) - inicarposition[i]) <= aps;
我正在尝试在 cplex ide 中编写以下约束。
x_ij +x_ji == 1
(汽车i
前面的汽车j
或汽车j
前面的汽车i
)对于所有i
和j
这样 i<j
他们都被分配了起始位置,bently是1honda是2bmw是3audi是4
我试过的..
{string} cars = ["bently" "honda" "bmw" "audi"];
dvar int x[cars][cars] in 0..1;
forall(i in cars)
forall(j in cars:i<j)
x[i][j] + x[j][i] == 1;
提前致谢..
可以
{string} cars = {"bently" ,"honda" ,"bmw" ,"audi"};
dvar int x[cars][cars] in 0..1;
subject to
{
forall(ordered i,j in cars)
x[i][j] + x[j][i] == 1;
}
帮助?
或
using CP;
{string} cars = {"bently" ,"honda" ,"bmw" ,"audi"};
dvar int position[cars] in 0..3;
subject to
{
allDifferent(position);
}
?
如果你标记你的约束,你会得到放松,这将帮助你调试:
forall(i in cars)
ctA:-aps <= ((numcars - sum(i in cars, j in cars:i < j) x[i][j]) - inicarposition[i]);
forall(i in cars)
ctB:((numcars - sum(i in cars, j in cars:i < j) x[i][j]) - inicarposition[i]) <= aps;