Call a dll from matlab dispatch  

  RSS
(@ismael2)
Eminent HOMER

Hi,

We have been working with the MATLAB link and we have found a problem with a MATLAB function. In our code we use the function loadlibrary() and if we add that function in our matlabDispatch function, HOMER cannot reach a solution.

https://es.mathworks.com/help/matlab/ref/loadlibrary.html

 

What is the reason of that problem? What are the limitations of MatlabDispatch function?

 

Thank you in advance

Kind Regards,

Ismael

Edited: 12 months  ago
ReplyQuote
Posted : July 3, 2017 5:37 am
(@dhiwaakar)
Illustrious HOMER Admin

Hi Ismael,

 

It is possible that the error could be not because of the loadlibrary() function. If we have a look at the error, that might give us a better explanation. Could you please send us a screenshot of the error message window? Thank you.

 

Best,

Dhiwaakar Rajasekaran

ReplyQuote
Posted : July 3, 2017 11:19 am
(@ismael2)
Eminent HOMER
There is no information about the error, the problem is that it remains calculating and there is no result. Like you see at the attached picture.
 The code to call the dll is:
If libisloaded(‘Controlf1’) == 0
                loadlibrary(‘Controlf1.dll’, ‘Controlf1.h’);
end
....
If libisloaded(‘Controlf1’)
                Unloadlibrary Controlf1.dll
end
 
 
ReplyQuote
Posted : July 4, 2017 11:26 am
(@dhiwaakar)
Illustrious HOMER Admin

Hi Ismael,

 

Since you didn't get any error, it is very much possible that the long run time of the model could be because of the model inputs itself like the search space inputs and not because of the loadlibrary() function. Can you please send us the files (MATLAB and HOMER) so we can take a look at it? Thank you.

 

 

Best,

Dhiwaakar Rajasekaran

ReplyQuote
Posted : July 4, 2017 12:00 pm
(@ismael2)
Eminent HOMER

Hi,

Attached you can find matlab and homer file. In the matlab dispatch file in comments this call to the dll (lines 96-105).


Thank you very much for the help

ReplyQuote
Posted : July 5, 2017 1:47 am
(@dhiwaakar)
Illustrious HOMER Admin

Hi Ismael,

 

Thank you for sending the files. Did you make sure the .dll or the library files are available in the same folder as that of the MatlabDispatch function? It runs fine without that function. Sorry but I can't test it with the function since I don't have the library files.

 

 

Best,

Dhiwaakar Rajasekaran

ReplyQuote
Posted : July 6, 2017 12:38 pm
(@ismael2)
Eminent HOMER

Hi,
Yes, I have the files in the same folder as the matlab.
Attached you can find matlab, library and homer file.  In the matlab dispatch, in the line 96-105 is the call of the .dll.

Thank you

ReplyQuote
Posted : July 10, 2017 4:26 am
(@dhiwaakar)
Illustrious HOMER Admin

Hi Ismael,

 

I tried running the model and it did give me an error. The error is due to missing compiler for C/C++ for MATLAB. This is an issue with MATLAB and you should be able to run it after you install a suitable C/C++ compiler for MATLAB. You can find more information on the MATLAB support website for installing a compiler.

 

Best,

Dhiwaakar Rajasekaran

ReplyQuote
Posted : July 10, 2017 1:06 pm
(@ismael2)
Eminent HOMER

 

Hi,

I have simulated the examples that you have in the forum for the MATLAB link and they work fine.

Yes, I have a compiler for MATLAB. I have installed the Microsoft Windows SFDk for Window 7 (7.1), Microsoft Visual C ++ compilers 2010 Standard x64 and x86. So using “loadlibrary” directly from MATLAB works fine.

The problem is when I use “loadlibrary” function inside MatlabDispatch() from homer. Homer does not give me any warning or error, it only appears as in the figure that I attach.

Thank you

Edited: 12 months  ago
ReplyQuote
Posted : July 11, 2017 6:01 am
(@dhiwaakar)
Illustrious HOMER Admin

Hi Ismael,

I discussed with our software development team and this seems like an issue with MATLAB trying to access the .dll/.h file. One possible solution could be to set directory path to access .dll files in MATLAB which again you can find on their support website but we won't be able to provide further support regarding this issue at this point of time.

 

Best,

Dhiwaakar Rajasekaran

 

ReplyQuote
Posted : July 11, 2017 11:14 am
(@ismael2)
Eminent HOMER

Okay, thank you so much for the help.
I will try with the directory and if you find any solution or make some example I will continue looking at the forum.

ReplyQuote
Posted : July 13, 2017 12:15 am
  
Working

Please Login or Register