Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Solving an LPs in Parallel Using CPLEX MATLAB API and parfor

  • 1.  Solving an LPs in Parallel Using CPLEX MATLAB API and parfor

    Posted Fri June 17, 2011 02:09 AM

    Originally posted by: BerkUstun


    I'm currently running Cplex on an 8-core machine and would like to take advantage of the parfor function in MATLAB to solve a number of LPs in parallel. Essentially, this may be more of a MATLAB question than a Cplex question, in which case please feel free to point it out.

    My main issue in using the parfor function is the transparency requirement, which stems from the fact that parallel threads cannot reference the same data and effectively forces me to set up an LP from scratch each time I aim to solve them in parallel.

    I am wondering:

    1. Is there an easy way to copy a Cplex LP object in MATLAB? This way, I can simply copy the object within the parfor loop instead of having to create it from scratch?

    2. In my past experience, I remember Cplex sometimes displayed that it solved an LP in 'Parallel mode.' What exactly is parallel mode? Does this mean it's using more than a single processor to solve the LP? If so, is there a way to tweak these settings

    3. (Somewhat unrelated) My understanding is that the CPLEX API in MATLAB does not solve LPs within MATLAB but copies the information into another environment using cplexlink. Is there a way to speed up this process? Would it help if I switched from CPLEX API in MATLAB to say the CPLEX API in C or C++? Effectively, I believe that the access time might be the issue that is slowing down my code the most.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Solving an LPs in Parallel Using CPLEX MATLAB API and parfor

    Posted Fri June 17, 2011 02:24 AM

    Originally posted by: SystemAdmin


    Crazy idea for question 1 (I am not a matlab user): Export the model into a .sav file and have each thread that solves the model read it from the .sav file.

    Answer to question 2: When solving LPs there are two ways in which CPLEX takes advantage of multiple processors:
    • concurrentopt If more than one processor is available then CPLEX solves the problem by different algorithms simultaneously. Depending on the number of processors and the threading mode (see the user manual) it runs primal simplex, dual simplex and barrier on the same model and uses the result of whichever algorithm finishes first. This is useful in general if you do not know what algorithm performs best on your problem.
    • barrier The barrier algorithm offers opportunity for parallel speedup and can be implemented to take advantage of multiple processors.
    In default settings concurrentopt is used. In order to select a particular algorithm use parameter CPX_PARAM_LPMETHOD.

    (Partial) answer to question 3: All the APIs (matlab, C++, ...) ultimately call the functions provided by the C callable library. Each API can be considered as a wrapper for the callable library that has its own kind of problem representation. Consequently, the fastest possible thing you can do is to use the C callable library directly. This will eliminate all data transformations that are performed in the APIs. If you spend most of your time in problem reading/creation and not in the actual solve then this might indeed speed up your overall performance.
    #CPLEXOptimizers
    #DecisionOptimization