<div class="gmail_quote"><div>Martijn,</div><div><br></div><div>There is an example on the Mathworks File Exchange of nonlinear MPC in an S-function using IPOPT for a 4 tank process. I think the author, Trevor Slade, was using another solver but you can change it to IPOPT with an option change to NLC.solver = 3.</div>
<div><br></div><div><a href="http://www.mathworks.com/matlabcentral/fileexchange/35999-nonlinear-control-of-4-tank-process">http://www.mathworks.com/matlabcentral/fileexchange/35999-nonlinear-control-of-4-tank-process</a>
</div><div><br></div><div>This isn&#39;t exactly how you are trying to implement it but it may give some ideas for your project.</div><div><br></div><div>-John Hedengren</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---------- Forwarded message ----------<br>From: Martijn Disse &lt;<a href="mailto:M.W.Disse@student.tudelft.nl">M.W.Disse@student.tudelft.nl</a>&gt;<br>To: &quot;<a href="mailto:ipopt@list.coin-or.org">ipopt@list.coin-or.org</a>&quot; &lt;<a href="mailto:ipopt@list.coin-or.org">ipopt@list.coin-or.org</a>&gt;<br>
Cc: <br>Date: Tue, 29 May 2012 19:52:54 +0000<br>Subject: [Ipopt] Question: Using IPOPT as an S-function in Simulink<br>





<div lang="NL" link="blue" vlink="purple">
<div>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">Dear all,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">For my thesis work I am using IPOPT as a solver for a Model Predictive Controller. IPOPT is open source and exist of a large collection of files written in C++. I installed the solver to be
 used with Matlab via the OPTI-Toolbox (</span><span lang="nl"><a href="http://www.i2c2.aut.ac.nz/Resources/Software/OptiToolbox.html" target="_blank"><span lang="EN-GB">http://www.i2c2.aut.ac.nz/Resources/Software/OptiToolbox.html</span></a></span><span lang="EN-GB">) which
 come with a precompiled mex-file that acts as a function to call the solver. This works perfectly. However, since I need to use XPC-target or Windows Real Time Target, I need to implement the solver somehow in a Simulink block.
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">This is what I&#39;ve tried so far:<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt;text-autospace:none">
<u></u><span lang="EN-GB" style="font-family:Symbol"><span>·<span style="font:7.0pt &quot;Times New Roman&quot;">        
</span></span></span><u></u><span lang="EN-GB">Since I already have a mex-file I thought it would be convienent to use that inside a simple &#39;Matlab Function&#39;-block. This works in Simulink, but the code generator cannot compile the Simulink diagram to a real-time
 executable code.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt;text-autospace:none">
<u></u><span lang="EN-GB" style="font-family:Symbol"><span>·<span style="font:7.0pt &quot;Times New Roman&quot;">        
</span></span></span><u></u><span lang="EN-GB">Creating an S-function in which I call the .mex function. This code cannot be compiled since the .tlc file is missing.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">After some search on
<a href="http://www.mathworks.se/matlabcentral/answers/38962-call-a-mex-function-from-simulink" target="_blank">
fora</a> and <a href="http://www.mathworks.com/matlabcentral/answers/36879-calling-mex-function-from-within-simulink" target="_blank">
Matlab central</a>, I found out that I should create a C MEX S-function and compile it. To make life easier, Simulink comes with an S-function builder in which libraries etc. can be added. I failed in constructing one and it is driving me crazy. My question
 to you therefor  is:<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span lang="EN-GB">Who has experience in compiling IPOPT (or any other set of C++ files) to act as an S-function in Simulink and is willing to point me in the right direction?<u></u><u></u></span></b></p>

<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">Your help will be greatly appreciated!<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="nl">Best,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="nl">Martijn <u></u><u></u></span></p>
<p class="MsoNormal"><u></u> </p></div></div></blockquote></div>