Optimizing a function from a given set?

조회 수: 12 (최근 30일)
Mohamed Larabi
Mohamed Larabi 2018년 6월 17일
댓글: Walter Roberson 2018년 6월 17일
Is there a way to find the optimal value of a minimized function from a given set of solutions?
Here is an example of what I would like to do:
For x in {0,0.5,1}, solve: x = arg max f(x).
I think I would need a variation of "fminbnd", as this one uses a given interval of solutions, while I need a given set of solutions.
Any suggestion would be very much appreciated. Thank you

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 17일
For an explicit list of arguement values, x:
[bestfval, bestidx] = max(arrayfun(@f, x))
bestx = x(bestidx);
If the function is fully vectorized then
[bestfval, bestidx] = max(f(x(:)));
bestx = x(bestidx);
  댓글 수: 2
Mohamed Larabi
Mohamed Larabi 2018년 6월 17일
Your answer replies perfectly to the problem stated. But I made a mistake while I typed it. It is:
For x in {0,0.5,1}, solve: x = arg max x*f(y). If you have any thoughts about it, please let me know.
Walter Roberson
Walter Roberson 2018년 6월 17일
If the task is to find the y that maximizes x*f(y) for each given x, then the answer is going to be the same as the y that maximizes f(y) without considering the x because multiplication by positive x is a linear operator. If some of the x could be negative and some positive then you could have a more interesting situation.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mohamed Larabi
Mohamed Larabi 2018년 6월 17일
The task is to find the x, while f(y) is given. I am trying to simplify my problem as much as I can to be understandable by the overall Matlab community. What I actually need to do is to numerically solve HJB (Hamilton-Jacobi-Bellman) problem. It is dynamic programming. Do you have any reference or link to share about it? Thank you very much.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 6월 17일
If f(y) is given, then the x that maximizes x*f(y) is:
if f(y) > 0
bestx = max(x);
elseif f(y) < 0
bestx = min(x);
else
all finite non-nan entries in x give the same result
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by