Dear all,
I am running a MATLAB code employing a function optimisation using the pattern search algorithm (the poll method used is GSS positive basis 2N and I am using the parallel computing option). For a variety of reasons (including IP) we want to port the code into C++. Can you please suggest a numerical library, possibly MIT licence or similar, that allows me to perform the same task (pattern search with parallel computing) with decent performance?
Thanks!

답변 (2개)

Sean de Wolski
Sean de Wolski 2020년 6월 24일

1 개 추천

Could you use the Compiler SDK to build a C++ library directly? This would reuse your exact implementation with patternsearch and parallel computing.

댓글 수: 8

Rik
Rik 2020년 6월 24일
Wouldn't that be subject to the same license restrictions as the copy of Matlab that created that library? Or am I misunderstanding how this works?
Andrea Agosti
Andrea Agosti 2020년 6월 24일
hi, thanks for your comment.
can you please expand a bit your answer? I am familiar with MATLAB compiler, but not with Compiler SDK.
Regards,
Sean de Wolski
Sean de Wolski 2020년 6월 24일
You're misunderstanding how it works. The whole purpose of the Compiler SDK is to build scalable applications that are encrypted and totally royalty-free.
Sean de Wolski
Sean de Wolski 2020년 6월 24일
The Compiler SDK lets you build C++ shared libraries rather than executables like the regular Compiler.
Andrea Agosti
Andrea Agosti 2020년 6월 24일
hi,
so if i have a function like:
main.m which calls the pattern search (and the parallelization toolbox) will all the sub-functions (inside main.m) will be translated to a c++ library?
it seems strange to me because if the compiler SDK works more or less as the coder, not all the functions can be translated to c++.
Sean de Wolski
Sean de Wolski 2020년 6월 24일
편집: Sean de Wolski 2020년 6월 24일
MATLAB Compiler doesn't transpile to C++; it doesn't write C++. It packages the MATLAB code up with a C++ interface, to run against a runtime. So it's the exact same code running against the same MATLAB execution engine and supports almost all of the MATLAB language and Toolboxes.
MATLAB Coder transpiles MATLAB code to C, C++. I.e. it rewrites it. This has more limited support and is generally targeted for embedded applications.
Your goal of having royalty free, IP protected, MATLAB code matches better with the Compiler SDK workflow.
Andrea Agosti
Andrea Agosti 2020년 6월 24일
hi,
thanks for your clarification. It is a very useful solution but using the compiler i would not have any performance improvement. Am i correct?
Sean de Wolski
Sean de Wolski 2020년 6월 24일
It's running the same code against the same engine. The only change in performance will be if the compiled library is used on a more powerful machine.

댓글을 달려면 로그인하십시오.

Aditya Verma
Aditya Verma 2020년 6월 24일

0 개 추천

Hello!
You can try the famous OpenCV library. It also has inbuilt constructs to parallelize your code. It uses the BSD 3-Clause licence.
You could also check out MATLAB Coder. It allows you to convert your MATLAB code to C/C++ code. However, not all MATLAB functionalities are supported for conversion. You can refer the following link to check for the same:
Thanks

댓글 수: 6

Andrea Agosti
Andrea Agosti 2020년 6월 24일
Hi, thanks for your answer.
i checked OpenCV library but I didn't see anything related with numerical optimisation. Am i wrong?
Regarding coder, yes we are looking into it but unfortunately it doesn't support all the MATLAB functionalities.
thanks
Aditya Verma
Aditya Verma 2020년 6월 24일
By numerical optimization, you mean this? https://docs.opencv.org/3.4/da/d01/group__core__optim.html
Andrea Agosti
Andrea Agosti 2020년 6월 24일
Thanks for your fast answer,
yes, but I am looking for a library with direct search solver or in general a non gradient based solver (like pattern search in matlab). Also, the problem under consideration is not a linear programming problem, it is a problem like
Minimise f(x1,x2,..,xn)
Subject to:Ax<=b
x>=LB and x<=UB
Thanks
Aditya Verma
Aditya Verma 2020년 6월 24일
편집: Aditya Verma 2020년 6월 24일
Oh, I see. In my knowledge OpenCV doesn't support it. You need a "non-linear direct search optimization library". I did some googling and found one with LGPL licence: https://software.sandia.gov/opt++/opt++2.4_doc/html/index.html
This could be useful for your case.
Andrea Agosti
Andrea Agosti 2020년 6월 24일
hi,
that's great! very useful.
thanks
Aditya Verma
Aditya Verma 2020년 6월 24일
You're welcome!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

질문:

2020년 6월 24일

댓글:

2020년 6월 24일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by