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, add_constraintex, str_add_constraint

columns

Initial number of columns. Can be 0 as new columns can be added via add_column, add_columnex, 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 "lp_lib.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 copy_lp, delete_lp, free_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, resize_lp