set_basis
Sets an initial basis of the lp.
void set_basis(lprec *lp, int *bascolumn);
Return Value
set_basis has no return value.
Parameters
lp
Pointer to previously created lp model. See return value of make_lp,
copy_lp, read_lp, read_lp_file,
read_LP, read_mps, read_MPS
bascolumn
An array with 1+rows elements that contains the initial basis.
Remarks
The set_basis function sets an initial basis of the lp.
The array specifies the basis 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 "lpkit.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);
}
bascolumn[0] = 0;
bascolumn[1] = -1;
bascolumn[2] = -2;
set_basis(lp, bascolumn);
delete_lp(lp);
return(0);
}
lp_solve API reference
See Also make_lp, copy_lp,
read_lp, read_lp_file, read_LP, read_mps,
read_MPS, get_basis, reset_basis
|