set_uprange
Set the upper range on a constraint.
int set_uprange(lprec *lp, int row, REAL value);
Return Value
set_uprange returns TRUE (1) if the operation was successful. A return
value of FALSE (0) indicates an error.
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
row
The row number of the constraint on which the range must be set.
It must be between 1 and the number of rows in the lp.
Remarks
The set_uprange function sets an upper range on the constraint (row)
identified by row.
Setting a range on a row is the way to go instead of adding an extra constraint
(row) to the model. Setting a range doesn't increase the model size that means
that the model stays smaller and will be solved faster.
An upper range will be set if the constraint is a greater than constraint. This
upper range has the same effect as adding an extra row to the model with a less
than constraint and a RHS equal to the value of the RHS plus this range.
However the range is more performant since no extra row must be created.
Note that the range must be the difference between the maximum that must be set
and the minimum that is already set in the RHS.
Example
#include <stdio.h>
#include <stdlib.h>
#include "lpkit.h"
int main(void)
{
lprec *lp;
/* Create a new LP model */
lp = make_lp(1, 1);
if(lp == NULL) {
fprintf(stderr, "Unable to create new LP model\n");
return(1);
}
set_uprange(lp, 1, 1.0);
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, set_rh_range, get_rh_range, set_lowrange
|