Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::Gurobi Class Reference

#include <g_gurobi.h>

Classes

class  CallbackContext
 
struct  SparseMat
 

Public Types

using Callback = std::function<absl::Status(const CallbackContext&)>
 

Public Member Functions

 ~Gurobi ()
 
absl::Status AddVar (double obj, double lb, double ub, char vtype, const std::string &name)
 Calls GRBaddvar() to add a variable to the model.
 
absl::Status AddVar (absl::Span< const int > vind, absl::Span< const double > vval, double obj, double lb, double ub, char vtype, const std::string &name)
 
have size equal to the number of new be empty (all new variables have objective coefficient 0). - have size equal to the number of new variables
 
have size equal to the number of new be be empty(all new variables have name ""). absl have size equal to the number of new be empty (all new variables have objective coefficient 0). - have size equal to the number of new variables
 
have size equal to the number of new be be empty(all new variables have name ""). absl have size equal to the number of new be be empty(all new variables have name ""). absl absl::Status DelVars (absl::Span< const int > ind)
 Calls GRBdelvars().
 
absl::Status AddConstr (char sense, double rhs, const std::string &name)
 
absl::Status AddConstr (absl::Span< const int > cind, absl::Span< const double > cval, char sense, double rhs, const std::string &name)
 
have size equal to the number of new be empty(all new constraints have name ""). absl absl::Status DelConstrs (absl::Span< const int > ind)
 Calls GRBdelconstrs().
 
absl::Status ChgCoeffs (absl::Span< const int > cind, absl::Span< const int > vind, absl::Span< const double > val)
 
absl::Status AddQpTerms (absl::Span< const int > qrow, absl::Span< const int > qcol, absl::Span< const double > qval)
 
absl::Status DelQ ()
 
absl::Status SetNthObjective (int index, int priority, double weight, double abs_tol, double rel_tol, const std::string &name, double constant, absl::Span< const int > lind, absl::Span< const double > lval)
 
absl::Status AddQConstr (absl::Span< const int > lind, absl::Span< const double > lval, absl::Span< const int > qrow, absl::Span< const int > qcol, absl::Span< const double > qval, char sense, double rhs, const std::string &name)
 
absl::Status DelQConstrs (absl::Span< const int > ind)
 
absl::Status AddSos (absl::Span< const int > types, absl::Span< const int > beg, absl::Span< const int > ind, absl::Span< const double > weight)
 
absl::Status DelSos (absl::Span< const int > ind)
 
absl::Status AddIndicator (const std::string &name, int binvar, int binval, absl::Span< const int > ind, absl::Span< const double > val, char sense, double rhs)
 
absl::Status DelGenConstrs (absl::Span< const int > ind)
 
absl::StatusOr< int > GetNnz (int first_var, int num_vars)
 
absl::Status GetVars (absl::Span< int > vbegin, absl::Span< int > vind, absl::Span< double > vval, int first_var, int num_vars)
 
absl::StatusOr< SparseMatGetVars (int first_var, int num_vars)
 
absl::Status UpdateModel ()
 Calls GRBupdatemodel().
 
absl::Status Optimize (Callback cb=nullptr)
 
void Terminate ()
 Calls GRBterminate().
 
absl::StatusOr< bool > ComputeIIS (Callback cb=nullptr)
 
bool IsAttrAvailable (const char *name) const
 
absl::StatusOr< int > GetIntAttr (const char *name) const
 
absl::Status SetIntAttr (const char *attr_name, int value)
 
absl::StatusOr< double > GetDoubleAttr (const char *name) const
 
absl::Status SetDoubleAttr (const char *attr_name, double value)
 
absl::StatusOr< std::string > GetStringAttr (const char *name) const
 
absl::Status SetStringAttr (const char *attr_name, const std::string &value)
 
absl::Status GetIntAttrArray (const char *name, absl::Span< int > attr_out) const
 
