get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_reduced_costs, get_ptr_reduced_costs

Returns the sensitivity of the constraints and the variables.

int get_sensitivity_rhs(lprec *lp, REAL *duals, REAL *dualsfrom, REAL *dualstill);

int get_ptr_sensitivity_rhs(lprec *lp, REAL **ptr_duals, REAL **ptr_dualsfrom, REAL **ptr_dualstill);

int get_reduced_costs(lprec *lp, REAL *duals);

int get_ptr_reduced_costs(lprec *lp, REAL **ptr_duals);

Return Value

get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_reduced_costs, get_ptr_reduced_costs return 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

duals

An array that will contain the values of the dual variables aka reduced costs.

ptr_duals

The address of a pointer that will point to an array that will contain the values of the dual variables aka reduced costs.

dualsfrom

An array that will contain the values of the lower limits on the dual variables aka reduced costs.

ptr_dualsfrom

The address of a pointer that will point to an array that will contain the values of the lower limits of the dual variables aka reduced costs.

dualstill

An array that will contain the values of the upper limits on the dual variables aka reduced costs.

ptr_dualstill

The address of a pointer that will point to an array that will contain the values of the upper limits of the dual variables aka reduced costs.

Remarks

The get_sensitivity_rhs, get_ptr_sensitivity_rhs functions return the values of the dual variables aka reduced costs and their limits. The get_reduced_costs, get_ptr_reduced_costs function returns only the values of the dual variables aka reduced costs. It is there for backwards compatibility.
These values are only valid after a successful solve. Functions get_sensitivity_rhs and get_reduced_costs need arrays that are already dimensioned with get_Nrows+get_Ncolumns elements. get_ptr_sensitivity_rhs, get_ptr_reduced_costs returns a pointer to an array already dimensioned by lp_solve. For functions get_sensitivity_rhs and get_ptr_sensitivity_rhs, Element 0 will contain the value of the first row, element 1 of the second row, ... Element get_Nrows contains the value for the first variable, element get_Nrows+1 the value for the second variable and so on. For functions get_reduced_costs, get_ptr_reduced_costs the index starts from 1 and element 0 is not used.
The dual values or reduced costs values indicate that the objective function will change with the value of the reduced cost if the restriction is changed with 1 unit. There will only be a reduced cost if the value is bounded by the restriction, else it is zero. Note that the sign indicates if the objective function will increase or decrease. The reduced costs remains constant as long as the restriction stays within the lower/upper range also provided with these functions (dualsfrom, dualstill). If there is no reduced cost, or no lower/upper limit, then these values are (-)infinity.

Example

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

int main(void)
{
  lprec *lp;
  REAL duals[1+2], dualsfrom[1+2], dualstill[1+2], *ptr_duals, *ptr_dualsfrom, *ptr_dualstill;

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

  str_set_obj_fn(lp, "1 1");
  str_add_constraint(lp, "2 4", GE, 10);
  set_lowbo(lp, 1, 1);

  solve(lp);

  get_sensitivity_rhs(lp, duals, dualsfrom, dualstill);
  get_ptr_sensitivity_rhs(lp, &ptr_duals, &ptr_dualsfrom, &ptr_dualstill);

  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, is_feasible, get_objective, get_variables, get_ptr_variables, get_primal_solution, get_ptr_primal_solution, get_work_solution, get_ptr_work_solution, get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex,