make_lp

Create and initialise a new lprec structure.

lprec *make_lp(int rows, int columns);

Return Value

Returns a pointer to a new lprec structure. This must be provided to almost all lp_solve functions.
A NULL return value indicates an error. Specifically not enough memory available to setup an lprec structure.

Parameters

rows

Initial number of rows. Can be 0 as new rows can be added via add_constraint or str_add_constraint

columns

Initial number of columns. Can be 0 as new columns can be added via add_column or str_add_column

Remarks

The make_lp function constructs a new LP. Sets all variables to initial values.
The LP has rows rows and columns columns. The matrix contains no values, but space for one value. All arrays that depend on rows and columns are allocated.

It is advised not to read/write the lprec structure. Instead, use the function interface to communicate with the lp_solve library. This because the structure can change over time. The function interface will be more stable.

Example

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

int main(void)
{
  lprec *lp;

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

  /* Model created */

  /*
  .
  .
  .
  */

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also delete_lp, copy_lp, read_lp, read_lp_file, read_LP, read_mps, read_MPS