optimization using fminimax not enough input arguments
7 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have the following example that I need to model on Matlab.
I am using the function fminimax to retrieve values for u and v to characterize my controller. I was asked to find find the minmax of the Hamiltonian function which will lead to the derivatives written below and using these derivatives, matlab will supposedly give me values for x, u and v. So far, I have written the following code, but I am always getting the error "not enough input arguments". How can I use fminimax to find the values of x, u and v?

1 件のコメント
Walter Roberson
2019 年 12 月 27 日
Your Game.m requires that a variable named T be already defined, so we cannot test your code.
回答 (2 件)
Walter Roberson
2019 年 12 月 27 日
x0=[30; 0; 25; 0];
ub=[100; 10000; 100; 100];
lb=[0; 0; 0; 0];
result=fminimax(@myfun,x0,ub,lb);
fminimax has the full calling sequence
X = fminimax(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS)
You can omit starting from the right hand side -- for example it would be valid to call
X = fminimax(FUN,X0,A,B,Aeq,Beq,LB,UB)
However, because parameters are positional in MATLAB, you cannot omit parameters in the middle and still hope to have MATLAB understand you. If you want to pass LB and UB and do not need A, B, Aeq, Beq, then you need to pass [] in the positions of the parameters you do not need:
result=fminimax(@myfun,x0, [], [], [], [], ub,lb);
Meanwhile, you have
function [H] = myfun(T, Q, Tff, lambda)
so myfun needs to be passed 4 parameters, but fminimax will only pass a single parameter (the documentation refers to it as x ) .
Notice the part of the fminimax documentation that says,
Passing Extra Parameters explains how to pass extra parameters to the objective functions and nonlinear constraint functions, if necessary.
6 件のコメント
Walter Roberson
2019 年 12 月 27 日
Mathworks does not create any minimizers that are guaranteed to find the global minima of arbitrary functions. Indeed, it can be proven that it is impossible to create a function that is guaranteed to return the global minima location of arbitrary functions.
Most of the Mathworks optimization functions do not even try to find the global minima: they are local minimizers only. Even the functions such as ga() in the Global Optimization Toolbox do not promise to find the global minima, only to use some strategies that sometimes work.
Because of this, the Mathworks optimization functions that operate on abitrary objective functions never report back that they have definitely found a global minima: instead they just report back that they have found a minima, but warn that it might only be a local minima.
That is what you are seeing: you have found what appears to be a pretty decent minima, a location that is either the exact minima (to within round-off) or very close to it -- but fminimax cannot promise that for sure it is the global minima.
For example, if your function were
H = (x-xs).^2+lambda.*(v-x+u) - (x == 0.74453133950005578878261758291046135127544403076171875) * 1e100;
then at x = 0.74453133950005578878261758291046135127544403076171875 exactly the function would have a huge dip, and there is no possible way that a numeric exploration of the surface that did not happen to try 0.74453133950005578878261758291046135127544403076171875 exactly could possibly detect it.
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
