get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_dual_solution, get_ptr_dual_solution, get_var_dualresult

# get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_dual_solution, get_ptr_dual_solution, get_var_dualresult Returns the sensitivity of the constraints and the variables. unsigned char get_sensitivity_rhs(lprec *lp, REAL *duals, REAL *dualsfrom, REAL *dualstill); unsigned char get_ptr_sensitivity_rhs(lprec *lp, REAL **ptr_duals, REAL **ptr_dualsfrom, REAL **ptr_dualstill); unsigned char get_dual_solution(lprec *lp, REAL *duals); unsigned char get_ptr_dual_solution(lprec *lp, REAL **ptr_duals); REAL get_var_dualresult(lprec *lp, int index); Return Value get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_dual_solution, get_ptr_dual_solution return TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error. get_var_dualresult returns the reduced cost. 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 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. index The column of the variable for which the reduced cost is required. Note that this is the column number before presolve was done, if active. If index is 0, then the value of the objective function is returned by get_var_dualresult 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_dual_solution, get_ptr_dual_solution, get_var_dualresult functions return only the value(s) of the dual variables aka reduced costs. These values are only valid after a successful solve and if there are integer variables in the model then only if set_presolve is called before solve with parameter PRESOLVE_SENSDUALS. Function get_sensitivity_rhs needs an array that is already dimensioned with get_Nrows+get_Ncolumns elements. Function get_dual_solution needs an array that is already dimensioned with 1+get_Nrows+get_Ncolumns elements. get_ptr_sensitivity_rhs and get_ptr_dual_solution return 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_dual_solution and get_ptr_dual_solution the index starts from 1 and element 0 is not used. The first get_Nrows elements contain the duals of the constraints, the next get_Ncolumns elements contain the duals of the variables. 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. Note that get_ptr_sensitivity_rhs and get_ptr_dual_solution return a pointer to memory allocated and maintained by lp_solve. Be careful what you do with it. Don't modify its contents or free the memory. Unexpected behaviour would occur. Also note that this memory pointer is only guaranteed to remain constant until a next lp_solve API call is done. You should call this function again to make sure you have again the correct pointer. Otherwise, this pointer could point to invalid memory. This should not be a problem since this call is very efficient. Example
    #include <stdio.h>
    #include <stdlib.h>
    #include "lp_lib.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, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, is_feasible, get_objective, get_working_objective, get_variables, get_ptr_variables, get_primal_solution, get_ptr_primal_solution, get_var_primalresult, get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex,