set_rh_vec, str_set_rh_vec

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

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

unsigned char str_set_rh_vec(lprec *lp, char *rh_string);

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.

Parameters

lp

Pointer to previously created lp model. See return value of make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

rh

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

rh_string

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 "lp_lib.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, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, set_rh, get_rh, add_constraint, add_constraintex, str_add_constraint, add_column, add_columnex, str_add_column, get_mat, get_column, get_columnex, set_column, set_columnex, get_row, get_rowex, set_row, set_rowex