Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Parallelize model generation via OpenMP in C++ API

    Posted 01/26/17 10:00 AM

    Originally posted by: nlp7


    Hi,

    I have a model with a large number of constraints which takes long time to be constructed within the C++ API (more than 20 minutes).

    I am trying to parallelize the loop that generates the constraints with openMP, but I am getting segfaults leading to some IloExpr objects that I use to build the constraints. So my question is, whether the model creation portion of the C++ API is thread safe, and if so what is a proper implementation.

    Thank you


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Parallelize model generation via OpenMP in C++ API

    Posted 01/27/17 03:52 AM

    No, the model building API is not safe to use in the way you do. You will have to use explicit locking to make this thread-safe.

    However, there are a few dos and donts that influence the speed of generating constraints, for example

    • Instead of things like 'a = a + b'  use computed assignment 'a += b' whenever possible,
    • if you are adding multiple constraints consider adding multiple constraints in one call (using an IloRangeArray) instead of adding each constraint individually in a loop,
    • only extract the model into the IloCplex instance once the model is completely built.
    • ...

    Observing these things can already give significant speedup (unless you already followed these guidelines).


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Parallelize model generation via OpenMP in C++ API

    Posted 01/27/17 10:55 AM

    Originally posted by: nlp7


    Thank you Daniel for your response.

    You understand that explicit locking will just make the possible benefits of parallelization to vanish (since the cplex related code is the bottleneck at least in my case). In any case, I think that there is some value there and if the implementation from your side becomes thread safe, then we can have almost linear increase in the model generation speed (since everyone has at least 2 threads available).

    This would be of great interest for people dealing with big models that have to solve multiple times, or even when incorporating CPLEX within a BnB scheme, where in each node you have to recreate the model.

     

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization