copy_lp

Copy an lprec structure to a new lprec structure.

lprec *copy_lp(lprec *lp);

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

lp

lprec structure to copy from.

Remarks

The copy_lp function makes a copy of an existing lp. The new lp is completely independent of the original lp.

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, *lpcopy;

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

  if(lpcopy == NULL) {
    fprintf(stderr, "Unable to create copy LP model\n");
    return(1);
  }
  
  /* Model created */
  
  /*
  .
  .
  .
  */
  
  delete_lp(lp);
  delete_lp(lpcopy);
  return(0);
}

lp_solve API reference

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