Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Computation Time difference Matlab/C++

    Posted Wed March 07, 2018 06:51 AM

    Originally posted by: Erano1


    Hello Guys,

    currently i am working with CPLEX for optimize MILP. To make easy changes in my simulation and problem formulations i am using Matlab to solve the optimization Problem. To compare computation time with other works which used C++ i wanted to know, if there is any global statement about difference in computation time in Matlab and C++? Something like time in Matlab = x*C++ . Or is this not possible and always depends on the problem you want to be solved? 

     

    Greetings, 

    Erano1


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Computation Time difference Matlab/C++

    Posted Wed March 07, 2018 08:06 AM

    Are you about these factors in general or only with respect to CPLEX?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Computation Time difference Matlab/C++

    Posted Wed March 07, 2018 08:28 AM

    Originally posted by: Erano1


    Hey, 

    both would help :) In some paper it could be shown that C++ was ca 500 times faster then Matlab (https://pdfs.semanticscholar.org/ed2b/5f9a2ca37e55052eafbf5abc166245cf7995.pdf, for exampl). But this is  for a much different case as optimization. To be more accurate it would be nice to know about a number only with respect to CPLEX. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Computation Time difference Matlab/C++

    Posted Wed March 07, 2018 08:57 AM

    For CPLEX you have to consider how CPLEX works in matlab and C++: In  both languages, there is a representation of your problem in that specific language. This representation is eventually extracted into the callable library. The callable library is implemented in C and once the models have been extracted to it, it no longer matters where the models came from. The optimization itself runs in the code that was implemented in C, not in matlab or C++. So with respect to CPLEX the only difference you could observe between matlab and C++ is the time to do the extraction. This time is usually negligible unless you solve a large number of small problems or solve very huge problems.

    I cannot speak to the rest of your application.

    Using a factor to compare C++ and matlab seems a little suspicious to me. There are usually many ways to implement the same thing. How do you tell whether the software you are comparing to uses an efficient implementation or not? Also, what is efficient in C++ is not necessarily efficient in matlab and vice versa.

    Does your application spend a lot of time in matlab? If most of the time is spent inside CPLEX then maybe the time in matlab just does not matter?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Computation Time difference Matlab/C++

    Posted Fri March 09, 2018 04:06 AM

    Originally posted by: Erano1


    Hello Daniel, 

    thank you very much for your detailed answer, it is very helpfull. 

    I want to compare two different kind of ways to solve an optimal path planning algorithm for robot manipulators. The work i want to compare with was implemented in C++ for real time application. For make changes and programming easier till the final version is finished i work only with Matlab. But the importent thing to compare is just the solvertime CPLEX need for the optimization. 

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Computation Time difference Matlab/C++

    Posted Fri March 09, 2018 09:25 AM

    I think you have two options:

    1. Just measure the time the solve() call takes in matlab. As stated before, the overhead of extraction should not be too big unless you solve a large number of models that solve quickly.
    2. Export the model to a SAV file and then solve that SAV file using the interactive optimizer. That removes any matlab-related overhead.

    You could also do 1 and 2 for some models just to confirm that the times you measure in matlab are similar to the times you measure in the interactive.


    #CPLEXOptimizers
    #DecisionOptimization