absl::StatusOr< std::vector< int > > GetIntAttrArray (const char *name, int len) const
 
absl::Status SetIntAttrArray (const char *name, absl::Span< const int > new_values)
 
absl::Status SetIntAttrList (const char *name, absl::Span< const int > ind, absl::Span< const int > new_values)
 
absl::Status GetDoubleAttrArray (const char *name, absl::Span< double > attr_out) const
 
absl::StatusOr< std::vector< double > > GetDoubleAttrArray (const char *name, int len) const
 
absl::Status SetDoubleAttrArray (const char *name, absl::Span< const double > new_values)
 
absl::Status SetDoubleAttrList (const char *name, absl::Span< const int > ind, absl::Span< const double > new_values)
 
absl::Status GetCharAttrArray (const char *name, absl::Span< char > attr_out) const
 
absl::StatusOr< std::vector< char > > GetCharAttrArray (const char *name, int len) const
 
absl::Status SetCharAttrArray (const char *name, absl::Span< const char > new_values)
 
absl::Status SetCharAttrList (const char *name, absl::Span< const int > ind, absl::Span< const char > new_values)
 
absl::StatusOr< int > GetIntAttrElement (const char *name, int element) const
 
absl::Status SetIntAttrElement (const char *name, int element, int new_value)
 
absl::StatusOr< double > GetDoubleAttrElement (const char *name, int element) const
 
absl::Status SetDoubleAttrElement (const char *name, int element, double new_value)
 
absl::StatusOr< char > GetCharAttrElement (const char *name, int element) const
 
absl::Status SetCharAttrElement (const char *name, int element, char new_value)
 
absl::Status SetParam (const char *name, const std::string &value)
 
absl::Status SetIntParam (const char *name, int value)
 Calls GRBsetintparam().
 
absl::Status SetDoubleParam (const char *name, double value)
 Calls GRBsetdblparam().
 
absl::Status SetStringParam (const char *name, const std::string &value)
 Calls GRBsetstrparam().
 
absl::StatusOr< int > GetIntParam (const char *name)
 Calls GRBgetintparam().
 
absl::StatusOr< double > GetDoubleParam (const char *name)
 Calls GRBgetdblparam().
 
absl::StatusOr< std::string > GetStringParam (const char *name)
 Calls GRBgetstrparam().
 
absl::Status ResetParameters ()
 Calls GRBresetparams().
 
GRBmodelmodel () const
 Typically not needed.
 
absl::Status ToStatus (int grb_err, absl::StatusCode code=absl::StatusCode::kInvalidArgument, absl::SourceLocation loc=absl::SourceLocation::current()) const
 

Static Public Member Functions

static absl::StatusOr< std::unique_ptr< Gurobi > > New (GRBenvUniquePtr primary_env=nullptr)
 
static absl::StatusOr< std::unique_ptr< Gurobi > > NewWithSharedPrimaryEnv (GRBenv *primary_env)
 

Public Attributes

have size equal to the number of new variables
 
have size equal to the number of new be be empty(all new variables have name ""). absl have size equal to the number of new variables
 
have size equal to the number of new constraints
 

Detailed Description

Models and solves optimization problems with Gurobi.

This is a thin wrapper on the Gurobi C API, holding a GRBmodel, associated GRBenv that GRBnewmodel creates, and optionally the primary environment to clean up on deletion.

Throughout, we refer to the child GRBenv created by GRBnewmodel as the "model environment" while the GRBenv that was used to create the model as the "primary environment", for details see: https://www.gurobi.com/documentation/9.1/refman/c_newmodel.html Attributes Most properties of a Gurobi optimization model are set and read with attributes, using the attribute names defined in the Gurobi C API. There are scalar attributes returning a single value of the following types:

  • int, e.g. GRB_INT_ATTR_MODELSENSE
  • double, e.g. GRB_DBL_ATTR_OBJVAL
  • string, e.g. GRB_STR_ATTR_MODELNAME and array attributes returning a list of values of the following types:
  • int array, e.g. GRB_INT_ATTR_BRANCHPRIORITY
  • double array, e.g. GRB_DBL_ATTR_LB
  • char array, e.g. GRB_CHAR_ATTR_VTYPE

