【问题标题】:Overlapping constraint in linear programming线性规划中的重叠约束
【发布时间】:2022-07-12 00:04:38
【问题描述】:

我正在尝试对非重叠矩形实施约束。我找到了这个链接: http://yetanothermathprogrammingconsultant.blogspot.com/2017/07/rectangles-no-overlap-constraints.html

但我不太明白为什么二进制变量的总和应该小于或等于 3,如下图所示。不应该只有两个约束同时为真,这样总和应该小于或等于两个吗?

【问题讨论】:

    标签: constraints linear-programming gurobi constraint-programming


    【解决方案1】:

    这些约束表明至少有一个不等式应该成立。如果sum(delta)=4 则放宽所有限制。我们想要防止的。所以我们需要禁止sum(delta)=4。我们通过声明sum(delta)<4sum(delta)<=3 来做到这一点。换句话说:至少有一个delta=0,所以至少应该有一个约束。

    所述方法基本上实现了:

    constraint 1 OR constraint 2 OR constraint 3 OR constraint 4.
    

    或者说:

    rectangle i should be to the left of rectangle j
    or rectangle i should be to the right of rectangle j  
    or rectangle i should be above rectangle j  
    or rectangle i should be below rectangle j  
    

    不确定为什么要保留两个约束。

    【讨论】:

    • 现在说得通了。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    相关资源
    最近更新 更多