hokiedsp / matlab-nlopt

A Matlab wrapper of NLopt nonlinear optimization library
MIT License
3 stars 2 forks source link

Problem Installing on Windows 10 #1

Closed SussexGooner closed 4 years ago

SussexGooner commented 4 years ago

Hi,

I am hoping that you can help. I am trying to install matlab-nlopt. I am not great with CMAKE so apologies if this is a straightforward question. cmake falls over with the following error. I am sure that it is straightforward to solve but I am not sure what to do. I tried adding the MATLAB\bin directory to the path as that's where the MEX.bat file exists.

Any suggestions would be appreciated.

thanks,

Daniel

CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find Matlab (missing: Matlab_MEX_LIBRARY Matlab_MX_LIBRARY Matlab_ENGINE_LIBRARY Matlab_DATAARRAY_LIBRARY MX_LIBRARY) (found version "9.8") Call Stack (most recent call first): C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.14/Modules/FindMatlab.cmake:1765 (find_package_handle_standard_args) CMakeLists.txt:30 (find_package)

-- Configuring incomplete, errors occurred!

hokiedsp commented 4 years ago

@SussexGooner - Could you try the most recent CMake version? I use the CMake's default FindMatlab module and IIRC it needs to be up to date to be compatible with the latest Matlab version.

SussexGooner commented 4 years ago

Hi,

That got me a little bit further. I now get an error that it could not find git for clone of nlopt. Sorry for all of the questions. I will tinker with this tomorrow.

Daniel

Sent from my iPhone

On Sep 22, 2020, at 6:06 PM, Kesh Ikuma notifications@github.com wrote:

 @SussexGooner - Could you try the most recent CMake version? I use the CMake's default FindMatlab module and IIRC it needs to be up to date to be compatible with the latest Matlab version.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

hokiedsp commented 4 years ago

Glad you figured the MATLAB part out. No need to apologize and raise more questions as you wish. I'll do my best helping ya (though I left Matlab scene for a little while now)

Now, that's peculiar that you cannot clone nlopt... I just tried it myself and it worked for me. Could you post the cmake output text?

BTW, the nlopt library is found at https://github.com/stevengj/nlopt and it is built as an external project (CMakeLists.txt Lines 39-43) which should run the script in CMakeLists.txt.win32.in

If no go, you can try to build nlopt separately (which also is a cmake project) and set NLOPT_ROOT_DIR env var to point to the install dir. There are other options you can find if you decipher cmake/FindNLopt.cmake

