[Coin-discuss] CoinModel: inconsistency between addRow and getElement

John J Forrest jjforre at us.ibm.com
Wed May 16 04:50:05 EDT 2007


Martin,

Bug had been fixed in trunk and branches/devel.  Should be OK now in
stable.

John Forrest


                                                                           
             Martin von Gagern                                             
             <Martin.vGagern at g                                             
             mx.net>                                                    To 
             Sent by:                  Discussions about open source       
             coin-discuss-boun         software for Operations Research    
             ces at list.coin-or.         <coin-discuss at list.coin-or.org>     
             org                                                        cc 
                                                                           
                                                                   Subject 
             05/15/07 12:49 PM         [Coin-discuss] CoinModel:           
                                       inconsistency between addRow and    
                                       getElement                          
             Please respond to                                             
             Discussions about                                             
                open source                                                
               software for                                                
                Operations                                                 
                 Research                                                  
             <coin-discuss at lis                                             
              t.coin-or.org>                                               
                                                                           
                                                                           




Hi!

I just stumbled upon what seems a lot like a bug in CoinModel to me.

#include <iostream>
#include <CoinModel.hpp>

int main() {
  CoinModel model;
  for (int row = 0; row < 2; ++row) {
    int columns[2];
    double elements[2];
    for (int col = 0; col < 2; ++col) {
      columns[col] = col;
      elements[col] = 10 * row + col + 11;
    }
    model.addRow(2, columns, elements);
  }
  for (int row = 0; row < model.numberRows(); ++row) {
    for (int col = 0; col < model.numberColumns(); ++col) {
      std::cout << model.getElement(row, col) << '\t';
    }
    std::cout << std::endl;
  }
  model.writeMps("test.mps");
}

This program outputs the matrix
0            0
0            0
although the written MPS file correctly contains the matrix
11           12
21           22

Using setElement instead of addRow seems to work better.

In case it is intentional not to update any hashes when elemnts are
added rowwise, this fact might be stored in some flag, to make
getElement fail (e.g. using an assertion) instead of behave
inconsistently. Also there should be a method to manually start hashing.
 Or is there already such a method? I found none.

Greetings,
 Martin von Gagern

[attachment "signature.asc" deleted by John J Forrest/Watson/IBM]
_______________________________________________
Coin-discuss mailing list
Coin-discuss at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/coin-discuss





More information about the Coin-discuss mailing list