Definition of Objective function in fmincon when it's not an analytic function

1 回表示 (過去 30 日間)
Itachi
Itachi 2012 年 9 月 3 日
Hi guys, I want to be able to define the objective function when it's not an analytic function. In my code I'm doing analysis by FEM to find a value for displacement in each iteration but I don't have the displacement function itself. How can I minimize displacement (Objective function) then?
Thanks in advance.

採用された回答

Alan Weiss
Alan Weiss 2012 年 9 月 4 日
You have some function that evaluates the objective, right? Maybe an interpolation as in the Mount Washington example. Toolbox functions don't care what the objective function is, they just need to be able to get function evaluations.
If your objective function is not smooth, as often happens when the evaluation is a simulation or numerical solution of an equation, then you might need to set the finite differences to be larger than default. use the FinDiffRelStep or DiffMinChange options. Or use patternsearch if you have Global Optimization toolbox.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  3 件のコメント
Alan Weiss
Alan Weiss 2012 年 9 月 4 日
My question to you is, do you have a function that evaluates the objective? Is it a file on your MATLAB path? I suppose the answer is yes, and your function looks something like
function objective = mycalculation(x,a,b)
...
where a and b are parameters, and x is the vector of control variables. Then you should write
fun = @(x)mycalculation(x,a,b);
xanswer = fmincon(fun,x0,...)
For more details, see Writing Scalar Objective Functions.
Alan Weiss
MATLAB mathematical toolbox documentation
Itachi
Itachi 2012 年 9 月 7 日
Thanks.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by