All this being said, I'd warn you that this project was born out of my desire to make NLopt interchangeable with Mathwork's Optimization Toolbox. So, it may be a bit finicky getting used to it, especially if your interest is in global optimization (which I really didn't use). NLOpt project itself offers its own low-level MATLAB interface, which may get you finer control (and less prone to bugs) than this project.

SussexGooner commented 4 years ago

Hi,

I think I have made more progress. I manually install nlopt following most of the instructions found there except that ‘make’ and ‘sudo make install’ failed on the command line so I built the projects in visual studio (running as an administrator). This appeared to install it on c:\program files(x86) which suggests it worked. I then did the same for matlab-nlopt-master.

I opened MATLAB and opened the nlopt_fmincon_example1.m and tried to execute it. I get the following error messages:

Error using nlopt.options.mexfcn

Method 'mexfcn' is not defined for class 'nlopt.options' or is removed from MATLAB's search path.

Error in nlopt.options (line 98)

     obj.mexfcn(obj, lower(algorithm), dim);

Error in nlopt.fmincon (line 196)

  options = nlopt.options('LN_COBYLA',n);

Error in nlopt_fmincon_example1 (line 9)

x = nlopt.fmincon(fun,x0,A,b)

I appreciate the help and feel I am getting closer. After I get this working on my computer, I am hoping that installing it on my daughter’s computer will be straightforward. She is the one doing the optimization work and is looking for an easy replacement for fmincon, but is wanting to try different optimization algorithms.

Thanks,

Daniel

From: Kesh Ikuma notifications@github.com Sent: Wednesday, September 23, 2020 8:35 AM To: hokiedsp/matlab-nlopt matlab-nlopt@noreply.github.com Cc: SussexGooner d.brown456@icloud.com; Mention mention@noreply.github.com Subject: Re: [hokiedsp/matlab-nlopt] Problem Installing on Windows 10 (#1)

Glad you figured the MATLAB part out. No need to apologize and raise more questions as you wish. I'll do my best helping ya (though I left Matlab scene for a little while now)

Now, that's peculiar that you cannot clone nlopt... I just tried it myself and it worked for me. Could you post the cmake output text?

BTW, the nlopt library is found at https://github.com/stevengj/nlopt and it is built as an external project (CMakeLists.txt Lines 39-43) which should run the script in CMakeLists.txt.win32.in

If no go, you can try to build nlopt separately (which also is a cmake project) and set NLOPT_ROOT_DIR env var to point to the install dir. There are other options you can find if you decipher cmake/FindNLopt.cmake

All this being said, I'd warn you that this project was born out of my desire to make NLopt interchangeable with Mathwork's Optimization Toolbox. So, it may be a bit finicky getting used to it, especially if your interest is in global optimization (which I really didn't use). NLOpt project itself offers its own low-level MATLAB interface, which may get you finer control (and less prone to bugs) than this project.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hokiedsp/matlab-nlopt/issues/1#issuecomment-697454941 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ARC46YEJ42ELXLMSRQN5GT3SHIBPXANCNFSM4RVIYNVA . https://github.com/notifications/beacon/ARC46YCXGYYAUF7P5DAIF4TSHIBPXA5CNFSM4RVIYNVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFGJFCXI.gif

SussexGooner commented 4 years ago

Hi,

Having installed nlopt correctly, it installed the matlab files as well as the nlopt.dll. I was able to get the example nlopt code to run in matlab so maybe I’ll push my daughter to use that directly rather than me trying to get your wrapper to work.

Thanks for your help as I don’t think I would have persevered without someone helping me along.

Thanks,

Daniel

From: danielgbrown@icloud.com danielgbrown@icloud.com Sent: Wednesday, September 23, 2020 9:57 AM To: 'hokiedsp/matlab-nlopt' reply@reply.github.com; 'hokiedsp/matlab-nlopt' matlab-nlopt@noreply.github.com Cc: 'SussexGooner' d.brown456@icloud.com; 'Mention' mention@noreply.github.com Subject: RE: [hokiedsp/matlab-nlopt] Problem Installing on Windows 10 (#1)

Hi,

I think I have made more progress. I manually install nlopt following most of the instructions found there except that ‘make’ and ‘sudo make install’ failed on the command line so I built the projects in visual studio (running as an administrator). This appeared to install it on c:\program files(x86) which suggests it worked. I then did the same for matlab-nlopt-master.

I opened MATLAB and opened the nlopt_fmincon_example1.m and tried to execute it. I get the following error messages:

Error using nlopt.options.mexfcn

Method 'mexfcn' is not defined for class 'nlopt.options' or is removed from MATLAB's search path.

Error in nlopt.options (line 98)

     obj.mexfcn(obj, lower(algorithm), dim);

Error in nlopt.fmincon (line 196)

  options = nlopt.options('LN_COBYLA',n);

Error in nlopt_fmincon_example1 (line 9)

x = nlopt.fmincon(fun,x0,A,b)

I appreciate the help and feel I am getting closer. After I get this working on my computer, I am hoping that installing it on my daughter’s computer will be straightforward. She is the one doing the optimization work and is looking for an easy replacement for fmincon, but is wanting to try different optimization algorithms.

Thanks,

Daniel

From: Kesh Ikuma <notifications@github.com mailto:notifications@github.com > Sent: Wednesday, September 23, 2020 8:35 AM To: hokiedsp/matlab-nlopt <matlab-nlopt@noreply.github.com mailto:matlab-nlopt@noreply.github.com > Cc: SussexGooner <d.brown456@icloud.com mailto:d.brown456@icloud.com >; Mention <mention@noreply.github.com mailto:mention@noreply.github.com > Subject: Re: [hokiedsp/matlab-nlopt] Problem Installing on Windows 10 (#1)

Glad you figured the MATLAB part out. No need to apologize and raise more questions as you wish. I'll do my best helping ya (though I left Matlab scene for a little while now)

Now, that's peculiar that you cannot clone nlopt... I just tried it myself and it worked for me. Could you post the cmake output text?

BTW, the nlopt library is found at https://github.com/stevengj/nlopt and it is built as an external project (CMakeLists.txt Lines 39-43) which should run the script in CMakeLists.txt.win32.in

If no go, you can try to build nlopt separately (which also is a cmake project) and set NLOPT_ROOT_DIR env var to point to the install dir. There are other options you can find if you decipher cmake/FindNLopt.cmake

All this being said, I'd warn you that this project was born out of my desire to make NLopt interchangeable with Mathwork's Optimization Toolbox. So, it may be a bit finicky getting used to it, especially if your interest is in global optimization (which I really didn't use). NLOpt project itself offers its own low-level MATLAB interface, which may get you finer control (and less prone to bugs) than this project.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hokiedsp/matlab-nlopt/issues/1#issuecomment-697454941 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ARC46YEJ42ELXLMSRQN5GT3SHIBPXANCNFSM4RVIYNVA . https://github.com/notifications/beacon/ARC46YCXGYYAUF7P5DAIF4TSHIBPXA5CNFSM4RVIYNVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFGJFCXI.gif

hokiedsp commented 4 years ago

@SussexGooner - Okie dokie. Glad you have nlopt running. If you ever decide to revisit your issue. The missing mexfcn is the mex file that cmake builds. So, you likely didn't install the files in cmake.