resize_lp

Allocate memory for the specified size.

unsigned char resize_lp(lprec *lp, int rows, int columns);

Return Value

Returns TRUE if succeeded, FALSE if not.

Parameters

lp

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

rows

Allocate memory for this amount of rows.

columns

Allocate memory for this amount of columns.

Remarks

The resize_lp function deletes the last rows/columns of the model if the new number of rows/columns is less than the number of rows/columns before the call.

However, the function does not add rows/columns to the model if the new number of rows/columns is larger. It does however changes internal memory allocations to the new specified sizes. This to make the add_constraint, add_constraintex, str_add_constraint and add_column, add_columnex, str_add_column routines faster. Without resize_lp, these functions have to reallocated memory at each call for the new dimensions. However if resize_lp is used, then memory reallocation must be done only once resulting in better performance. So if the number of rows/columns that will be added is known in advance, then performance can be improved by using this function.

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, 3);
  if(lp == NULL) {
    fprintf(stderr, "Unable to create new LP model\n");
    return(1);
  }

  /* Model created */

  /* 1000 constraints will be added, so allocate memory for it in advance to make things faster */
  resize_lp(lp, 1000, get_Ncolumns(lp));

  /* Now add the 1000 constraints */

  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, add_column, add_columnex, str_add_column, add_constraint, add_constraintex, str_add_constraint