# write_mps, write_freemps, write_MPS, write_freeMPS, MPS_writefileex Write an mps model. unsigned char write_MPS(lprec *lp, FILE *stream); unsigned char write_freeMPS(lprec *lp, FILE *stream); unsigned char write_mps(lprec *lp, char *filename); unsigned char write_freemps(lprec *lp, char *filename); unsigned char MPS_writefileex(lprec *lp, int typeMPS, void *userhandle, (void *userhandle, char *buf) write_modeldata_routine); Return Value The routines 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 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 stream Pointer to FILE structure. filename Filename to write the mps model to. typeMPS type of the MPS file. Can be one of the following values:
MPSFIXED (1) | Fixed MPS format
MPSFREE (2) | Free MPS format
write_modeldata_routine Routine to write the MPS model to. The routine has following definition: typedef int (__WINAPI write_modeldata_func)(void *userhandle, char *buf); userhandle is the second parameter passed to write_lp_ex buf is a shrunk of data. Remarks The write_mps, write_freemps, write_MPS, write_freeMPS functions write the model to filename. write_MPS, write_freeMPS need a file pointer to an already opened file. write_mps, write_freemps accept the name of the file. The latter function will generally be more convenient. MPS_writefileex writes the model via a user defined routine. 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 mps-format. The write_free* routines write files in free MPS format. The other routines write files in fixed MPS format. 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);
      }

      write_mps(lp, "model.mps");

      delete_lp(lp);
      return(0);
    }
lp_solve API reference See Also delete_lp, free_lp, make_lp, copy_lp,read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, read_lp, read_LP, write_lp, write_LP, write_lpex, read_lp, read_LP