Documentation

GRBnewmodel


GRBnewmodel

int GRBnewmodel ( GRBenv *env,
    GRBmodel **modelP,
    const char *Pname,
    int numvars,
    double *obj,
    double *lb,
    double *ub,
    char *vtype,
    const char **varnames )

Create a new optimization model. This routine allows you to specify an initial set of variables (with objective coefficients, bounds, types, and names), but the initial model will have no constraints. Constraints can be added later with GRBaddconstr or GRBaddconstrs.

Return value:

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

Arguments:

env: The environment in which the new model should be created. Note that the new model will get a copy of this environment, so subsequent modifications to the original environment (e.g., parameter changes) won't affect the new model. Use GRBgetenv to modify the environment associated with a model.

modelP: The location in which the pointer to the new model should be placed.

Pname: The name of the model.

numvars: The number of variables in the model.

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.

Example usage:

  double obj[] = {1.0, 1.0};
  char *names[] = {"var1", "var2"};
  error = GRBnewmodel(env, &model, "New", 2, obj, NULL, NULL, NULL, names);