<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:10.0pt;
        margin-left:0cm;
        line-height:115%;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-mailStijl17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:-2;
        mso-list-type:simple;
        mso-list-template-ids:958939590;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:*;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level1 lfo1
        {mso-level-numbering:continue;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:0cm;
        margin-left:0cm;
        text-indent:0cm;
        font-family:Symbol;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">Dear all,<o:p></o:p></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"><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.
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">This is what I've tried so far:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1;text-autospace:none">
<![if !supportLists]><span lang="EN-GB" style="font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-GB">Since I already have a mex-file I thought it would be convienent to use that inside a simple 'Matlab Function'-block. This works in Simulink, but the code generator cannot compile the Simulink diagram to a real-time
executable code.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1;text-autospace:none">
<![if !supportLists]><span lang="EN-GB" style="font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><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.<o:p></o:p></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">
fora</a> and <a href="http://www.mathworks.com/matlabcentral/answers/36879-calling-mex-function-from-within-simulink">
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:<o:p></o:p></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?<o:p></o:p></span></b></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB">Your help will be greatly appreciated!<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="nl">Best,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="nl">Martijn <o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>