read_params

Read settings from a parameter file.

unsigned char read_params(lprec *lp, char *filename, char *options);

Return Value

Returns TRUE (1) if parameters could be read, else FALSE (0).

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 parameters from.

options

Optional options. Can be:
-h header: Read parameters at specified header. By default this is Default

Remarks

lp_solve parameters (options) are read from a parameter file. This file has an ini-format as used by Windows applications. All parameters are read from a header. This is by default [Default]. The header can be specified in the options parameter. Other headers are ignored.

Example parameter file:

[Default]
; lp_solve version 5.5 settings

anti_degen=ANTIDEGEN_FIXEDVARS + ANTIDEGEN_STALLING + ANTIDEGEN_INFEASIBLE
basiscrash=CRASH_NONE
improve=IMPROVE_DUALFEAS + IMPROVE_THETAGAP
maxpivot=250
negrange=-1e+006
pivoting=PRICER_DEVEX + PRICE_ADAPTIVE
presolve=PRESOLVE_NONE
presolveloops=2147483647
scalelimit=5
scaling=SCALE_GEOMETRIC + SCALE_EQUILIBRATE + SCALE_INTEGERS
simplextype=SIMPLEX_DUAL_PRIMAL
bb_depthlimit=-50
bb_floorfirst=BRANCH_AUTOMATIC
bb_rule=NODE_PSEUDONONINTSELECT + NODE_GREEDYMODE + NODE_DYNAMICMODE + NODE_RCOSTFIXING
;break_at_first=0
;break_at_value=-1e+030
mip_gap_abs=1e-011
mip_gap_rel=1e-011
epsint=1e-007
epsb=1e-010
epsd=1e-009
epsel=1e-012
epsperturb=1e-005
epspivot=2e-007
infinite=1e+030
;debug=0
;obj_bound=1e+030
;print_sol=0
;timeout=0
;trace=0
;verbose=NORMAL

Note that there are some options commented out (;). This is done because these options can not be used in general for all models or because they are debug/trace/print options. These options can be made active and will be read by read_params but note again that they are possible dangerous to be used in general (except for the debug/trace/print options). Note that there are two kind of entries:

  • Numerical values
  • Options

Numercial values can be integer values like maxpivot or floating point values like epsel

Options are a combination of constants as defined in the manual. Multiple options are added with +. For example option anti_degen.

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);
  }

  read_params(lp, "a.ini", "-h MyParams"); /* Will read parameters from file a.ini under section MyParams */

  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, write_params, reset_params