[Clp] An error in CoinStructuredModel?

Siamak Moradi siamak.ind at gmail.com
Wed Mar 6 00:27:32 EST 2013


Hi everyone,

I have attached (and pasted below) a small program that demonstrates a
problem that I've encountered with CoinStructuredModel:

The demonstration works as follows:
* Read a block structured LP from an MPS file
* Loop over the blocks; print their dimensions and number of entries
* Retrieve a reference to a **nonzero** block via
CoinStructuredModel::coinBlock
* Request a pointer to the blocks entries via CoinModel::elements
* Surprisingly, the call results in a null pointer.

If anyone has a moment in which to compile and run this small example, I
would be very grateful for any suggestions. Although I am sure that I've
done something silly, I have no good leads at this point! Perhaps I am
missing a crucial call to a consolidation method?

Many thanks in advance,

Siamak

<reproduce_error.cpp>
#include "CoinStructuredModel.hpp"
#include <iostream>

/*
This program reproduces what appears to be an error in CoinStructuredModel.
Any comments would be greatly appreciated.
*/

int main(int, char * [])
{
    using namespace std;

    //
    // Loads a problem with 4x4 blocks; 7 are nonzero
    //
    CoinStructuredModel structuredModel("4x4blocks.mps", true);

    cout << "blocks: " << structuredModel.numberRowBlocks() << " x " <<
structuredModel.numberColumnBlocks() << endl;
    cout << "entries: " << structuredModel.numberRows() << " x " <<
structuredModel.numberColumns() << endl;

    //
    // Displays block attributes:
    // Note that block (0, 0), in particular, is nonzero
    //
    for (int i = 0; i != structuredModel.numberRowBlocks(); ++i)
    {
        for (int j = 0; j != structuredModel.numberColumnBlocks(); ++j)
        {
            int index = structuredModel.blockIndex(i, j);
            if(index >= 0)
            {
                CoinModel const& block = *structuredModel.coinBlock(index);
                cout << "index of block (" << i << ", " << j << ")... " <<
index << ": ";
                cout << block.numberRows() << " x " <<
block.numberColumns();
                cout << " (" << block.numberElements() << " entries)" <<
endl;
            }
        }
    }

    //
    // Here, we "know" that block (0, 0) is nonzero...
    //
    const int id = structuredModel.blockIndex(0, 0);
    CoinModel block = *structuredModel.coinBlock(id);

    //
    // ... yet we are unable to retrieve its entries via elements()
    //
    cout << "Entries for block " << id << "... " << endl;
    CoinModelTriple const* triple = block.elements();
    assert(triple != 0); // This assertion fails!

    return 0;
}
</reproduce_error.cpp>

<4x4blocks.mps>
NAME          3commodi
ROWS
 E  R0001
 E  R0002
 E  R0003
 E  R0004
 E  R0005
 E  R0006
 E  R0007
 E  R0008
 E  R0009
 E  R0010
 E  R0011
 E  R0012
 E  R0013
 E  R0014
 E  R0015
 E  R0016
 E  R0017
 E  R0018
 E  R0019
 E  R0020
 E  R0021
 E  R0022
 E  R0023
 E  R0024
 L  R0025
 L  R0026
 L  R0027
 L  R0028
 L  R0029
 L  R0030
 L  R0031
 L  R0032
 L  R0033
 L  R0034
 L  R0035
 N  R0036
