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 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
).The full list of attributes can be found in the Attributes section of this document. Examples of how to query and set attributes can also be found in this section.
- char get(GRB.CharAttr attr)#
- double get(GRB.DoubleAttr attr)#
- int get(GRB.IntAttr attr)#
- String get(GRB.StringAttr attr)#
Query the value of a quadratic constraint attribute.
- Arguments:
attr – The attribute being queried.
- Return value:
The current value of the requested attribute.
- Example:
// Get constraint sense char sense = constr.get(GRB.CharAttr.QCSense); // Get RHS double rhs = constr.get(GRB.DoubleAttr.QCRHS); // Get information whether constraint participates in a previously computed IIS int iisqconstr = constr.get(GRB.IntAttr.IISQConstr); // Get constraint name String name = constr.get(GRB.StringAttr.QCName);
- void set(GRB.CharAttr attr, char newval)#
- void set(GRB.DoubleAttr attr, double newval)#
- void set(GRB.IntAttr attr, int newval)#
- void set(GRB.StringAttr attr, String newval)#
Set the value of a quadratic constraint attribute.
- Arguments:
attr – The attribute being modified.
newval – The desired new value of the attribute.
- Example:
// Set constraint sense constr.set(GRB.CharAttr.QCSense, '>'); // Set RHS constr.set(GRB.DoubleAttr.QCRHS, 2.0); // Force constraint into IIS constr.set(GRB.IntAttr.IISQConstrForce, 1); // Set constraint name constr.set(GRB.StringAttr.QCName, "newName");