# set_row, set_rowex set a constraint in the lp. unsigned char set_row(lprec *lp, int row_no, REAL *row); unsigned char set_rowex(lprec *lp, int row_no, int count, REAL *row, int *colno); Return Value set_row, set_rowex return 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_no The row number that must be changed. count Number of elements in row and colno. row An array with 1+get_Ncolumns (count for set_rowex, if colno is different from NULL) elements that contains the values of the row. colno A zero-based array with count elements that contains the column numbers of the row. However this variable can also be NULL. In that case element i in the variable row is column i and values start at element 1. Remarks The set_row, set_rowex functions change the values of an existing row in the model at once. Note that add_constraint, add_constraintex, str_add_constraint add a row to the model, making the number of rows one larger. These functions change an existing row. Note that for set_row (and set_rowex when colno is NULL) element 1 of the array is column 1, element 2 is column 2, ... element 0 is not used. set_rowex has the possibility to specify only the non-zero elements. And in contrary to set_row, set_rowex reads the arrays starting from element 0. However when colno is NULL then set_rowex acts as set_row and then values start at element 1. When colno is provided, then it specifies the column numbers of the non-zero elements. This will speed up building the model considerably if there are a lot of zero values. In most cases the matrix is sparse and has many zero value. Thus it is almost always better to use set_rowex instead of set_row. set_rowex is always at least as performant as set_row. It is more performant to call these functions than multiple times set_mat. Note that unspecified values by set_rowex are set to zero. Note that these routines will perform much better when set_add_rowmode is called before adding constraints. Example
    #include <stdio.h>
    #include <stdlib.h>
    #include "lp_lib.h"

    int main(void)
    {
      lprec *lp;
      REAL row[1+3];     /* must be 1 more than number of columns ! */
      REAL sparserow[2]; /* must be the number of non-zero values */
      int colno[2];

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

      row[1] = 1.0;
      row[2] = 0.0; /* also zero elements must be provided */
      row[3] = 2.0;
      set_row(lp, 1, row); /* changes the values of existing row 1 */

      colno[0] = 1; sparserow[0] = 1.0; /* column 1 */
      colno[1] = 3; sparserow[1] = 2.0; /* column 3 */
      set_rowex(lp, 2, 2, sparserow, colno);

      delete_lp(lp);
      return(0);
    }
lp_solve API reference See Also make_lp, copy_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, get_row, get_rowex, add_constraint, add_constraintex, str_add_constraint, set_obj_fn, set_obj_fnex, str_set_obj_fn, set_obj, set_add_rowmode, is_add_rowmode, get_constr_type, is_constr_type, del_constraint, add_column, add_columnex, str_add_column, set_column, set_columnex, get_column, get_columnex, get_mat