QSopt QSchange_objcoef QSopt > Callable Library > Function List
  QSopt
  Downloads
  LP Info
  Software
  Problem Formats
  Callable Library
  Overview
Function List
  Rational Solver
  Beta
  Contact Info
Purpose
Change a coefficient in the objective function.
Synopsis
int QSchange_objcoef (QSprob p, int indx, double coef)
Arguments
p a handle to an initialized problem.
indx the index of the variable whose objective coefficient will be changed.
coef the new value of the coefficient.
Returns
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
Description

Use this function to change a single coefficient in the objective function; it can be used to modify an existing non-zero coefficient or to add a new non-zero coefficient to the objective.

Note that the function assumes that the column (variable) exists; use QSnew_col if the coefficient introduces a new column.

Example
/* Change the objective coefficient of variable y to 5.0   */

int rval = 0;
int yindex;

/* Find the index of of y */

rval = QSget_column_index (p, "y", &yindex);
if (rval) {
    fprintf (stderr, "could not get index, error code %d\n", rval);
} else {
    if (yindex == -1) {
        printf ("y is not a variable in the problem\n");
    } else {
        rval = QSchange_objcoef (p, yindex, 5.0);
        if (rval) {
            fprintf (stderr, "could not change coef, error %d\n", rval);
        }
    }
}
 
QSopt | Problem Formats | Downloads Back
Last Updated: November 2003