フィルターのクリア

How do I use GlobalSearch to solve the minimal problem of a customized function with two outputs

1 回表示 (過去 30 日間)
I code a customized function U ,it has a input d which is a 5-dimensional vector, a output 'flag' ,and a output 'P' witch is the parameter I want to find it's minimal value:
function [P flag]=U(d)
...
end
The question is how can I to use GlobalSearch to find the minimal value of P.
Thanks for helping me....

採用された回答

infinity
infinity 2019 年 6 月 19 日
Hello
I will give an example of find minimum value of objective function
First, we can create the objective function, named by U(x), for example
function res = U(x)
res = sqrt(x(1)^2 + x(2)^2 + x(3)^2 + ...
x(3)^2 + x(4)^2 + x(5)^2);
Then, we can use the globalsearch as follows
problem = createOptimProblem('fmincon','objective', ...
@(x) U(x), 'x0', [1 1 1 1 1], 'lb', [-3 -3 -3 -3 -3], ...
'ub', [3 3 3 3 3]);
gs = GlobalSearch;
[x, f] = run(gs, problem)
where x0 = [1, 1, ..., 1] is the initial guess, lb is the lower bound of the varibale, ub is the upper bound of the variable and x is the optimal solution, f is the minimum value of the objective function corresponding to x.
Best regards,
Trung
  6 件のコメント
mathy
mathy 2019 年 6 月 20 日
Your answers do help me a lot! Thank you again for your patience and your answers!
infinity
infinity 2019 年 6 月 20 日
I am glad to know your problem has been solved.
You are wellcome!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by