c++ - 硬币或线性规划 : ClpPlusMinusOneMatrix representation

标签 c++ coin-or-cbc

我正在使用 Coin-or Linear Programming图书馆。我想构建一个 ClpPlusMinusOneMatrix .它的构造函数是:

ClpPlusMinusOneMatrix (int numberRows, 
                       int numberColumns, 
                       bool columnOrdered, 
                       const int *indices, 
                       const CoinBigIndex *startPositive, 
                       const CoinBigIndex *startNegative);

尚不清楚startPositivestartNegative 是什么。如果它与另一类描述的概念相同 here ,那么矩阵如何区分 +1 和 -1 值?

例如,如果我想实现 1x4 矩阵:[1 -1 1 -1]。 Clp 是怎么知道最后两个元素的值的?

#include <coin/ClpPlusMinusOneMatrix.hpp>

int main()
{
        int indices [4] {0, 1, 2, 3}; 
        CoinBigIndex startPositive [2] {0, 4}; 
        CoinBigIndex startNegative [2] {1, 4}; 
        ClpPlusMinusOneMatrix(1, 4, false, indices, startPositive, startNegative);
}

谢谢

最佳答案

如果浏览源代码here ,您可以推断出什么是 startPositvestartNegative。首先,必须构建矩阵,使得所有 +1 元素必须先于一行中的所有 -1 值(如果行优先)或列(如果列优先)。然后 startPositive[i] 只是行 i 中第一个 +1 的元素索引,如果行主要,或者列 i 如果列主要.

关于c++ - 硬币或线性规划 : ClpPlusMinusOneMatrix representation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38966907/

相关文章:

android - 检查 Android NDK 代码中的整数溢出

python - 您如何让 CBC 在时限内返回最佳解决方案? (皮莫)

python - PuLP CBC 多线程不适用于 COIN_CMD

c++ - 测试 Shell、插入和快速排序的程序问题

c++ - 将二维数组传输到 csv 文件?

c++ - route-me 与 libosmscout(适用于 iOS 的离线 vector map )

c++ - 设备浏览问题

c++ - 使用 C++ 将 vector 数组转换为 .MPS 文件

python - PuLP 求解器错误