add_column, str_add_column

Add a column to the lp.

int add_column(lprec *lp, REAL *column);

int str_add_column(lprec *lp, char *str_column);

Return Value

add_column and str_add_column returns TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error.
lp->spx_status specifies what error occurred.

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

column

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

str_row

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

Remarks

The add_column, str_add_column functions adds a column to the model (at the end) and sets all values of the column at once.
Note that element 0 of the array is the value of the objective function for that column. Column 1 is element 1, column 2 is element 2, ...

Example

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

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

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

  column[0] = 1.0;
  column[1] = 2.0;
  column[2] = 3.0;
  add_column(lp, column);

  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, set_obj_fn, str_set_obj_fn, del_column, add_constraint, str_add_constraint, get_column, get_row, get_mat, mat_elm, column_in_lp