Cookie Settings
Customize Consent Preferences
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

Other cookies are those that are being identified and have not been classified into any category as yet.

Try our new documentation site (beta).

Filter Content By
Version
Table of contents
Filter by Language
C API Details
C++ API Details
GRBModel +
Java API Details
GRBModel +
.NET API Details
GRBModel +
Python API Details
Model +
Attributes
Parameters
Parameter Descriptions +


GRBXloadmodel

int GRBXloadmodel ( GRBenv *env,
    GRBmodel **modelP,
    const char *Pname,
    int numvars,
    int numconstrs,
    int objsense,
    double objcon,
    double *obj,
    char *sense,
    double *rhs,
    size_t *vbeg,
    int *vlen,
    int *vind,
    double *vval,
    double *lb,
    double *ub,
    char *vtype,
    const char **varnames,
    const char **constrnames )

The size_t version of GRBloadmodel. The argument that counts non-zero values is of type size_t in this version to support models with more than 2 billion non-zero values.

Create a new optimization model, using the provided arguments to initialize the model data (objective function, variable bounds, constraint matrix, etc.). The model is then ready for optimization, or for modification (e.g., addition of variables or constraints, changes to variable types or bounds, etc.).

Return value:

A non-zero return value indicates that a problem occurred while creating the 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 gets 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 newly created model should be placed.

Pname: The name of the model.

numvars: The number of variables in the model.

numconstrs: The number of constraints in the model.

objsense: The sense of the objective function. Allowed values are 1 (minimization) or -1 (maximization).

objcon: Constant objective offset.

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

sense: The senses of the new constraints. Options are '=' (equal), '<' (less-than-or-equal), or '>' (greater-than-or-equal). You can also use constants GRB_EQUAL, GRB_LESS_EQUAL, or GRB_GREATER_EQUAL.

rhs: Right-hand side values for the new constraints. This argument can be NULL, in which case the right-hand side values are set to 0.0.

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 and vlen value, indicating the start position of the non-zeros for that variable in the vind and vval arrays, and the number of non-zero values for that variable, respectively. Thus, for example, if vbeg[2] = 10 and vlen[2] = 2, 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].

vlen: Number of constraint matrix non-zero values associated with each variable. See the description of the vbeg argument for more information.

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.

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.

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

Important notes:

We recommend that you build a model one constraint or one variable at a time, using GRBaddconstr or GRBaddvar, rather than using this routine to load the entire constraint matrix at once. It is much simpler, less error prone, and it introduces no significant overhead.

Example usage:

  /* maximize    x +   y + 2 z
     subject to  x + 2 y + 3 z <= 4
                 x +   y       >= 1
     x, y, z binary */

  int    vars    = 3;
  int    constrs = 2;
  size_t vbeg[]  = {0, 2, 4};
  int    vlen[]  = {2, 2, 1};
  int    vind[]  = {0, 1, 0, 1, 0};
  double vval[]  = {1.0, 1.0, 2.0, 1.0, 3.0};
  double obj[]   = {1.0, 1.0, 2.0};
  char   sense[] = {GRB_LESS_EQUAL, GRB_GREATER_EQUAL};
  double rhs[]   = {4.0, 1.0};
  char   vtype[] = {GRB_BINARY, GRB_BINARY, GRB_BINARY};

  error = GRBXloadmodel(env, &model, "example", vars, constrs, -1, 0.0,
                        obj, sense, rhs, vbeg, vlen, vind, vval,
                        NULL, NULL, vtype, NULL, NULL);