GRBModel::addVar()


GRBModel::addVar()

Add a single decision variable to a model.

GRBVar addVar ( double lb,
    double ub,
    double obj,
    char type,
    string name="" )

Add a variable; non-zero entries will be added later.

Arguments:

lb: Lower bound for new variable.

ub: Upper bound for new variable.

obj: Objective coefficient for new variable.

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

name (optional): Name for new variable.

Return value:

New variable object.

GRBVar addVar ( double lb,
    double ub,
    double obj,
    char type,
    int numnz,
    const GRBConstr* constrs,
    const double* coeffs,
    string name="" )

Add a variable, and the associated non-zero coefficients.

Arguments:

lb: Lower bound for new variable.

ub: Upper bound for new variable.

obj: Objective coefficient for new variable.

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

numnz: Number of constraints in which this new variable participates.

constrs: Array of constraints in which the variable participates.

coeffs: Array of coefficients for each constraint in which the variable participates.

name (optional): Name for new variable.

Return value:

New variable object.

GRBVar addVar ( double lb,
    double ub,
    double obj,
    char type,
    const GRBColumn& col,
    string name="" )

Add a variable, and the associated non-zero coefficients.

Arguments:

lb: Lower bound for new variable.

ub: Upper bound for new variable.

obj: Objective coefficient for new variable.

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

col: GRBColumn object for specifying a set of constraints to which new variable belongs.

name (optional): Name for new variable.

Return value:

New variable object.