NO FRAMES

CPXnewrows

public int CPXnewrows(CPXCENVptr env, CPXLPptr lp, int rcnt, const double * rhs, const char * sense, const double * rngval, char ** rowname)
Definition file: cplex.h

The routine CPXnewrows adds empty constraints to a specified CPLEX problem object. This routine may be called any time after a call to CPXcreateprob.

For each row, the user can specify the sense, righthand side value, range value and name of the constraint. The added rows are indexed to put them at the end of the problem. Thus, if rcnt rows are added to a problem object already having k rows, the new rows have indices k, k+1, ... k+rcnt-1. The constraint coefficients in the new rows are zero; the constraint coefficients can be changed with calls to CPXchgcoef, CPXchgcoeflist or CPXaddcols.

Table 1: Settings for elements of the array sense
sense[i]= 'L'<= constraint
sense[i]= 'E'= constraint
sense[i]= 'G'>= constraint
sense[i]= 'R'ranged constraint

Example

 status = CPXnewrows (env, lp, rcnt, rhs, sense, NULL, newrowname);

See also the example lpex1.c in the ILOG CPLEX User's Manual and in the standard distribution.

Parameters:

env

A pointer to the CPLEX environment as returned by CPXopenCPLEX.

lp

A pointer to a CPLEX problem object as returned by CPXcreateprob.

rcnt

An integer that specifies the number of new rows to be added to the problem object.

rhs

An array of length rcnt containing the righthand side term for each constraint to be added to the problem object. May be NULL, in which case the righthand side terms are set to 0.0 for the new constraints.

sense

An array of length rcnt containing the sense of each constraint to be added to the problem object. This array may be NULL, in which case the sense of each constraint is set to 'E' The values of the elements of this array appear in Table 1.

rngval

An array of length rcnt containing the range values for the new constraints. If a new constraint has sense[i]='R', the value of constraint i can be between rhs[i] and rhsi[i]+rngval[i]. May be NULL, in which case the range values are all set to zero.

rowname

An array of length rcnt containing pointers to character strings that represent the names of the new rows, or equivalently, the constraint names. May be NULL, in which case the new rows are assigned default names if the rows already resident in the problem object have names; otherwise, no names are associated with the constraints. If row names are passed to CPXnewrows but existing constraints have no names assigned, default names are created for the existing constraints.

Returns:

The routine returns zero if successful and nonzero if an error occurs.