-
Notifications
You must be signed in to change notification settings - Fork 1
/
matlab_overview.html
254 lines (242 loc) · 11.4 KB
/
matlab_overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="generator" content="jemdoc, see http://jemdoc.jaboc.net/" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="jemdoc.css" type="text/css" />
<title>ACADO from MATLAB</title>
</head>
<body>
<table summary="Table for page layout." id="tlayout">
<tr valign="top">
<td id="layout-menu">
<div class="menu-category">ACADO Toolkit</div>
<div class="menu-item"><a href="index.html">Overview</a></div>
<div class="menu-item"><a href="features.html">Features</a></div>
<div class="menu-item"><a href="licensing.html">Licensing</a></div>
<div class="menu-item"><a href="publications.html">Publications</a></div>
<div class="menu-item"><a href="developers.html">Developers</a></div>
<div class="menu-item"><a href="blog.html">Blog</a></div>
<div class="menu-category">Installation</div>
<div class="menu-item"><a href="install_linux.html">Linux</a></div>
<div class="menu-item"><a href="install_osx.html">OS X</a></div>
<div class="menu-item"><a href="install_windows.html">Windows</a></div>
<div class="menu-category">Interfaces</div>
<div class="menu-item"><a href="matlab_overview.html" class="current">MATLAB interface</a></div>
<div class="menu-category">The Code <br /> Generation Tool</div>
<div class="menu-item"><a href="cgt_overview.html">Overview</a></div>
<div class="menu-category">Support</div>
<div class="menu-item"><a href="documentation.html">Documentation</a></div>
<div class="menu-item"><a href="extra_support.html">Additional</a></div>
<div class="menu-category">For developers</div>
<div class="menu-item"><a href="dev_guide.html">Guidelines</a></div>
<div class="menu-item"><a href="known_issues.html">Known issues</a></div>
<div class="menu-item"><a href="getting_involved.html">Getting involved</a></div>
</td>
<td id="layout-content">
<div id="toptitle">
<h1>ACADO from MATLAB</h1>
</div>
<p>This interface brings the ACADO Integrators and algorithms for direct optimal control, model predictive control and parameter estimation to MATLAB. It uses the ACADO Toolkit C++ code base and implements a thin layer to communicate with this code base.</p>
<div class="infoblock">
<div class="blocktitle">Key Features</div>
<div class="blockcontent">
<p>Three available standard interfaces:</p>
<ul>
<li><p>Use the stand-alone Runge-Kutta and BDF's integrators in MATLAB</p>
</li>
<li><p>Compose your optimization problem in a MATLAB environment with familiar MATLAB syntax using the generic optimal control interface</p>
</li>
<li><p>Write your own C++ code as a MEX-function and compile it using ACADO for MATLAB build-in MEX-compiler</p>
</li>
</ul>
<p>ACADO code generation from MATLAB:</p>
<ul>
<li><p>SIMexport: generate efficient, customized Runge-Kutta integrators which can be accessed from MATLAB</p>
</li>
<li><p>OCPexport: generate efficient, customized OCP solvers which can be accessed from MATLAB</p>
</li>
</ul>
<p>Link your models to ACADO:</p>
<ul>
<li><p>Link MATLAB ODE or DAE models</p>
</li>
<li><p>Link C++ ODE or DAE models</p>
</li>
<li><p>Link C ODE or DAE models with ACADO generated code</p>
</li>
<li><p>Provide optional Jacobians for faster calculations</p>
</li>
</ul>
</div></div>
<h2>Getting started with the MATLAB interface</h2>
<p>To install and use the MATLAB interface you need to have a recent MATLAB version and a C++ compiler installed. Follow these steps to get you started in a few minutes.</p>
<h3>Step 1 - Installing a compiler</h3>
<dl>
<dt>I'm a Linux / Mac user</dt>
<dd><p>Make sure you have installed a recent version of the GCC compiler (at least version 4.4).</p></dd>
</dl>
<dl>
<dt>I'm a Windows user</dt>
<dd><p>Make sure you have installed a recent version the Microsoft Visual C++ compiler, at least version 2010.</p></dd>
</dl>
<h3>Step 2 - Configuring MATLAB</h3>
<p>Once a compiler is installed it needs to be linked to MATLAB. Open MATLAB (a recent version of MATLAB is required) and run in command window:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
>> mex -setup;
</pre></div></div>
<p>MATLAB returns:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n?
</pre></div></div>
<p>Type “y” and hit enter.</p>
<p><b>I'm a LINUX / Mac user</b></p>
<p>MATLAB shows you a list of installed compilers. Enter the number corresponding to the GCC compiler (in this case 1) and hit enter.</p>
<div class="codeblock">
<div class="blockcontent"><pre>
The options files available for mex are:
1: /software/matlab/20XX/bin/gccopts.sh :
Template Options file for building gcc MEX-files
2: /software/matlab/20XX/bin/mexopts.sh :
Template Options file for building MEX-files via [...]
0: Exit with no changes
Enter the number of the compiler (0-2):
</pre></div></div>
<p><b>I'm a windows user</b></p>
<p>MATLAB shows you a list of installed compilers. Enter the number corresponding to the Visual C++ compiler (in this case 2) and hit enter.</p>
<div class="codeblock">
<div class="blockcontent"><pre>
Select a compiler:
[1] Lcc-win32 C X.Y.Z in C:\PROGRA~1\MATLAB\R20XX\sys\lcc
[2] Microsoft Visual C++ 20XX [...] in C:\Program Files...
[0] None
Compiler:
</pre></div></div>
<p>Confirm the result by writing “y” and hitting enter:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
Please verify your choices:
Compiler: Microsoft Visual C++ 20XX [...]
Location: C:\Program Files\Microsoft Visual Studio X.Y
Are these correct [y]/n?
</pre></div></div>
<h3>Step 3 - Building the ACADO interface</h3>
<p>Please download the toolkit code. Our suggestion is to always clone the <b>stable</b> branch:</p>
<ul>
<li><p>Linux and OS X users can check-out the code using <a href="http://git-scm.com" target=“blank”>GIT</a> directly from a terminal. Please execute the following command in a terminal:</p>
</li>
</ul>
<div class="codeblock">
<div class="blockcontent"><pre>
git clone https://github.com/acado/acado.git -b stable ACADOtoolkit
</pre></div></div>
<ul>
<li><p>Windows users can use e.g. <a href="https://code.google.com/p/tortoisegit/" target=“blank”>TortoiseGit</a>:</p>
<ul>
<li><p>Open your file manager and make a folder called “ACADOtoolkit”.</p>
</li>
<li><p>Open tortoise git application and fill in the fields as described <a href="https://code.google.com/p/tortoisegit/wiki" target=“blank”>here</a>:</p>
<ul>
<li><p>Enter the URL for cloning. Our suggestion is to always check out <b>stable</b> branch <tt>https:<i></i>github.com/acado/acado.git</tt></p>
</li>
<li><p>Point “Directory” field to the ACADOtoolkit folder.</p>
</li>
<li><p>Check the “Branch” field and enter <b>stable</b>.</p>
</li></ul>
</li>
<li><p>Click “OK” and wait for the code to be downloaded.</p>
</li>
</ul>
</li>
</ul>
<p>If for any reason you cannot download the code using GIT or you do not want to use GIT (this is not encouraged!), you can download the code in a zip archive</p>
<ol>
<li><p>current code from the <b>stable</b> branch <a href="http://www.acadotoolkit.org/zip/acadotoolkit-current-stable.zip" target=“blank”>acadotoolkit-current-stable.zip</a> or</p>
</li>
<li><p>current code from the <b>master</b> branch <a href="http://www.acadotoolkit.org/zip/acadotoolkit-current-master.zip" target=“blank”>acadotoolkit-current-master.zip</a>.</p>
</li>
</ol>
<p>Those archives are automatically updated after each successfully compiled and tested commit we push to the GIT repository.</p>
<p>Please note you do not need to build ACADO at this stage, you just need to download it. We will refer to the main ACADO folder (<tt>ACADOtoolkit</tt>) as <ACADO_ROOT>. Open Matlab in this directory.</p>
<p>Navigate to the MATLAB installation directory by running:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
cd interfaces/matlab/;
</pre></div></div>
<p>You are now ready to compile the ACADO interface. This compilation will take several minutes but needs to be done only once. Run “make” in your command window:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
make clean all;
</pre></div></div>
<p>You will see:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
Making ACADO...
</pre></div></div>
<p>and after a while when the compilation is finished:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
ACADO successfully compiled.
Needed to compile XYZ file(s).
If you need to restart Matlab, run this make file again
to set all paths or run savepath in your console to
save the current search path for future sessions.
</pre></div></div>
<p>ACADO has now been compiled. As the text indicated every time you restart MATLAB you need to run “make” again to set all paths. When running “make” again no new files need to be compiled and the process will only take a few seconds. However, it is easier to save your paths for future Matlab session. Do so by running “savepath” in your command window (this step is optional).</p>
<div class="codeblock">
<div class="blockcontent"><pre>
savepath;
</pre></div></div>
<h3>Step 4 - Running your first example</h3>
<p>We will now run the OCP getting started example:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
cd examples/ocp/getting_started/
</pre></div></div>
<p>The file getting_started.m contains the ACADO syntax to setup and execute a simple Optimal Control Problem. Run “getting_started” in your terminal to test the execution:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
getting_started;
</pre></div></div>
<p>You should see a report similar to the following one:</p>
<div class="codeblock">
<div class="blockcontent"><pre>
[......]
1: KKT tolerance = 2.016e-001 objective value = 6.4478e-001
2: KKT tolerance = 2.074e+000 objective value = 4.3516e-001
3: KKT tolerance = 1.484e-001 objective value = -2.3787e+000
4: KKT tolerance = 9.130e-002 objective value = -2.3441e+000
5: KKT tolerance = 1.035e-001 objective value = -2.4338e+000
6: KKT tolerance = 5.587e-002 objective value = -2.5326e+000
7: KKT tolerance = 2.741e-002 objective value = -2.5766e+000
8: KKT tolerance = 1.839e-002 objective value = -2.5959e+000
9: KKT tolerance = 1.543e-002 objective value = -2.6105e+000
10: KKT tolerance = 1.494e-002 objective value = -2.6258e+000
11: KKT tolerance = 5.624e-003 objective value = -2.6404e+000
12: KKT tolerance = 1.584e-004 objective value = -2.6456e+000
13: KKT tolerance = 1.214e-008 objective value = -2.6456e+000
convergence achieved.
</pre></div></div>
<p>A graph will be drawn with the results which are stored in the variable 'out’. You're done!</p>
<p>Would you like to read more? Download the user <a href="documentation.html" target=“blank”>manual</a>.</p>
<div id="footer">
<div id="footer-text">
Page generated 2014-09-02 01:01:41 CEST, by <a href="https://github.com/wsshin/jemdoc_mathjax" target="blank">jemdoc+MathJax</a>.
</div>
</div>
</td>
</tr>
</table>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>
</body>
</html>