Search code examples
pythoncplexquadratic

Performance issue with setting quadratic objective in CPLEX


I am solving a large sparse quadratic problem. My objective function has only quadratic terms and the coefficients of all terms are the same and equal to 1 and it includes all of the variables.

I use objective.set_quadratic_coefficients function in python to create my objective function. For small problems (10000 variables), the objective function is generated quickly but it gets much slower for larger problems (100000 variables) and does return anything for my main problem that has 1000000 variables.

Is there an alternative to objective.set_quadratic_coefficients to speed up the creating the problem?


Solution

  • After asking my question in the IBM forum, I received and answer and it works. The fastest way to create the quadratic objective function is to use objective.set_quadratic() with only a list that contains the coefficient values (they can vary and don't need to be all equal to 1.0)