Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Performance issue with setting quadratic objective

  • 1.  Performance issue with setting quadratic objective

    Posted Sun September 10, 2017 09:48 PM

    Originally posted by: Emirza


    Hello,

    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? 

    Thanks


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Performance issue with setting quadratic objective

    Posted Mon September 11, 2017 02:26 AM

    Have you tried invoking objective.set_quadratic() with an all-1 array that is as long as the number of variables?

    Also, when calling objective.set_quadratic_coefficients(), do you index variables by name or by index? If you are indexing by name then try indexing by index.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Performance issue with setting quadratic objective

    Posted Mon September 11, 2017 10:20 AM

    Originally posted by: Emirza


    Thank you for your response. 

    I used objective.set_quadratic() with an array that is as long as the number of variables and now the quadratic objective function gets created really fast. It is also not necessary to have an array of all 1 and the coefficients can vary. I also tried objective.set_quadratic() with indices and values and it works fine but not as fast as just passing the array of values.

    I couldn't try objective.set_quadratic_coefficients() with just using calling with indices because it seems like objective.set_quadratic_coefficients() needs a tuple of indices, names and value. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Performance issue with setting quadratic objective

    Posted Mon September 11, 2017 01:12 PM

    With regards to your last remark, the documentation for objective.set_quadratic_coefficients is here. Here's the relevant snippet:

    Sets coefficients of the quadratic component of the objective function.
    To set a single coefficient, call this method as
    objective.set_quadratic_coefficients(v1, v2, val)
    where v1 and v2 are names or indices of variables and val is the value for the coefficient.
    To set multiple coefficients, call this method as
    objective.set_quadratic_coefficients(sequence)
    where sequence is a list or tuple of triples (v1, v2, val) as described above.

    v1 and v2 can be either names or indices (or one of each), but if you use indices only, you should get better performance (than if you had used names). In general, I think it should be much faster to use objective.set_quadratic, though. See this page in the user's manual for general advice on using indices vs names.

     


    #CPLEXOptimizers
    #DecisionOptimization