You set a scalar attribute with the methods SetXXXAttr, e.g. std::unique_ptr<Gurobi> gurobi = Gurobi::New().value(); absl::Status s = gurobi->SetIntAttr(GRB_INT_ATTR_MODELSENSE, 1);

Note
not all attributes can be set; consult the Gurobi attribute docs.

Attributes can also be read. However, attributes can be unavailable depending on the context, e.g. the solution objective value is not available before solving. You can determine when an attribute is available either from the Gurobi documentation or by directly testing: std::unique_ptr<Gurobi> gurobi = Gurobi::New().value(); bool is_avail = gurobi->IsAttrAvailable(GRB_DBL_ATTR_OBJVAL); To read an attribute: std::unique_ptr<Gurobi> gurobi = Gurobi::New().value(); absl::StatusOr<double> obj = gurobi->GetDoubleAttr(GRB_DBL_ATTR_OBJVAL); (The method should succeed when IsAttrAvailable() is true and you have specified the type of attribute correctly.)

Array attributes are similar, but the API differs slightly. E.g. to set the first three variable lower bounds to 1.0: std::unique_ptr<Gurobi> gurobi = Gurobi::New().value(); absl::Status s = gurobi->SetDoubleAttrArray(GRB_DBL_ATTR_LB, {1, 1, 1}); You can also set specific indices, see SetDoubleAttrList. To read, use: Gurobi* gurobi = ...; int num_vars = ...; absl::StatusOr<std::vector<double>> lbs = gurobi->GetDoubleAttrArray(GRB_DBL_ATTR_LB, num_vars); An overload to write the result into an absl::Span is also provided.

Warning
as with the Gurobi C API, attributes cannot be read immediately after they have been set. You need to call UpdateModel() (which is called by Optimize()) before reading the model back. E.g. std::unique_ptr<Gurobi> gurobi = Gurobi::New().value(); CHECK_OK(gurobi->AddVars({1, 1}, {0, 0}, {1, 1}, {GRB_INTEGER, GRB_INTEGER}, {"x", "y"})); int num_vars = gurobi->GetIntAttr(GRB_INT_ATTR_NUMVARS).value(); ///< Is 0. CHECK_OK(gurobi->UpdateModel()); num_vars = gurobi->GetIntAttr(GRB_INT_ATTR_NUMVARS).value(); ///< Is now 2. Calls to UpdateModel() are expensive and should be minimized. Parameters Parameters are associated directly with Gurobi rather than a GRBenv as in the C API. Parameters have three types: int, double and string. You can get and set them by their C API names, e.g. std::unique_ptr<Gurobi> gurobi = Gurobi::New().value(); gurobi->SetIntParam(GRB_INT_PAR_LOGTOCONSOLE, 1); gurobi->GetIntParam(GRB_INT_PAR_LOGTOCONSOLE); ///< Returns 1. Unlike attributes, values can be read immediately, no call to UpdateModel() is required.

Definition at line 149 of file g_gurobi.h.

Member Typedef Documentation

◆ Callback

using operations_research::math_opt::Gurobi::Callback = std::function<absl::Status(const CallbackContext&)>

Invoked regularly by Gurobi while solving if provided as an argument to Gurobi::Optimize(). If the user returns a status error in the callback:

  • Termination of the solve is requested.
  • The error is propagated to the return value of Gurobi::Optimize().
  • The callback will not be invoked again.

Definition at line 222 of file g_gurobi.h.

Constructor & Destructor Documentation

◆ ~Gurobi()

operations_research::math_opt::Gurobi::~Gurobi ( )

Definition at line 225 of file g_gurobi.cc.

Member Function Documentation

