set_mat

Set a single element in the matrix.

int set_mat(lprec *lp, int row, int column, REAL value);

Return Value

set_mat 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

row

Row number of the matrix. Must be between 0 and number of rows in the lp. Row 0 is objective function.

column

Column number of the matrix. Must be between 1 and number of columns in the lp.

value

Value to be set for row row, column column.

Remarks

The set_mat function sets a value in the matrix. If there was already a value for this element, it is replaced and if there was no value, it is added.
This function is not efficient if many values are to be set. Consider to use add_constraint, str_add_constraint, str_set_obj_fn, str_set_obj_fn, add_column, str_add_column.

Example

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

int main(void)
{
  lprec *lp;

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

  set_mat(lp, 1, 2, 3.1415927);

  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, add_constraint, str_set_obj_fn, str_set_obj_fn, add_column, get_column, get_row, get_mat, mat_elm