DOKK / manpages / debian 12 / lp-solve / lp_solve.1.en
lp_solve(1) General Commands Manual lp_solve(1)

lp_solve - a mixed integer linear programming (MILP) solver

lp_solve [options] [input file]

lp_solve solves mixed integer linear programming problems. The program accepts models of problems in various different formats (including custom formats through XLIs) and attempts to solve them. There are a large number of different options which can be used to alter the solving process to improve performance or get more accurate results.

The lp file format is a simple, human readable file format for linear programming models. It is the default format used by lp_solve.

The format consists of series of statements, each ending in a semicolon. The first statement is always the objective function, followed by any number of constraints, followed by any number of declarations.

The objective function consists of an expression to be optimized, optionally prefixed by max: or min: to specify which direction to optimize. The default is to maximize.

Each constraint consists of a relational expression, optionally prefixed by a name followed by a colon. The expression must contain at least one relational operator (<, <=, =, =>, >). You can specify ranges two operators at once (e.g. 2 < x < 4) instead of two separate constraints.

Declarations can be one of:

Marks the variables as integers.
Marks the variables as binary (can only take 0 or 1).
Marks the variables as semi-continuous. These variables can always take the value 0 even if it is outside the variable's range.
Marks the variables as free. These variables have no lower bound, unlike other variables which have a default lower bound of 0.
Marks the variables as part of a special ordered set (SOS). Out of the variables listed, only one can be non-zero at once. If sostype is specified, then up to that number of variables can be non-zero as long as they are all adjacent to each other (e.g. for an sostype of 2, var1 and var2 could be non-zero, but not var1 and var3).

