get_basis
Returns the basis of the lp.
void get_basis(lprec *lp, int *bascolumn, unsigned char nonbasic);
Return Value
get_basis has no return value.
Parameters
lp
Pointer to previously created lp model. See return value of make_lp,
read_lp, read_LP, read_lpt,
read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI
bascolumn
An array with 1+get_Nrows or 1+get_Nrows+get_Ncolumns
elements that will contain the basis after the call.
nonbasic
If FALSE, then bascolumn must have 1+get_Nrows
elements and only contains the basic variables. It TRUE, then bascolumn must
have 1+get_Nrows+get_Ncolumns
elements and will also contain the non-basic variables.
Remarks
The get_basis function returns the basis of the lp.
The array receives the basic variables and if nonbasic is TRUE, then
also the non-basic variables. If an element is less then zero then it means on
lower bound, else on upper bound.
Element 0 of the array is unused.
The default initial basis is bascolumn[x] = -x.
Each element represents a basis variable. If the absolute value is between 1
and get_Nrows, it represents a slack variable and
if it is between get_Nrows+1 and
get_Nrows+get_Ncolumns then it
represents a regular variable. If the value is negative, then the variable is
on its lower bound. If positive it is on its upper bound.
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 or reset_basis is called.
Example
#include <stdio.h> #include
<stdlib.h> #include "lp_lib.h"
int main(void)
{
lprec *lp;
int bascolumn[1+2]; /* must be 1 more then number of rows ! */
/* Create a new LP model */
lp = make_lp(2, 0);
if(lp == NULL) {
fprintf(stderr, "Unable to create new LP model\n");
return(1);
}
get_basis(lp, bascolumn, FALSE);
delete_lp(lp);
return(0);
}
lp_solve API reference
See Also make_lp,
read_lp, read_LP, read_lpt, read_LPT, read_mps,
read_freemps, read_MPS, read_freeMPS, read_XLI, set_basis, reset_basis, default_basis, get_basiscrash, set_basiscrash
|