get_constr_value

Gets the value of a constraint according to provided variable values.

REAL get_constr_value(lprec *lp, int row, int count, REAL *primsolution, int *nzindex);

Return Value

get_constr_value returns the value of the constraint as calculated with the provided variable values.

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

row

The row for which the constraint value must be calculated. Must be between 1 and number of rows in the lp.

count

The number of items in primsolution and nzindex.

primsolution

The values of the variables.

nzindex

The variable indexes.

Remarks

The get_constr_value function returns the value of a constraint according to provided variable values.
If primsolution is NULL, then the solution of the last solve is taken. count and nzindex are then ignored.
If primsolution is not NULL, and nzindex is NULL, then the variable values are taken from primsolution and element i must specify the value for variable i. Element 0 is not used and thus data starts from element 1. The variable must then contain 1+get_Ncolumns elements. count is ignored in that case.
If primsolution is not NULL, and nzindex is not NULL, then the variable values are taken from primsolution. nzindex contains the indexes of the variables and count specifies how many elements there are in primsolution and nzindex. So the data is then provided in a sparse vector. Elements start from index 0 in that case.

Example

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

int main(void)
{
  lprec *lp;
  int constr;

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

  solve(lp);

  printf("%f\n", get_constr_value(lp, 0, 0, NULL, NULL));

  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, get_constraints, get_ptr_constraints, get_variables, get_ptr_variables, get_primal_solution, get_ptr_primal_solution, get_var_primalresult