Try our new documentation site (beta).
GRBModel.addVars()
Add new decision variables to a model.
GRBVar[] | addVars ( | int | count, |
char | type ) |
-
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: Variable type for new variables (GRB.CONTINUOUS, GRB.BINARY, GRB.INTEGER, GRB.SEMICONT, or GRB.SEMIINT).
Return value:
Array of new variable objects.
GRBVar[] | addVars ( | double[] | lb, |
double[] | ub, | ||
double[] | obj, | ||
char[] | type, | ||
String[] | names ) |
-
Add new decision variables to a model. The number of
added variables is determined by the length of the input arrays
(which must be consistent across all arguments).
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.
Return value:
Array of new variable objects.
GRBVar[] | addVars ( | double[] | lb, |
double[] | ub, | ||
double[] | obj, | ||
char[] | type, | ||
String[] | names, | ||
int | start, | ||
int | len ) |
-
Add new decision variables to a model. This signature
allows you to use arrays to hold the various variable attributes
(lower bound, upper bound, etc.), without forcing you to add a
variable for each entry in the array. The
start
and
len
arguments allow you to specify which variables to add.
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.
start: The first variable in the list to add.
len: The number of variables to add.
Return value:
Array of new variable objects.
GRBVar[] | addVars ( | double[] | lb, |
double[] | ub, | ||
double[] | obj, | ||
char[] | type, | ||
String[] | names, | ||
GRBColumn[] | col ) |
-
Add new decision variables to a model. This signature
allows you to specify the list 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.
Return value:
Array of new variable objects.