Search code examples
pythonmathematical-optimizationcomplex-numbersgurobi

How to use complex variables in a Gurobi problem


I currently solve optimization problems with complex variables using CVX + Mosek, on MATLAB. I'm now considering switching to Gurobi + Python for some applications.

  1. Is there a way to declare complex values (both inside constraints and as optimization variables) directly into Gurobi's Python interface?

  2. If not, which are good modeling languages, with Python interface, that automates the reduction of the problem to real variables before calling the solver?

I know, for instance, that YALMIP does this reduction (though no Python interface), and newer versions of CVXPY also (but I haven't used it extensively, and don't know if it already has good performance, is stable, and reasonably complete). Any thoughts on these issues and recommendations of other interfaces are thus welcome.


Solution

  • The only possible variables in Gurobi are:

    • Integer;
    • Binary;
    • Continuous;
    • Semi-Continuous and;
    • Semi-Integer.

    Also, I don't know the problem you're trying to solve, but complex number are quite strange for linear optimization.

    The complex plane isn't a ordered field, so that is not possible to say that a given complex number z1 > z2

    You'll probably have to model your problem in such way that you can decompose the constraints with real and imaginary parts, so that you can work only with real numbers.