# Documentation

Filter Content By
Version
Languages

### GRBXaddvars

 int GRBXaddvars ( GRBmodel *model, int numvars, size_t numnz, size_t *vbeg, int *vind, double *vval, double *obj, double *lb, double *ub, char *vtype, const char **varnames )

The size_t version of GRBaddvars. The two arguments that count non-zero values are of type size_t in this version to support models with more than 2 billion non-zero values.

Add new variables to a model. Note that, due to our lazy update approach, the new variables won't actually be added until you update the model (using GRBupdatemodel), optimize the model (using GRBoptimize), or write the model to disk (using GRBwrite).

Return value:

A non-zero return value indicates that a problem occurred while adding the variables. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.

Arguments:

model: The model to which the new variables should be added.

numvars: The number of new variables to add.

numnz: The total number of non-zero coefficients in the new columns.

vbeg: Constraint matrix non-zero values are passed into this routine in Compressed Sparse Column (CSC) format. Each column in the constraint matrix is represented as a list of index-value pairs, where each index entry provides the constraint index for a non-zero coefficient, and each value entry provides the corresponding non-zero value. Each variable in the model has a vbeg, indicating the start position of the non-zeros for that variable in the vind and vval arrays. This routine requires columns to be stored contiguously, so the start position for a variable is the end position for the previous variable. To give an example, if vbeg[2] = 10 and vbeg[3] = 12, that would indicate that variable 2 has two non-zero values associated with it. Their constraint indices can be found in vind[10] and vind[11], and the numerical values for those non-zeros can be found in vval[10] and vval[11].

vind: Constraint indices associated with non-zero values. See the description of the vbeg argument for more information.

vval: Numerical values associated with constraint matrix non-zeros. See the description of the vbeg argument for more information.

obj: Objective coefficients for the new variables. This argument can be NULL, in which case the objective coefficients are set to 0.0.

lb: Lower bounds for the new variables. This argument can be NULL, in which case all variables get lower bounds of 0.0.

ub: Upper bounds for the new variables. This argument can be NULL, in which case all variables get infinite upper bounds.

vtype: Types for the variables. Options are GRB_CONTINUOUS, GRB_BINARY, GRB_INTEGER, GRB_SEMICONT, or GRB_SEMIINT. This argument can be NULL, in which case all variables are assumed to be continuous.

varnames: Names for the new variables. This argument can be NULL, in which case all variables are given default names.