bug-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-glpk] 'glp_del_rows' robustness suggestion


From: Robbie Morrison
Subject: [Bug-glpk] 'glp_del_rows' robustness suggestion
Date: Thu, 26 Feb 2009 23:46:45 +0300

Hello Andrew

Concerning GLPK version 4.35, released 09-Jan-2009.

I wonder if 'glp_del_rows' and similar should be more
fault-tolerant.

Consider the following incorrect code:

    int nRows = glp_get_num_rows(d_prob);   // GLPK API, returns 0 in this 
example
    std::vector<int> vRows(1, 0);           // contains { 0 } but could be any 
value
    glp_del_rows(d_prob, nRows, &vRows[0]); // GLPK API

which fails thus:

  glp_del_rows: nrs = 0; invalid number of rows
  Error detected in file glpapi01.c at line 1089

This example clearly falls outside documented usage --
but is not itself completely illogical.  I now protect
against such calls, but it might be useful to make GLPK
more tolerant in such circumstances.  Just a thought.

In passing, note the use of the C++ std::vector 'vRows'
as a C array -- in which case, simply pass in the
address of the first element: &vRows[0].  I quite like
this idiom.

cheers, Robbie
---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : address@hidden
Webmail (preferred)           : address@hidden
[from IMAP client]









reply via email to

[Prev in Thread] Current Thread [Next in Thread]