set_constr_type

Set the type of a constraint.

unsigned char set_constr_type(lprec *lp, int row, int con_type);

Return Value

set_constr_type 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, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

row

The row for which the constraint type must be set. Must be between 1 and number of rows in the lp.

con_type

The type of the constraint. Can by any of the following values:

LE (1) Less than or equal (<=)
EQ (3) Equal (=)
GE (2) Greater than or equal (>=)
FR (0) Free

Remarks

The set_constr_type function sets the constraint type for the specified row.
The default constraint type is LE.
Note the free (FR) constraint type. This is new from version 5.1.0.1
A free constraint will act as if the constraint is not there. The lower bound is -Infinity and the upper bound is +Infinity.
This can be used to temporary disable a constraint without having to delete it from the model. Note that the already set RHS and range on this constraint is overruled with Infinity by this.

Example

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

int main(void)
{
  lprec *lp;

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

  set_constr_type(lp, 1, GE);

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, get_constr_type, is_constr_type, add_constraint, add_constraintex, str_add_constraint, del_constraint