COLUMNS
    C0001     R0001     1
    C0001     R0006     -1
    C0001     R0025     1
    C0001     R0034     3
    C0001     R0035     18
    C0001     R0036     3
    C0002     R0001     1
    C0002     R0004     -1
    C0002     R0026     1
    C0002     R0034     10
    C0002     R0035     2
    C0002     R0036     10
    C0003     R0002     1
    C0003     R0004     -1
    C0003     R0027     1
    C0003     R0034     2
    C0003     R0035     7
    C0003     R0036     2
    C0004     R0003     1
    C0004     R0004     -1
    C0004     R0028     1
    C0004     R0034     6
    C0004     R0035     8
    C0004     R0036     6
    C0005     R0003     1
    C0005     R0008     -1
    C0005     R0029     1
    C0005     R0034     10
    C0005     R0035     7
    C0005     R0036     10
    C0006     R0004     1
    C0006     R0005     -1
    C0006     R0030     1
    C0006     R0034     5
    C0006     R0035     6
    C0006     R0036     5
    C0007     R0005     1
    C0007     R0006     -1
    C0007     R0031     1
    C0007     R0034     7
    C0007     R0035     6
    C0007     R0036     7
    C0008     R0005     1
    C0008     R0007     -1
    C0008     R0032     1
    C0008     R0034     5
    C0008     R0035     4
    C0008     R0036     5
    C0009     R0005     1
    C0009     R0008     -1
    C0009     R0033     1
    C0009     R0034     8
    C0009     R0035     1
    C0009     R0036     8
    C0010     R0009     1
    C0010     R0014     -1
    C0010     R0025     1
    C0010     R0034     2
    C0010     R0035     2
    C0010     R0036     2
    C0011     R0009     1
    C0011     R0012     -1
    C0011     R0026     1
    C0011     R0034     7
    C0011     R0035     6
    C0011     R0036     7
    C0012     R0010     1
    C0012     R0012     -1
    C0012     R0027     1
    C0012     R0034     3
    C0012     R0035     8
    C0012     R0036     3
    C0013     R0011     1
    C0013     R0012     -1
    C0013     R0028     1
    C0013     R0034     1
    C0013     R0035     3
    C0013     R0036     1
    C0014     R0011     1
    C0014     R0016     -1
    C0014     R0029     1
    C0014     R0034     5
    C0014     R0035     2
    C0014     R0036     5
    C0015     R0012     1
    C0015     R0013     -1
    C0015     R0030     1
    C0015     R0034     3
    C0015     R0035     1
    C0015     R0036     3
    C0016     R0013     1
    C0016     R0014     -1
    C0016     R0031     1
    C0016     R0034     4
    C0016     R0035     2
    C0016     R0036     4
    C0017     R0013     1
    C0017     R0015     -1
    C0017     R0032     1
    C0017     R0034     3
    C0017     R0035     2
    C0017     R0036     3
    C0018     R0013     1
    C0018     R0016     -1
    C0018     R0033     1
    C0018     R0034     6
    C0018     R0035     2
    C0018     R0036     6
    C0019     R0017     1
    C0019     R0022     -1
    C0019     R0025     1
    C0019     R0034     3
    C0019     R0035     5
    C0019     R0036     3
    C0020     R0017     1
    C0020     R0020     -1
    C0020     R0026     1
    C0020     R0034     3
    C0020     R0035     3
    C0020     R0036     3
    C0021     R0018     1
    C0021     R0020     -1
    C0021     R0027     1
    C0021     R0034     4
    C0021     R0035     7
    C0021     R0036     4
    C0022     R0019     1
    C0022     R0020     -1
    C0022     R0028     1
    C0022     R0034     2
    C0022     R0035     4
    C0022     R0036     2
    C0023     R0019     1
    C0023     R0024     -1
    C0023     R0029     1
    C0023     R0034     3
    C0023     R0035     22
    C0023     R0036     3
    C0024     R0020     1
    C0024     R0021     -1
    C0024     R0030     1
    C0024     R0034     8
    C0024     R0035     5
    C0024     R0036     8
    C0025     R0021     1
    C0025     R0022     -1
    C0025     R0031     1
    C0025     R0034     6
    C0025     R0035     3
    C0025     R0036     6
    C0026     R0021     1
    C0026     R0023     -1
    C0026     R0032     1
    C0026     R0034     2
    C0026     R0035     6
    C0026     R0036     2
    C0027     R0021     1
    C0027     R0024     -1
    C0027     R0033     1
    C0027     R0034     8
    C0027     R0035     2
    C0027     R0036     8
RHS
    B         R0001     18
    B         R0006     -18
    B         R0010     20
    B         R0015     -20
    B         R0019     25
    B         R0024     -25
    B         R0025     30
    B         R0026     20
    B         R0027     50
    B         R0028     20
    B         R0029     20
    B         R0030     50
    B         R0031     20
    B         R0032     20
    B         R0033     20
    B         R0034     100000000
    B         R0035     100000000
ENDATA
</4x4blocks.mps>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/clp/attachments/20130306/f5a5b926/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4x4blocks.mps
Type: application/octet-stream
Size: 5347 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/clp/attachments/20130306/f5a5b926/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reproduce_error.cpp
Type: text/x-c++src
Size: 1619 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/clp/attachments/20130306/f5a5b926/attachment-0001.bin>


More information about the Clp mailing list