GRBModel::addVars()

Add new decision variables to a model.

GRBVar* addVars ( int count,
    char type=GRB_CONTINUOUS )
    Add count new decision variables to a model. All associated attributes take their default values, except the variable type, which is specified as an argument.

    Arguments:

    count: Number of variables to add.

    type (optional): Variable type for new variables (GRB_CONTINUOUS, GRB_BINARY, GRB_INTEGER, GRB_SEMICONT, or GRB_SEMIINT).

    Return value:

    Array of new variable objects. Note that the result is heap-allocated, and must be returned to the heap by the user.

GRBVar* addVars ( const double* lb,
    const double* ub,
    const double* obj,
    const char* type,
    const string* names,
    int count )
    Add count new decision variables to a model. This signature allows you to use arrays to hold the various variable attributes (lower bound, upper bound, etc.).

    Arguments:

    lb: Lower bounds for new variables. Can be NULL, in which case the variables get lower bounds of 0.0.

    ub: Upper bounds for new variables. Can be NULL, in which case the variables get infinite upper bounds.

    obj: Objective coefficients for new variables. Can be NULL, in which case the variables get objective coefficients of 0.0.

    type: Variable types for new variables (GRB_CONTINUOUS, GRB_BINARY, GRB_INTEGER, GRB_SEMICONT, or GRB_SEMIINT). Can be NULL, in which case the variables are assumed to be continuous.

    names: Names for new variables. Can be NULL, in which case all variables are given default names.

    count: The number of variables to add.

    Return value:

    Array of new variable objects. Note that the result is heap-allocated, and must be returned to the heap by the user.

GRBVar* addVars ( const double* lb,
    const double* ub,
    const double* obj,
    const char* type,
    const string* names,
    const GRBColumn* cols,
    int count )
    Add new decision variables to a model. This signature allows you to specify the set of constraints to which each new variable belongs using an array of GRBColumn objects.

    Arguments:

    lb: Lower bounds for new variables. Can be NULL, in which case the variables get lower bounds of 0.0.

    ub: Upper bounds for new variables. Can be NULL, in which case the variables get infinite upper bounds.

    obj: Objective coefficients for new variables. Can be NULL, in which case the variables get objective coefficients of 0.0.

    type: Variable types for new variables (GRB_CONTINUOUS, GRB_BINARY, GRB_INTEGER, GRB_SEMICONT, or GRB_SEMIINT). Can be NULL, in which case the variables are assumed to be continuous.

    names: Names for new variables. Can be NULL, in which case all variables are given default names.

    cols: GRBColumn objects for specifying a set of constraints to which each new column belongs.

    count: The number of variables to add.

    Return value:

    Array of new variable objects. Note that the result is heap-allocated, and must be returned to the heap by the user.