get_variables, get_ptr_variables

Returns the values of the variables.

int get_variables(lprec *lp, REAL *var);

int get_ptr_variables(lprec *lp, REAL **ptr_var);

Return Value

get_variables, get_ptr_variables 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

var

An array that will contain the values of the variables.

ptr_var

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

Remarks

The get_variables, get_ptr_variables functions retrieve the values of the variables.
These values are only valid after a successful solve or lag_solve. Function get_variables needs an array that is already dimensioned with get_Ncolumns elements. get_ptr_variables 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, ...

Example

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

int main(void)
{
  lprec *lp;
  REAL var[2], *ptr_var;

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

  solve(lp);

  get_variables(lp, var);
  get_ptr_variables(lp, &ptr_var);

  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_constraints, get_ptr_constraints, get_primal_solution, get_ptr_primal_solution, get_work_solution, get_ptr_work_solution, 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