solve
solve the model.
int solve(lprec *lp);
Return Value
NOMEMORY (-2) |
Out of memory |
OPTIMAL (0) |
An optimal solution was obtained |
SUBOPTIMAL (1) |
The model is sub-optimal. Only happens if there are integer variables and there is already an integer solution found. The solution is not guaranteed the most optimal one.
- A timeout occured (set via set_timeout or with the -timeout option in lp_solve)
- set_break_at_first was called so that the first found integer solution is found (-f option in lp_solve)
- set_break_at_value was called so that when integer solution is found that is better than the specified value that it stops (-o option in lp_solve)
- set_mip_gap was called (-g/-ga/-gr options in lp_solve) to specify a MIP gap
- An abort function is installed (put_abortfunc) and this function returned TRUE
- At some point not enough memory could not be allocated
|
INFEASIBLE (2) |
The model is infeasible |
UNBOUNDED (3) |
The model is unbounded |
DEGENERATE (4) |
The model is degenerative |
NUMFAILURE (5) |
Numerical failure encountered |
USERABORT (6) |
The abort routine returned TRUE. See put_abortfunc |
TIMEOUT (7) |
A timeout occurred. A timeout was set via set_timeout |
PRESOLVED (9) |
The model could be solved by presolve. This can only happen if presolve is active via set_presolve |
ACCURACYERROR (25) |
Accuracy error encountered |
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
Remarks
The solve function solves the model. solve can be called more
than once. Between calls, the model may be modified in every way. Restrictions
may be changed, matrix values may be changed and even rows and/or columns may
be added or deleted.
If set_timeout was called before solve with a non-zero timeout
and a timout occurs, and there was already an integer solution found (that is possibly not the best),
then solve will return SUBOPTIMAL. If there was no integer solution found yet
or there are no integers or the solvers is still in the first phase where a REAL optimal solution is
searched for, then solve will return TIMEOUT.
If set_presolve was called before solve, then it can happen that
presolve eliminates all rows and columns such that the solution is known by presolve. In that
case, no solve is done. This also means that values of constraints and sensitivity are unknown.
solve will return PRESOLVED in this case.
Example
#include <stdio.h>
#include <stdlib.h>
#include "lp_lib.h"
int main(void)
{
lprec *lp;
int ret;
/* Create a new LP model */
lp = make_lp(0, 0);
if(lp == NULL) {
fprintf(stderr, "Unable to create new LP model\n");
return(1);
}
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, lag_solve, statustext, is_feasible,
get_objective, get_working_objective, get_variables,
get_ptr_variables, get_constraints,
get_ptr_constraints, get_constr_value, get_primal_solution,
get_ptr_primal_solution, get_var_primalresult,
get_sensitivity_rhs,
get_ptr_sensitivity_rhs, get_dual_solution, get_ptr_dual_solution, get_var_dualresult,
get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex,
get_ptr_sensitivity_objex
|