◆ AddConstr() [1/2]

absl::Status operations_research::math_opt::Gurobi::AddConstr ( absl::Span< const int > cind,
absl::Span< const double > cval,
char sense,
double rhs,
const std::string & name )

Calls GRBaddconstr() to add a constraint to the model.

The inputs cind and cval must have the same size.

Definition at line 324 of file g_gurobi.cc.

◆ AddConstr() [2/2]

absl::Status operations_research::math_opt::Gurobi::AddConstr ( char sense,
double rhs,
const std::string & name )

Calls GRBaddconstr() to add a constraint to the model.

This overload does not add any variable coefficients to the constraint.

Definition at line 319 of file g_gurobi.cc.

◆ AddIndicator()

absl::Status operations_research::math_opt::Gurobi::AddIndicator ( const std::string & name,
int binvar,
int binval,
absl::Span< const int > ind,
absl::Span< const double > val,
char sense,
double rhs )

Calls GRBaddgenconstrIndicator().

ind and val must be of equal length.

Definition at line 458 of file g_gurobi.cc.

◆ AddQConstr()

absl::Status operations_research::math_opt::Gurobi::AddQConstr ( absl::Span< const int > lind,
absl::Span< const double > lval,
absl::Span< const int > qrow,
absl::Span< const int > qcol,
absl::Span< const double > qval,
char sense,
double rhs,
const std::string & name )

Calls GRBaddqconstr().

Requirements:

  • lind and lval must be equal length.
  • qrow, qcol, and qval must be equal length.

Definition at line 402 of file g_gurobi.cc.

◆ AddQpTerms()

absl::Status operations_research::math_opt::Gurobi::AddQpTerms ( absl::Span< const int > qrow,
absl::Span< const int > qcol,
absl::Span< const double > qval )

Calls GRBaddqpterms().

Requirements:

  • qrow, qcol, and qval have size equal to the number of new quadratic objective terms.

Definition at line 366 of file g_gurobi.cc.

◆ AddSos()

absl::Status operations_research::math_opt::Gurobi::AddSos ( absl::Span< const int > types,
absl::Span< const int > beg,
absl::Span< const int > ind,
absl::Span< const double > weight )

Calls GRBaddsos().

