GRBQConstr#
- GRBQConstr#
Gurobi quadratic constraint object. Quadratic constraints are always associated with a particular model. You create a quadratic constraint object by adding a quadratic constraint to a model (using
GRBModel.AddQConstr
), rather than by using aGRBQConstr
constructor.The methods on quadratic constraint objects are used to get and set quadratic constraint attributes. For example, quadratic constraint right-hand sides can be queried by calling
Get
(GRB.DoubleAttr.QCRHS
). Note, however, that it is generally more efficient to query attributes for a set of constraints at once. This is done using the attribute query method on theGRBModel
object (GRBModel.Get
).- Example:
// Create variables GRBVar x = model.AddVar(-2.0, 2.0, 0.0, GRB.CONTINUOUS, "x"); GRBVar y = model.AddVar(0.0, 3.0, 0.0, GRB.CONTINUOUS, "y"); // Add quadratic constraint x^2 + x*y + y = 0 with name c1 GRBQConstr constr = model.AddQConstr(x*x + x*y + y == 0, "c1");
' Create variables Dim x As GRBVar = model.AddVar(-2.0, 2.0, 0.0, GRB.CONTINUOUS, "x") Dim y As GRBVar = model.AddVar(0.0, 3.0, 0.0, GRB.CONTINUOUS, "y") ' Add quadratic constraint x^2 + x*y + y = 0 with name c1 Dim constr As GRBQConstr = model.AddQConstr(x*x + x*y + y == 0, "c1")
- char Get(GRB.CharAttr attr)#
Query the value of a char-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being queried.
- Returns:
The current value of the requested attribute.
- Example:
// Get constraint sense char sense = constr.Get(GRB.CharAttr.QCSense);
' Get constraint sense Dim sense As Char = constr.Get(GRB.CharAttr.QCSense)
- double Get(GRB.DoubleAttr attr)#
Query the value of a double-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being queried.
- Returns:
The current value of the requested attribute.
- Example:
// Get RHS double rhs = constr.Get(GRB.DoubleAttr.QCRHS);
' Get RHS Dim rhs As Double = constr.Get(GRB.DoubleAttr.QCRHS)
- int Get(GRB.IntAttr attr)#
Query the value of an int-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being queried.
- Returns:
The current value of the requested attribute.
- Example:
// Get information whether constraint participates in a // previously computed IIS int iisqconstr = constr.Get(GRB.IntAttr.IISQConstr);
' Get information whether constraint participates in a ' previously computed IIS Dim iisqconstr As Integer = constr.Get(GRB.IntAttr.IISQConstr)
- string Get(GRB.StringAttr attr)#
Query the value of a string-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being queried.
- Returns:
The current value of the requested attribute.
- Example:
// Get constraint name string name = constr.Get(GRB.StringAttr.QCName);
' Get constraint name Dim name As String = constr.Get(GRB.StringAttr.QCName)
- void Set(GRB.CharAttr attr, char newvalue)#
Set the value of a char-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being modified.
newvalue – The desired new value of the attribute.
- Example:
// Set constraint sense constr.Set(GRB.CharAttr.QCSense, '>');
' Set constraint sense constr.Set(GRB.CharAttr.QCSense, ">")
- void Set(GRB.DoubleAttr attr, double newvalue)#
Set the value of a double-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being modified.
newvalue – The desired new value of the attribute.
- Example:
// Set RHS constr.Set(GRB.DoubleAttr.QCRHS, 2.0);
' Set RHS constr.Set(GRB.DoubleAttr.QCRHS, 2.0)
- void Set(GRB.IntAttr attr, int newvalue)#
Set the value of an int-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being modified.
newvalue – The desired new value of the attribute.
- Example:
// Force constraint into IIS constr.Set(GRB.IntAttr.IISQConstrForce, 1);
' Force constraint into IIS constr.Set(GRB.IntAttr.IISQConstrForce, 1)
- void Set(GRB.StringAttr attr, string newvalue)#
Set the value of a string-valued quadratic constraint attribute.
- Parameters:
attr – The attribute being modified.
newvalue – The desired new value of the attribute.
- Example:
// Set constraint name constr.Set(GRB.StringAttr.QCName, "newName");
' Set constraint name constr.Set(GRB.StringAttr.QCName, "newName")