Try our new documentation site (beta).


MQConstr

Gurobi matrix quadratic constraint object. An MQConstr object is an array-like data structure that represents multiple quadratic constraints (in contrast to a QConstr object, which represents a single quadratic constraint). It behaves similar to NumPy's ndarrays, e.g., it has a shape and can be indexed and sliced. Matrix quadratic constraints are always associated with a particular model. You typically create these objects with Model.addConstr, using overloaded comparison operators on matrix variables, matrix linear expressions, and matrix quadratic expressions.

Quadratic constraint objects have a number of attributes. The full list can be found in the Attributes section of this document. Some constraint attributes can only be queried, while others can also be set. Recall that the Gurobi optimizer employs a lazy update approach, so changes to attributes don't take effect until the next call to Model.update, Model.optimize, or Model.write on the associated model.

We should point out a few things about quadratic constraint attributes. Consider the QCRHS attribute. The values for a matrix quadratic constraint mqc can be queried using mc.QCRHS. The Gurobi library ignores letter case in attribute names, so it can also be queried as mc.qcrhs. Attribute values are returned as a NumPy ndarray that has the same shape as qmc. An attribute can be set, using a standard assignment statement (e.g., mqc.qcrhs = b), with b being either an ndarray with the appropriate shape, or a scalar which is then applied to all of the associated quadratic constraints. However, as mentioned earlier, attribute modification is done in a lazy fashion, so you won't see the effect of the change immediately. And some attributes can not be set (e.g., the QCPi attribute), so attempts to assign new values to them will raise an exception.

You can also use MQConstr.getAttr/ MQConstr.setAttr to access attributes. The attribute name can be passed to these routines as a string, or you can use the constants defined in the GRB.Attr class (e.g., GRB.Attr.QCRHS).



Subsections

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search

Gurobi Optimization