get_work_solution, get_ptr_work_solution

Returns the solution vector of the active lp.

int get_work_solution(lprec *lp, REAL *wv);

int get_ptr_work_solution(lprec *lp, REAL **ptr_wv);

Return Value

get_work_solution, get_ptr_work_solution 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_file, read_LP, read_mps, read_MPS

wv

An array that will contain the value of the objective function (element 0), values of the constraints (elements 1 till Nrows), and the values of the variables (elements Nrows+1 till Nrows+NColumns).

ptr_wv

The address of a pointer that will point to an array that will contain the value of the objective function (element 0), values of the constraints (elements 1 till Nrows), and the values of the variables (elements Nrows+1 till Nrows+NColumns).

Remarks

The get_work_solution, get_ptr_work_solution functions retrieve the values of the objective function, constraints and variables of an individual simplex problem. There is no difference between this and get_primal_solution, get_ptr_primal_solution if the model is pure LP, but in case of integer restrictions, the branch and bound algorithm is used which creates multiple sub-simplex models and get_work_solution, get_ptr_work_solution then returns the solution of the current working model.
Function get_work_solution needs an array that is already dimensioned with 1 + get_Nrows + get_Ncolumns elements. get_ptr_work_solution returns a pointer to an array already dimensioned by lp_solve. Element 0 is the value of the objective function, elements 1 till Nrows the values of the constraints and elements Nrows+1 till Nrows+NColumns the values of the variables.

Example

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

int main(void)
{
  lprec *lp;
  REAL wv[1+2+3], *ptr_wv;

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

  solve(lp);

  get_work_solution(lp, wv);
  get_ptr_work_solution(lp, &ptr_wv);

  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_constraints, get_ptr_constraints, get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_reduced_costs, get_ptr_reduced_costs, get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex, get_primal_solution, get_ptr_primal_solution