Why complicate things? In a few recent posts I outlined a way to use
IPOPT from C#. To begin with, I created a DLL using MinGW and MSYS (described
here), and I then called this DLL from C# using P/Invoke (
here and
here).
However, there is no need to build your own DLL, the considerate IPOPT maintainers have already done this for us! Pre-compiled DLL libraries (and include files for C/C++ users) are found
here.
The binaries of the most recent IPOPT version (3.8.1), have been compiled with Visual Studio 2008 (C/C++) and Intel Fortran 8, if I understand correctly. As a test, I have taken the release version of
Ipopt38.dll from the 32-bit distribution instead of the
csipopt.dll I recently built, and called it from my
C# interface. The new DLL works just fine, only faster...
I have noticed two issues, which I am yet to investigate further:
1. When using the debug DLL, I get an exception regarding the callback delegates. When using the release library, I do not encounter this problem. As far as I have been able to tell, data is consistently maintained throughout the optimization when using the release version.
2. The output file from IPOPT is inaccessible to other C# code, even after I have completed the optimization. I have not yet been able to determine if this is purely a timing issue, or if I am not releasing resources correctly in my C# interface.
Finally, I want to direct a sincere thank you to Ramnadh, who commented upon my first post on this matter, asking whether I had managed to build a corresponding DLL in Visual Studio. This comment lead me to looking at the pre-compiled binaries, which in the end turned out to be so successful. Thanks, Ramnadh!