set_rh_vec, str_set_rh_vec

Set the right hand side (RHS) vector (column 0).

void set_rh_vec(lprec *lp, REAL *rh);

int str_set_rh_vec(lprec *lp, char *str_rh);

Return Value

set_rh_vec has no return value. str_set_rh_vec returns TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error.
lp->spx_status specifies what error occurred.

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

rh

An array with row elements that contains the values of the RHS.

str_row

A string with row elements that contains the values of the RHS. Each element must be separated by space(s).

Remarks

The set_rh_vec, str_set_rh_vec functions set all values of the RHS vector (column 0) at once.
Note that element 0 of the array is not considered (i.e. ignored). Row 1 is element 1, row 2 is element 2, ...
If the initial value of the objective function must also be set, use set_rh.

Example

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

int main(void)
{
  lprec *lp;
  REAL rhs[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);
  }

  rhs[1] = 1.0;
  rhs[2] = 2.0;
  set_rh_vec(lp, rhs);

  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, get_rh, add_constraint, add_column, get_mat, mat_elm, get_column, get_row