write_lpt, write_LPT

Write a CPLEX lp model to a file.

unsigned char write_LPT(lprec *lp, FILE *stream);

unsigned char write_lpt(lprec *lp, char *filename);

Return Value

write_lpt and write_LPT return TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error.
Note that row entry mode must be off, else this function also fails. See set_add_rowmode



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


Pointer to FILE structure.


Filename to write the CPLEX lp model to.


The write_lpt and write_LPT functions write the model to filename in CPLEX lp format. write_LPT needs a file pointer to an already opened file. write_lpt accepts the name of the file. The latter function will generally be more convenient.

When stream or filename are NULL, then output is written to output set by set_outputstream, set_outputfile. By default this is stdout.

The model in the file will be in CPLEX lp-format.


#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");

  write_lpt(lp, "model.lpt");


lp_solve API reference

See Also delete_lp, free_lp, make_lp, read_lpt, read_LPT, read_lp, read_LP, write_lp, write_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, write_mps, write_freemps, write_MPS, write_freeMPS