# read_basis

Read basis from a file and set as default basis.

unsigned char read_basis(lprec *lp, char *filename, char *info);

Return Value

Returns TRUE if basis could be read from filename and FALSE if not.
A FALSE return value indicates an error. Specifically file could not be opened or file has wrong structure or wrong number/names rows/variables or invalid basis.

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

filename

Filename to read the basis from.

info

When not NULL, returns the information of the INFO card in filename. When NULL, the information is ignored. Note that when not NULL, that you must make sure that this variable is long enough, else a memory overrun could occur.

Remarks

The read_basis function reads a basis from filename and sets it as initial basis of the lp.
Setting an initial basis can speed up the solver considerably. It is the starting point from where the algorithm continues to find an optimal solution.
When a restart is done, lp_solve continues at the last basis, except if set_basis, default_basis, guess_basis or read_basis is called.

The basis in the file must be in MPS bas file format.

Example

    #include <stdio.h>
    #include <stdlib.h>
    #include "lp_lib.h"

    int main(void)
    {
      lprec *lp;
      int ret;

      /* Read LP model */
      lp = read_LP("model.lp", NORMAL, "test model");
      if(lp == NULL) {
        fprintf(stderr, "Unable to create new LP model\n");
        return(1);
      }

      ret = read_basis(lp, "model.bas", NULL);

      ret = solve(lp);

      delete_lp(lp);
      return(0);
    }

lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, get_basis, set_basis, default_basis, write_basis, guess_basis, get_basiscrash, set_basiscrash