get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex

Returns the sensitivity of the objective function.

int get_sensitivity_obj(lprec *lp, REAL *objfrom, REAL *objtill);

int get_sensitivity_objex(lprec *lp, REAL *objfrom, REAL *objtill, REAL *objtillvalue);

int get_ptr_sensitivity_obj(lprec *lp, REAL **ptr_objfrom, REAL **ptr_objtill);

int get_ptr_sensitivity_objex(lprec *lp, REAL **ptr_objfrom, REAL **ptr_objtill, REAL *ptr_objtillvalue);

Return Value

get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex 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

objfrom

An array that will contain the values of the lower limits on the objective function.

ptr_objfrom

The address of a pointer that will point to an array that will contain the values of the lower limits of the objective function.

objtill

An array that will contain the values of the upper limits of the objective function.

ptr_objtill

The address of a pointer that will point to an array that will contain the values of the upper limits of the objective function.

objtillvalue

An array that will contain the values of the variables at their upper limit. Only applicable when the value of the variable is 0 (rejected).

ptr_objtillvalue

The address of a pointer that will point to an array that will contain the values of the variables at their upper limit. Only applicable when the value of the variable is 0 (rejected).

Remarks

The get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex functions return the sensitivity of the objective function.
These values are only valid after a successful solve. Functions get_sensitivity_obj, get_sensitivity_objex need arrays that are already dimensioned with get_Ncolumns elements. get_ptr_sensitivity_obj, get_ptr_sensitivity_objex returns a pointer to an array already dimensioned by lp_solve. Element 0 will contain the value of the first variable, element 1 of the second variable, ...
The meaning of these limits are the following. As long as the value of the coefficient of the objective function stays between the lower limit (objfrom) and the upper limit (objtill), the solution stays the same. Only the objective value itself changes with a value equal to the difference multiplied by the amount of this variable. If there is 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 objfrom[1+2], objtill[1+2], *ptr_objfrom, *ptr_objtill;

  /* 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_obj(lp, objfrom, objtill);
  get_ptr_sensitivity_obj(lp, &ptr_objfrom, &ptr_objtill);

  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_rhs, get_ptr_sensitivity_rhs,