Gets the type of the variable. Binary integer or floating point.

unsigned char is_binary(lprec *lp, int column);

Return Value

is_binary returns TRUE (1) if the variable is set as binary, FALSE (0) otherwise.



Pointer to previously created lp model. See return value of make_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI


The column number of the variable that must be checked. It must be between 1 and the number of columns in the lp.


The is_binary function returns if a variable must be binary or not. Default a variable is not binary. A binary variable is an integer variable with lower bound 0 and upper bound 1. From the moment there is at least one integer variable in the model, the Branch and Bound algorithm is used to make these variables integer. Note that solving times can be considerably larger when there are integer variables. See integer variables for a description about integer variables.


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

int main(void)
  lprec *lp;
  int binary;

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

  binary = is_binary(lp, 1); /* will return 0 since the variable is not set as binary at this point */


lp_solve API reference

See Also make_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, set_binary, is_int, set_int