Both C style comments (/* comment here */) and C++ style comments (// comment until end of line) can be used anywhere in the file.

Writes the model after solving it (normally any model conversions are processed before solving). This is useful if presolving is used to simplify the model.
Parse the input model, but stop before solving it. This can be used to convert models between formats without solving them.
Timeout if no solution has be found after sec seconds.
Ignore variable and constraint names in the input model (this is the same as combining both -norownames -nocolnames).
Ignore constraint names in the input model.
Ignore variable names in the input model.
Minimizes the LP problem, overriding the setting in the input model.
Maximizes the LP problem, overriding the setting in the input model.

Read the model from a file in LP format. This the the default.
Read the model from a file in 'fixed width' MPS format.
Read the model from a file in 'free' MPS format. This is the same as -mps except that fields are separated by a number of blanks instead of starting at fixed columns.
Converts the input model to LP format and writes it to the a file.
Converts the input model to 'fixed width' MPS format and writes it to a file.
Converts the input model to 'free' MPS format and writes it to a file.

Read the model using an external language interface (XLI). xliname specifies the path to the shared library containing the XLI, and is searched for according to the normal library search rules in ld.so(8) with the addition that the library filename is prefixed with lib and suffixed with .so if necessary.
Provides a file containing extra data used by the reading XLI library.
Extra options to pass to the reading XLI library.
Converts the input model to the format used by an XLI and writes it to a file. The format of xliname is described in -rxli above.
Extra options to pass to the writing XLI library.
Writes the model's solution to a file using an XLI library. The format of xliname is described in -rxli above.
Extra options to pass to the solution writing XLI library.

Print a usage message and exit.
Solution detail. Each level builds on top of the previous one and adds more detail to the solution.

0
print nothing
1
objective value only
2
variables (default level)
3
constraints
4
duals
5
lp model
6
scales
7
lp tableau
Print CPU time to parse input and to calculate solution.
Verbosity level. Controls the level of messages printed about the operation of the program.

0
neutral
1
critical
2
severe
3
important (default when -v is provided with no level)
4
normal (default when no -v option is given)
5
detailed
6
full
Trace pivot selection.
Debug mode. All intermediate results and branch-and-bound decisions are printed.
Report information while solving the model.
Create a dump of internal model variables before solving the model to given file.
Create a dump of internal model variables after solving the model, to given file.
Print all intermediate valid solutions. If a is used, prints only non-zero values. Can give useful solutions even if the total run time is too long.

Reads a list of parameters from a file. The parameters file can specify the same options as you can by passing arguments to lp_solve but can be more convenient if you need to change lots of settings. The format of the parameters file is in the INI format often used by Windows applications. All parameters are read from key-value pairs in a single section. The default section is [Default].
Sets options for reading the parameters file. Currently the only option is -h which changes the section within the file to read the parameters from.
Writes a parameters file based on the arguments given to lp_solve.
Sets options for writing the parameter file. Currently the only option is -h which changes the section within the file to write the parameters to.

Reads a basis file which is used as the starting point for solving the LP model. Basis files must be in MPS basis format.
Computes a basis from a list of initial guesses for each variable. Each line of the given file is in the format: variable:value where value is the initial guess for variable.
After solving the LP model, writes a basis file in MPS format. This file can be read back using -rbas.

Available options:
0
no crash basis (default).
1
most feasible basis.
2
least degenerate basis.

Ignore integer restrictions on variables.
Stops the branch and bound algorithm immediately after finding its first solution.
Stops the branch and bound algorithm immediately after finding a solution whose objective function has a value greater than this bound.
Sets a lower bound for the objective function. The branch and bound algorithm will immediately reject all solutions lower than this value.
Sets the depth limit for the branch and bound algorithm. A value of 0 disables depth limiting. A negative value sets a relative depth limit based on the number of variables in the input model. The default limit is -50.
Sets the tolerance which is used to determine whether a floating point number is an integer. A number has to be within this value of an integer to be considered one. The default value is 1e-7.
-g tolerance, -ga tolerance
Sets the absolute MIP gap used by the branch and bound algorithm. This tolerance is the difference between the best-found solution yet and the current solution. If the difference is smaller than this tolerance then the solution (and all the sub-solutions) is rejected. This can result in faster solving times, but results in a solution which is not the perfect solution. The default value is 1e-11.
Sets the relative MIP gap used by the branch and bound algorithm. This is similar to the absolute tolerance except that the difference is scaled by the best found solution before being compared to this tolerance. The default value is 1e-11.
During branch and bound, take the ceiling branch first.
During branch and bound, take the floor branch first.
During branch and bound, allow the algorithm to decide which branch to take. This is the default.
If the branch and bound algorithm produces multiple solutions with the same objective function value, prints the nth solution. Solution numbers start at 1.
Sets a branch and bound rule to use. The default rules are: -B5 -Bg -Bd -Bc

These rules are mutually exclusive:
0
select lowest indexed non-integer column.
1
selection based on distance from the current bounds.
2
selection based on the largest current bound.
3
selection based on largest fractional value.
4
simple, unweighted pseudo-cost of a variable.
5
extended pseudo-costing strategy based on minimizing the number of integer infeasibilities.
6
extended pseudo-costing strategy based on maximizing the normal pseudo-cost divided by the number of infeasibilities.

The above rules can be combined with any of the following:

WeightReverse - select by criterion minimum (worst), rather than criterion maximum (best).
BranchReverse - when -ca is selected, choose the opposite direction.
Greedy
PseudoCost - toggles between weighting based on pseudocost or objective function value.
DepthFirst - select the node that has already been selected before the most number of times.
Randomize - ddds a randomization factor to the score for any node candidate.
GubMode
Dynamic - when -Bf is selected, switch off this mode when a first solution is found.
RestartMode - enables regular restarts of pseudocost value calculations.
BreadthFirst - select the node that has been selected before the fewest number of times or not at all.
AutoOrder - order variables to improve branch-and-bound performance.
ReducedCostFixing - do bound tightening during B&B based of reduced cost info.
StringInit - initialize pseudo-costs by strong branching.

Prefer the primal simplex method for both phase 1 and phase 2.
Prefer the dual simplex method for both phase 1 and phase 2.
Prefer the dual simplex method for phase 1 and primal method for phase 2. This is the default.
Prefer the primal simplex method for phase 1 and dual method for phase 2.
Sets the basis factorization package to use. filename refers to a shared library loaded in the same way -rxli loads libraries.
Sets whether the objective function is stored in the top row of the constraint matrix or in separate storage. -o0 places the matrix in separate storage, and -o1 (the default) places it in the constraint matrix.
Sets the basis crash mode. When base crash is enabled, a heuristic 'crash procedure' is executed before the first simplex iteration to quickly choose a basis matrix that has fewer artificial variables. This procedure tends to reduce the number of iterations to optimality since a number of iterations are skipped.
Sets the maximum number of pivots between a re-inversion of the matrix. For stability reasons, lp_solve re-inverts the matrix on regular times. The default is 250 for the LUSOL bfp and 42 for the other BFPs.
Sets the value that is used as a tolerance pivot element to determine whether a value should be considered as 0. The default is 2e-7.
Sets the value that is used as a tolerance for reduced costs to determine whether a value should be considered as 0. The default is 1e-9.
Sets the value that is used as a tolerance for the Right Hand Side (RHS) to determine whether a value should be considered as 0. The default is 1e-10.
Sets the value that is used as a tolerance for rounding values to zero. The default is 1e-12.
Sets the value that is used as perturbation scalar for degenerative problems. The default is 1e-5.
Sets the iterative improvement level. level is a number which can be created by combining the different levels below. The default is -improve6.

0
none.
1
running accuracy measurement of solved equations on Bx=r.
2
improve initial dual feasibility by bound flips.
4
low-cost accuracy monitoring in the dual.
8
check for primal/dual feasibility at the node level.
Sets a simplex pivot rule or mode to use. The default rules are: -piv2 -piva

These rules are mutually exclusive:
0
select first.
1
select according to Dantzig.
2
select Devex pricing from Paula Harris.
3
select steepest edge.

The above rules can be combined with any of the following modes:

PrimalFallback - when steepest edge (-priv3) is selected, fallback to Devex in primal.
Multiple - preliminary implementation of the multiple pricing scheme. This means that attractive candidate entering columns from one iteration may be used in the subsequent iteration, avoiding full updating of reduced costs. In the current implementation, lp_solve only reuses the 2nd best entering column alternative
Adaptive - temporarily use alternative strategy if cycling is detected.
Randomize - adds a small randomization effect to the selected pricer.
LoopLeft - scan entering/leaving columns left rather than right.
LoopAlternate - scan entering/leaving columns alternating left/right.
HarrisTwoPass - use Harris' primal pivot logic rather than the default.
TrueNormInit - use true norms for Devex and Steepest Edge initializations.
Specifies if special handling must be done to reduce degeneracy/cycling while solving. The default options are: -degenf -degens.

Available options:
ColumnCheck
Dynamic
FixedVars
Stalling
NumFailure
Lostfeas
Infeasible
DuringBB
RHSPerturb
BoundFlip

Enables a presolve option. These options attempt to speed up calculations by simplifying the model before solving it. Any of these options can be combined together. If option is not specified, row and column presolving is enabled (as if -presolverow -presolvecol had been used). The default not to presolve.

Available options:
Rows - presolve rows.
Cols - presolve columns.
LinDep - eliminate linearly dependent rows.
Sos - convert constraints to SOSes (only SOS type 1 handled).
ReduceMip - if the phase 1 solution process finds that a constraint is redundant then this constraint is deleted.
Knapsack - simplification of knapsack-type constraints through addition of an extra variable, which also helps bound the objective function.
ElimEQ2 - direct substitution of one variable in 2-element equality constraints; this requires changes to the constraint matrix.
MergeRows - merges neighboring >= or <= constraints when the vectors are otherwise relatively identical into a single ranged constraint.
ColFixDual - variable fixing and removal based on considering signs of the associated dual constraint.
Bounds - does bound tightening based on full-row constraint information.
Duals - presolve duals.
ImpliedFree - identify implied free variables (releasing their explicit bounds).
ImpliedSlk- converts qualifying equalities to inequalities by converting a column singleton variable to slack.
ReduceGCD - reduce (tighten) coefficients in integer models based on GCD argument.
ProbeFix - attempt to fix binary variables at one of their bounds.
ProbeReduce - attempt to reduce coefficients in binary models.
RowDominate - identify and delete qualifying constraints that are dominated by others, also fixes variables at a bound.
ColDominate - deletes variables (mainly binary), that are dominated by others (only one can be non-zero).
-s[mode] [scalelimit]
Sets the scaling algorithm and/or scaling limit to use. scalelimit can only be specified when using the mutually exclusive integer modes. Omitting mode is the equivalent of using -s4. The default algorithm and limit is: -s1 5 -si -se

These rules are mutually exclusive:
0
no scaling.
1
geometric scaling.
2
Curtis-Reid scaling.
3
scale to convergence using largest absolute value.
4
numerical range-based scaling.
5
scale to convergence using logarithmic mean of all values.
6
scale based on the simple numerical range.
7
scale quadratic.

The above rules can be combined with any of the following:

also do power scaling.
also scale integer variables.
ensure no scaled number is outside the range -1..1.

The following example shows a model being solved by lp_solve. The first line contains the objective function to be maximized and the last 3 lines contain the constraints.

$ cat example.lp
max: 143 x + 60 y;
120 x + 210 y <= 15000;
110 x + 30 y <= 4000;
x + y <= 75;
$ lp_solve -S3 example.lp
Value of objective function: 6315.63
Actual values of the variables:
x                          21.875
y                          53.125
Actual values of the constraints:
R1                        13781.2
R2                           4000
R3                             75

This example converts a file in lp format to mps format.

$ lp_solve -parse_only -lp example.lp -wmps example.mps

ld.so(8)

September 2015