set_presolve

Specifies if a presolve must be done before solving.

void set_presolve(lprec *lp, int do_presolve, int maxloops);

Return Value

set_presolve has no return value.

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

do_presolve

Specifies presolve level. Can be the (OR) combination of any of the following values:

PRESOLVE_NONE (0) No presolve at all
PRESOLVE_ROWS (1) Presolve rows
PRESOLVE_COLS (2) Presolve columns
PRESOLVE_LINDEP (4) Eliminate linearly dependent rows
PRESOLVE_SOS (32) Convert constraints to SOSes (only SOS1 handled)
PRESOLVE_REDUCEMIP (64) If the phase 1 solution process finds that a constraint is redundant then this constraint is deleted. This is no longer active since it is very rare that this is effective, and also that it adds code complications and delayed presolve effects that are not captured properly.
PRESOLVE_KNAPSACK (128) Simplification of knapsack-type constraints through addition of an extra variable, which also helps bound the OF
PRESOLVE_ELIMEQ2 (256) Direct substitution of one variable in 2-element equality constraints; this requires changes to the constraint matrix. Elimeq2 simply eliminates a variable by substitution when you have 2-element equality constraints. This can sometimes cause fill-in of the constraint matrix, and also be a source of rounding errors which can lead to problems in the simplex.
PRESOLVE_IMPLIEDFREE (512) Identify implied free variables (releasing their explicit bounds)
PRESOLVE_REDUCEGCD (1024) Reduce (tighten) coefficients in integer models based on GCD argument. Reduce GCD is for mixed integer programs where it is possible to adjust the constraint coefficies due to integrality. This can cause the dual objective ("lower bound") to increase and may make it easier to prove optimality.
PRESOLVE_PROBEFIX (2048) Attempt to fix binary variables at one of their bounds
PRESOLVE_PROBEREDUCE (4096) Attempt to reduce coefficients in binary models
PRESOLVE_ROWDOMINATE (8192) Idenfify and delete qualifying constraints that are dominated by others, also fixes variables at a bound
PRESOLVE_COLDOMINATE (16384) Deletes variables (mainly binary), that are dominated by others (only one can be non-zero)
PRESOLVE_MERGEROWS (32768) Merges neighboring >= or <= constraints when the vectors are otherwise relatively identical into a single ranged constraint
Converts qualifying equalities to inequalities by converting a column singleton variable to slack. The routine also detects implicit duplicate slacks from inequality constraints, fixes and removes the redundant variable. This latter removal also tends to reduce the risk of degeneracy. The combined function of this option can have a dramatic simplifying effect on some models. Implied slacks is when, for example, there is a column singleton (with zero OF) in an equality constraint. In this case, the column can be deleted and the constraint converted to a LE constraint.
PRESOLVE_COLFIXDUAL (131072) Variable fixing and removal based on considering signs of the associated dual constraint. Dual fixing is when the (primal) variable can be fixed due to the implied value of the dual being infinite.
PRESOLVE_BOUNDS (262144) Does bound tightening based on full-row constraint information. This can assist in tightening the OF bound, eliminate variables and constraints. At the end of presolve, it is checked if any variables can be deemed free, thereby reducing any chance that degeneracy is introduced via this presolve option.
PRESOLVE_DUALS (524288) Calculate duals
PRESOLVE_SENSDUALS (1048576) Calculate sensitivity if there are integer variables

maxloops

The maximum number of times presolve may be done. Use get_presolveloops if you don't want to change this value.


Remarks

The set_presolve function specifies if a presolve must be done before solving. Presolve looks at the model and tries to simplify it so that solving times are shorter. For example a constraint on only one variable is converted to a bound on this variable (and the constraint is deleted). Note that the model dimensions can change because of this, so be careful with this. Both rows and columns can be deleted by the presolve.
The maxloops variable specifies the maximum number of times presolve is done. After a presolve is done, another presolve can again result in elimination of extra rows and/or columns. This number specifies the maximum number of times this process is repeated. By default this is until presolve has nothing to do anymore. Use get_presolveloops if you don't want to change this value.
Note that PRESOLVE_LINDEP can result in deletion of rows (the linear dependent ones). get_constraints, get_ptr_constraints will then return only the values of the rows that are kept and the values of the deleted rows are not known anymore. The default is not (PRESOLVE_NONE) doing a presolve. The following code can be used to retrieve the values of all the variables, even if variables are deleted by presolve:

int Norig_columns, Norig_rows, i;
REAL value;

Norig_columns = get_Norig_columns(lp);
Norig_rows = get_Norig_rows(lp);
for(i = 1; i <= Norig_columns; i++) {
  value = get_var_primalresult(lp, Norig_rows + i);
  printf("%f\n", value);
}

Note that there is no possibility to get the values of deleted rows.

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

  set_presolve(lp, PRESOLVE_ROWS | PRESOLVE_COLS | PRESOLVE_LINDEP, get_presolveloops(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_presolve, get_presolveloops, is_presolve