samedi 2 juillet 2016

Getting Obj and Constraint matrices out of Gurobi

I'm trying to analyse some solution space properties of an optimisation problem that I've got solving with Gurobi and python. Gurobi has a great way of adding in constraints and objective functions as linear expressions instead of fiddling with matrices.

However to do the analyses about convexity I need to have the Q (objective matrix) and A (constraint matrix). (Naming based off this example: https://www.gurobi.com/documentation/6.5/examples/dense_py.html)

Where the problem would be something like:

Minimise: X.T*Q*X + X*q    (X.T is the transpose of the matrix X)
Subject to: X.T*A*X + X*a

(As Gurobi allows quadratic constraints as well as objectives, the lower case a and q are to account for linear terms that may arise).

What I'm ideally looking for is something like print(gurobiModel.aMatrix) etc.

Does anyone know of such a function? Or perhaps something that could parse the LP model file?

Aucun commentaire:

Enregistrer un commentaire