Static optimization using fmincon and quadprog

5 ビュー (過去 30 日間)
Raj Patel
Raj Patel 2020 年 11 月 17 日
コメント済み: Raj Patel 2020 年 11 月 17 日
Can anyone tell me which one os the optimization methods is faster between "fmincon" and "quadprog"? And why is it faster or slower?
Thanks in advance,
Raj Patel

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 17 日
編集済み: Ameer Hamza 2020 年 11 月 17 日
quadprog() is used for a very specific type of optimization problem and, therefore, can be optimized way more than fmincon(). However, note that there is no direct comparison since fmincon() can solve problems which quadprog() cannot. But for a similar problem, quadprog() will be faster. For example
H = [1 -1; -1 2];
f = [-2; -6];
A = [1 1; -1 2; 2 1];
b = [2; 2; 3];
opts1 = optimoptions('quadprog', 'Display', 'off');
opts2 = optimoptions('fmincon', 'Display', 'off');
t1 = timeit(@() quadprog(H, f, A, b, [], [], [], [], [], opts1))
t2 = timeit (@() fmincon(@(x) 1/2*x.'*H*x+f.'*x, rand(2,1), A, b, [], [], [], [], [], opts2))
Result
>> t1
t1 =
8.3352e-04
>> t2
t2 =
0.0081
>> t2/t1
ans =
9.6923
quadprog() is about 10 times faster. You can also check that both fmincon() and quadprog() give same solutions.
  1 件のコメント
Raj Patel
Raj Patel 2020 年 11 月 17 日
Thanks Ameer.
Raj Patel

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by