add_lag_con, str_add_lag_con

Add a Lagrangian constraint to the lp.

unsigned char add_lag_con(lprec *lp, REAL *row, int con_type, REAL rhs);

unsigned char str_add_lag_con(lprec *lp, char *row_string, int con_type, REAL rhs);

Return Value

add_lag_con and str_add_lag_con 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, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

row

An array with column elements that contains the values of the row.

row_string

A string with column elements that contains the values of the row. Each element must be separated by space(s).

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 (>=)

rhs

The value of the right hand side (RHS).

Remarks

The add_lag_con, str_add_lag_con functions adds a Lagrangian row to the model (at the end) and sets all values of the row at once.
Note that element 0 of the array is not considered (i.e. ignored). Column 1 is element 1, column 2 is element 2, ...

Example

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

int main(void)
{
  lprec *lp;
  REAL row[1+2]; /* must be 1 more then number of columns ! */

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

  row[1] = 1.0;
  row[2] = 1.0;
  add_lag_con(lp, row, LE, 1.0); /* constructs the Lagrangian row: +v_1 +v_2 <= 1 */

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, add_constraint, add_constraintex, str_add_constraint, set_row, set_rowex, set_obj_fn, set_obj_fnex, str_set_obj_fn, set_obj, get_con_type, del_constraint, add_column, add_columnex, str_add_column, set_column, set_columnex, get_column, get_row, get_mat, lag_solve, get_Lrows