Set the value of the right hand side (RHS) vector (column 0) for one row.

int set_rh(lprec *lp, int row, REAL value);

Return Value

set_rh returns TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error.



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


The row for which the RHS value must be set. Must be between 0 and number of rows in the lp.


The value of the RHS.


The set_rh function sets the value of the RHS vector (column 0) for the specified row.
Note that row can also be 0 with this function. In that case an initial value for the objective value is set. Functions set_rh_vec, str_set_rh_vec ignore row 0 (for historical reasons) in the specified RHS vector, but it is possible to first call one of these functions and then set the value of the objective with set_rh.


#include <stdio.h>
#include <stdlib.h>
#include "lpkit.h"

int main(void)
  lprec *lp;

  /* Create a new LP model */
  lp = make_lp(2, 0);
  if(lp == NULL) {
    fprintf(stderr, "Unable to create new LP model\n");

  set_rh(lp, 1, 1.0); /* sets the value 1.0 for RHS row 1 */


lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_lp_file, read_LP, read_mps, read_MPS, set_rh_vec, str_set_rh_vec, get_rh, add_constraint, add_column, get_column, get_row, get_mat, mat_elm