This adds SOS constraints to the model. You may specify multiple SOS constraints at once, and may mix the types (SOS1 and SOS2) in a single call. The data is specified in CSR format, meaning that the entries of beg indicate the contiguous subranges of ind and weight associated with a particular SOS constraint. Please see the Gurobi documentation for more detail (https://www.gurobi.com/documentation/9.5/refman/c_addsos.html).

Requirements:

  • types and beg must be of equal length.
  • ind and weight must be of equal length.

Definition at line 435 of file g_gurobi.cc.

◆ AddVar() [1/2]

absl::Status operations_research::math_opt::Gurobi::AddVar ( absl::Span< const int > vind,
absl::Span< const double > vval,
double obj,
double lb,
double ub,
char vtype,
const std::string & name )

Calls GRBaddvar() to add a variable and linear constraint column to the model.

The inputs vind and vval must have the same size. Both can be empty if you do not want to modify the constraint matrix, though this is equivalent to the simpler overload above.

Definition at line 249 of file g_gurobi.cc.

◆ AddVar() [2/2]

absl::Status operations_research::math_opt::Gurobi::AddVar ( double obj,
double lb,
double ub,
char vtype,
const std::string & name )

Calls GRBaddvar() to add a variable to the model.

Model Building

Definition at line 244 of file g_gurobi.cc.

◆ ChgCoeffs()

absl::Status operations_research::math_opt::Gurobi::ChgCoeffs ( absl::Span< const int > cind,
absl::Span< const int > vind,
absl::Span< const double > val )

Calls GRBchgcoeffs().

Requirements:

  • cind, vind, and val have size equal to the number of changed constraint matrix entries.

Definition at line 477 of file g_gurobi.cc.

◆ ComputeIIS()

absl::StatusOr< bool > operations_research::math_opt::Gurobi::ComputeIIS ( Callback cb = nullptr)

Calls GRBcomputeIIS().

Returns:

  • a status if Gurobi errors,
  • true if Gurobi proves that the model is infeasible, or
  • false otherwise (e.g., feasibility is proven or a limit is reached).

The callback, if specified, is set before solving and cleared after.

If Gurobi v11 terminates at a limit before determining if the model is feasible or not, it will return an OK error code but then will fail to return anything about the IIS it does not have. To detect this case, we query the minimality attribute: we know that our env is valid at this point, and this should fail iff an IIS is present, i.e., Gurobi proved that the model was infeasible.

Definition at line 536 of file g_gurobi.cc.

◆ DelConstrs()

absl::Status operations_research::math_opt::Gurobi::DelConstrs ( absl::Span< const int > ind)

Calls GRBdelconstrs().

Definition at line 361 of file g_gurobi.cc.

◆ DelGenConstrs()

absl::Status operations_research::math_opt::Gurobi::DelGenConstrs ( absl::Span< const int > ind)

Calls GRBdelgenconstrs().

Deletes the specified general constraints.

Definition at line 472 of file g_gurobi.cc.

◆ DelQ()

absl::Status operations_research::math_opt::Gurobi::DelQ ( )

Calls GRBdelq().

Deletes all quadratic objective coefficients.

Definition at line 377 of file g_gurobi.cc.

◆ DelQConstrs()

absl::Status operations_research::math_opt::Gurobi::DelQConstrs ( absl::Span< const int > ind)

Calls GRBdelqconstrs().

Deletes the specified quadratic constraints.

Definition at line 430 of file g_gurobi.cc.

◆ DelSos()

absl::Status operations_research::math_opt::Gurobi::DelSos ( absl::Span< const int > ind)

Calls GRBdelsos().

Deletes the specified SOS constraints.

Definition at line 453 of file g_gurobi.cc.

◆ DelVars()

absl::Status operations_research::math_opt::Gurobi::DelVars ( absl::Span< const int > ind)

Calls GRBdelvars().

  • vbegin should have size equal to the number of new variables.
    • vind and vsize should have size equal to the number of new nonzeros in the linear constraint matrix.
      Note
      vbegin, vind and vval can all be empty if you do not want to modify the constraint matrix, this is equivalent to the simpler overload above.

Definition at line 314 of file g_gurobi.cc.

◆ empty() [1/2]

have size equal to the number of new be operations_research::math_opt::Gurobi::empty ( all new variables have objective coefficient 0)
new
  • names should either:

◆ empty() [2/2]

have size equal to the number of new be be empty(all new variables have name ""). absl have size equal to the number of new be operations_research::math_opt::Gurobi::empty ( all new variables have objective coefficient 0)
new
  • names should either:

◆ GetCharAttrArray() [1/2]

absl::Status operations_research::math_opt::Gurobi::GetCharAttrArray ( const char * name,
absl::Span< char > attr_out ) const

Definition at line 651 of file g_gurobi.cc.

◆ GetCharAttrArray() [2/2]

absl::StatusOr< std::vector< char > > operations_research::math_opt::Gurobi::GetCharAttrArray ( const char * name,
int len ) const

Definition at line 659 of file g_gurobi.cc.

◆ GetCharAttrElement()

absl::StatusOr< char > operations_research::math_opt::Gurobi::GetCharAttrElement ( const char * name,
int element ) const

Definition at line 724 of file g_gurobi.cc.

◆ GetDoubleAttr()

absl::StatusOr< double > operations_research::math_opt::Gurobi::GetDoubleAttr ( const char * name) const

Definition at line 569 of file g_gurobi.cc.

◆ GetDoubleAttrArray() [1/2]

absl::Status operations_research::math_opt::Gurobi::GetDoubleAttrArray ( const char * name,
absl::Span< double > attr_out ) const

Definition at line 636 of file g_gurobi.cc.

◆ GetDoubleAttrArray() [2/2]

absl::StatusOr< std::vector< double > > operations_research::math_opt::Gurobi::GetDoubleAttrArray ( const char * name,
int len ) const

Definition at line 644 of file g_gurobi.cc.

◆ GetDoubleAttrElement()

absl::StatusOr< double > operations_research::math_opt::Gurobi::GetDoubleAttrElement ( const char * name,
int element ) const

Definition at line 710 of file g_gurobi.cc.

◆ GetDoubleParam()

absl::StatusOr< double > operations_research::math_opt::Gurobi::GetDoubleParam ( const char * name)

Calls GRBgetdblparam().

Definition at line 764 of file g_gurobi.cc.

◆ GetIntAttr()

absl::StatusOr< int > operations_research::math_opt::Gurobi::GetIntAttr ( const char * name) const

Definition at line 562 of file g_gurobi.cc.

◆ GetIntAttrArray() [1/2]

absl::Status operations_research::math_opt::Gurobi::GetIntAttrArray ( const char * name,
absl::Span< int > attr_out ) const

Definition at line 621 of file g_gurobi.cc.

◆ GetIntAttrArray() [2/2]

absl::StatusOr< std::vector< int > > operations_research::math_opt::Gurobi::GetIntAttrArray ( const char * name,
int len ) const

Definition at line 629 of file g_gurobi.cc.

◆ GetIntAttrElement()

absl::StatusOr< int > operations_research::math_opt::Gurobi::GetIntAttrElement ( const char * name,
int element ) const

Definition at line 696 of file g_gurobi.cc.

◆ GetIntParam()

absl::StatusOr< int > operations_research::math_opt::Gurobi::GetIntParam ( const char * name)

Calls GRBgetintparam().

Definition at line 758 of file g_gurobi.cc.

◆ GetNnz()

absl::StatusOr< int > operations_research::math_opt::Gurobi::GetNnz ( int first_var,
int num_vars )

Linear constraint matrix queries. Calls GRBgetvars().

The number of nonzeros in the constraint matrix for the num_vars columns starting with first_var.

Warning
will not reflect pending modifications, call UpdateModel() or Optimize() first.

Definition at line 488 of file g_gurobi.cc.

◆ GetStringAttr()

absl::StatusOr< std::string > operations_research::math_opt::Gurobi::GetStringAttr ( const char * name) const
Warning
if a string attribute is the empty string, we need to be careful, std::string(char*) cannot take a nullptr.

Definition at line 576 of file g_gurobi.cc.

◆ GetStringParam()

absl::StatusOr< std::string > operations_research::math_opt::Gurobi::GetStringParam ( const char * name)

Calls GRBgetstrparam().

Definition at line 770 of file g_gurobi.cc.

◆ GetVars() [1/2]

absl::Status operations_research::math_opt::Gurobi::GetVars ( absl::Span< int > vbegin,
absl::Span< int > vind,
absl::Span< double > vval,
int first_var,
int num_vars )

Calls GRBgetvars().

Write the nonzeros of the constraint matrix for the num_vars columns starting with first_var out in CSC format to (vbegin, vind, vval).

The user is responsible for ensuring that the output Spans are exactly the correct size. See the other GetVars() overload for a simpler version.

Warning
will not reflect pending modifications, call UpdateModel() or Optimize() first.

Definition at line 495 of file g_gurobi.cc.

◆ GetVars() [2/2]

absl::StatusOr< Gurobi::SparseMat > operations_research::math_opt::Gurobi::GetVars ( int first_var,
int num_vars )

Calls GRBgetvars().

Returns the nonzeros of the constraint matrix for the num_vars columns starting with first_var out in CSC format.

Warning
will not reflect pending modifications, call UpdateModel() or Optimize() first.

Definition at line 509 of file g_gurobi.cc.

◆ IsAttrAvailable()

bool operations_research::math_opt::Gurobi::IsAttrAvailable ( const char * name) const

Attributes

Definition at line 558 of file g_gurobi.cc.

◆ model()

GRBmodel * operations_research::math_opt::Gurobi::model ( ) const
inline

Typically not needed.

Definition at line 574 of file g_gurobi.h.

◆ New()

absl::StatusOr< std::unique_ptr< Gurobi > > operations_research::math_opt::Gurobi::New ( GRBenvUniquePtr primary_env = nullptr)
static

Creates a new Gurobi, taking ownership of primary_env if provided (if no environment is given, a new one is created internally from the license file).

Definition at line 181 of file g_gurobi.cc.

◆ NewWithSharedPrimaryEnv()

absl::StatusOr< std::unique_ptr< Gurobi > > operations_research::math_opt::Gurobi::NewWithSharedPrimaryEnv ( GRBenv * primary_env)
static

Creates a new Gurobi using an existing GRBenv, where primary_env cannot be nullptr. Unlike Gurobi::New(), the returned Gurobi will not clean up the primary environment on destruction.

A GurobiEnv can be shared between models with the following restrictions:

  • Environments are not thread-safe (so use one thread or mutual exclusion for Gurobi::New()).
  • The primary environment must outlive each Gurobi instance.
  • Every "primary" environment counts as a "use" of a Gurobi License. Depending on your license type, you may need to share to run concurrent solves in the same process.

Definition at line 175 of file g_gurobi.cc.

◆ Optimize()

absl::Status operations_research::math_opt::Gurobi::Optimize ( Callback cb = nullptr)

Calls GRBoptimize().

The callback, if specified, is set before solving and cleared after.

Definition at line 528 of file g_gurobi.cc.

◆ ResetParameters()

absl::Status operations_research::math_opt::Gurobi::ResetParameters ( )

Calls GRBresetparams().

Definition at line 776 of file g_gurobi.cc.

◆ SetCharAttrArray()

absl::Status operations_research::math_opt::Gurobi::SetCharAttrArray ( const char * name,
absl::Span< const char > new_values )

Definition at line 615 of file g_gurobi.cc.

◆ SetCharAttrElement()

absl::Status operations_research::math_opt::Gurobi::SetCharAttrElement ( const char * name,
int element,
char new_value )

Definition at line 732 of file g_gurobi.cc.

◆ SetCharAttrList()

absl::Status operations_research::math_opt::Gurobi::SetCharAttrList ( const char * name,
absl::Span< const int > ind,
absl::Span< const char > new_values )

Definition at line 686 of file g_gurobi.cc.

◆ SetDoubleAttr()

absl::Status operations_research::math_opt::Gurobi::SetDoubleAttr ( const char * attr_name,
double value )

Definition at line 598 of file g_gurobi.cc.

◆ SetDoubleAttrArray()

absl::Status operations_research::math_opt::Gurobi::SetDoubleAttrArray ( const char * name,
absl::Span< const double > new_values )

Definition at line 609 of file g_gurobi.cc.

◆ SetDoubleAttrElement()

absl::Status operations_research::math_opt::Gurobi::SetDoubleAttrElement ( const char * name,
int element,
double new_value )

Definition at line 718 of file g_gurobi.cc.

◆ SetDoubleAttrList()

absl::Status operations_research::math_opt::Gurobi::SetDoubleAttrList ( const char * name,
absl::Span< const int > ind,
absl::Span< const double > new_values )

Definition at line 676 of file g_gurobi.cc.

◆ SetDoubleParam()

absl::Status operations_research::math_opt::Gurobi::SetDoubleParam ( const char * name,
double value )

Calls GRBsetdblparam().

Definition at line 748 of file g_gurobi.cc.

◆ SetIntAttr()

absl::Status operations_research::math_opt::Gurobi::SetIntAttr ( const char * attr_name,
int value )

Definition at line 594 of file g_gurobi.cc.

◆ SetIntAttrArray()

absl::Status operations_research::math_opt::Gurobi::SetIntAttrArray ( const char * name,
absl::Span< const int > new_values )

Definition at line 603 of file g_gurobi.cc.

◆ SetIntAttrElement()

absl::Status operations_research::math_opt::Gurobi::SetIntAttrElement ( const char * name,
int element,
int new_value )

Definition at line 704 of file g_gurobi.cc.

◆ SetIntAttrList()

absl::Status operations_research::math_opt::Gurobi::SetIntAttrList ( const char * name,
absl::Span< const int > ind,
absl::Span< const int > new_values )

Definition at line 666 of file g_gurobi.cc.

◆ SetIntParam()

absl::Status operations_research::math_opt::Gurobi::SetIntParam ( const char * name,
int value )

Calls GRBsetintparam().

Definition at line 744 of file g_gurobi.cc.

◆ SetNthObjective()

absl::Status operations_research::math_opt::Gurobi::SetNthObjective ( int index,
int priority,
double weight,
double abs_tol,
double rel_tol,
const std::string & name,
double constant,
absl::Span< const int > lind,
absl::Span< const double > lval )

Calls GRBsetobjectiven().

Sets the n-th objective in a multi-objective model.

Requirement:

  • lind and lval must be of equal length.

Definition at line 379 of file g_gurobi.cc.

◆ SetParam()

absl::Status operations_research::math_opt::Gurobi::SetParam ( const char * name,
const std::string & value )

Parameters Calls GRBsetparam().

Prefer the typed versions (e.g. SetIntParam()) defined below.

Definition at line 739 of file g_gurobi.cc.

◆ SetStringAttr()

absl::Status operations_research::math_opt::Gurobi::SetStringAttr ( const char * attr_name,
const std::string & value )

Definition at line 589 of file g_gurobi.cc.

◆ SetStringParam()

absl::Status operations_research::math_opt::Gurobi::SetStringParam ( const char * name,
const std::string & value )

Calls GRBsetstrparam().

Definition at line 753 of file g_gurobi.cc.

◆ Terminate()

void operations_research::math_opt::Gurobi::Terminate ( )

Calls GRBterminate().

Definition at line 780 of file g_gurobi.cc.

◆ ToStatus()

absl::Status operations_research::math_opt::Gurobi::ToStatus ( int grb_err,
absl::StatusCode code = absl::StatusCode::kInvalidArgument,
absl::SourceLocation loc = absl::SourceLocation::current() ) const

Definition at line 233 of file g_gurobi.cc.

◆ UpdateModel()

absl::Status operations_research::math_opt::Gurobi::UpdateModel ( )

Calls GRBupdatemodel().

Solving

Definition at line 524 of file g_gurobi.cc.

Member Data Documentation

◆ constraints

have size equal to the number of new operations_research::math_opt::Gurobi::constraints

Calls GRBaddconstrs().

Requirements:

  • sense and rhs must have size equal to the number of new constraints.
  • names should either:

Definition at line 327 of file g_gurobi.h.

◆ variables [1/2]

have size equal to the number of new operations_research::math_opt::Gurobi::variables

Calls GRBaddvars() to add variables to the model.

Requirements:

  • lb, ub and vtype must have size equal to the number of new variables.
  • obj should either:

Definition at line 271 of file g_gurobi.h.

◆ variables [2/2]

have size equal to the number of new be be empty (all new variables have name ""). absl have size equal to the number of new operations_research::math_opt::Gurobi::variables

Calls GRBaddvars() to add variables and linear constraint columns to the model.

The new linear constraint matrix columns are given in CSC format (see SparseMat above for an example).

Requirements:

  • lb, ub and vtype must have size equal to the number of new variables.
  • obj should either:

Definition at line 290 of file g_gurobi.h.


The documentation for this class was generated from the following files: