[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Speed of Ocave vs Matlab?
From: |
rocketsound |
Subject: |
Re: Speed of Ocave vs Matlab? |
Date: |
Tue, 8 Sep 2015 04:20:44 -0700 (PDT) |
For linear systems like a PT3 system and (positive definite) quadratic cost
functions, standard MPC controllers (like quasi infinite horizon MPC) can
always be written as a (quadratically constrained) quadratic programs thus
I'm using qp/quadprog in order to find the optimizer that I want to apply in
every MPC interation. I noticed that qp's speed is acceptable if the
problem's dimension is not "too large" which of course is pretty sketchy to
claim so let me give you more details: While writing this answer I run an
script that calculates a zero-terminal constraint MPC which is numerically
demanding because of the punctiform terminal constraint of the state vector.
I profiled two runs with a different prediciton horizon: The first run had
40 optimization variables and the second run had 100 optimization variables.
This is the result of the profiler:
40 optimization variables wrote
> # Function Attr Time (s) Time (%) Calls
> ---------------------------------------------------------------------
> 83 blkdiag 7.751 21.19 14200
> 85 cell2mat 5.892 16.11 14200
> 153 __line__ 3.648 9.98 251
> 112 __qp__ 3.424 9.36 50
> 84 cellfun 3.355 9.17 129063
> 155 __go_line__ 2.236 6.11 251
> 123 set 1.987 5.43 1272
> 13 ishandle 1.313 3.59 521
> 1 MPC_Exercise1_Solution 1.220 3.34 1
> 9 get 0.674 1.84 7521
> 2 clear 0.404 1.11 151
> 88 num2cell 0.304 0.83 14254
> 46 all 0.221 0.60 57672
> 140 __plt__ 0.214 0.58 200
> 37 zeros 0.192 0.53 15004
> 89 cat 0.185 0.50 14200
> 29 prefix ! 0.149 0.41 120895
> 125 __plt_get_axis_arg__ 0.140 0.38 906
> 87 sort 0.138 0.38 14200
> 6 binary == 0.129 0.35 86151
100 optimization variables wrote
> # Function Attr Time (s) Time (%) Calls
> ---------------------------------------------------------------------
> 121 __qp__ 35.160 34.83 50
> 94 blkdiag 21.028 20.83 35200
> 96 cell2mat 14.811 14.67 35200
> 95 cellfun 5.888 5.83 318063
> 158 __line__ 3.730 3.70 251
> 1 MPC_Exercise1_Solution 3.217 3.19 1
> 160 __go_line__ 2.772 2.75 251
> 130 set 2.071 2.05 1272
> 52 zeros 1.961 1.94 36004
> 13 ishandle 1.305 1.29 530
> 28 num2cell 0.734 0.73 35257
> 9 get 0.676 0.67 7531
> 32 all 0.543 0.54 141675
> 99 cat 0.482 0.48 35200
> 2 clear 0.424 0.42 151
> 21 prefix ! 0.377 0.37 288904
> 98 sort 0.366 0.36 35200
> 6 binary == 0.299 0.30 191160
> 63 false 0.293 0.29 74164
> 58 size 0.293 0.29 106169
As you can see, qp is the bottelneck here. Doubling the problem dimension
creatly increases the simulation time. I added Matlab's results as an
attachment to this reply (it is 1,206 s and 5,158 s).
40 optimization variables: profiler_40.png
<http://octave.1599824.n4.nabble.com/file/n4672497/profiler_40.png>
100 optimization variables: profiler_100.png
<http://octave.1599824.n4.nabble.com/file/n4672497/profiler_100.png>
For even more optimization variables and more complex constraints the
overall simulation time gets worse.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Speed-of-Ocave-vs-Matlab-tp4672488p4672497.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
Re: Speed of Ocave vs Matlab?, Markus Bergholz, 2015/09/07
Re: Speed of Ocave vs Matlab?, Sebastian Schöps, 2015/09/08