get_Ncolumns

Returns the number of columns (variables) in the lp.

int get_Ncolumns(lprec *lp);

Return Value

get_Ncolumns returns the number of columns (variables) in the lp.

Parameters

lp

Pointer to previously created lp model. See return value of make_lp, read_lp, read_LP, read_lpt, read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

Remarks

The get_Ncolumns function returns the number of columns (variables) in the lp.
Note that the number of columns can change when a presolve is done or when negative variables are split in a positive and a negative part.
Therefore it is advisable to use this function to determine how many columns there are in the lp instead of relying on an own count.

Example

#include <stdio.h>
#include <stdlib.h>
#include "lp_lib.h"

int main(void)
{
  lprec *lp;
  int Ncolumns;

  /* Create a new LP model */
  lp = make_lp(0, 1);
  if(lp == NULL) {
    fprintf(stderr, "Unable to create new LP model\n");
    return(1);
  }

  Ncolumns = get_Ncolumns(lp); /* Will return 1 */

  set_presolve(lp, PRESOLVE_COLS);
  solve(lp);

  Ncolumns = get_Ncolumns(lp); /* Will return 0 */

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, read_lp, read_LP, read_lpt, read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, get_Norig_columns, get_Nrows, get_Norig_rows, get_orig_index, get_lp_index, get_Lrows