Plot Results of objective function in fmincon

조회 수: 47 (최근 30일)
Amanuel Negash
Amanuel Negash 2020년 11월 21일
댓글: Athul Prakash 2020년 11월 24일
I have t he following objective function
function [ratiioOfID,Breciprocal]= objective(x)
then I have my main script that calls fmincon as following
lb = [1000*10^(-9),1000*10^(-9),10^(-9),10^(-9)];
ub = [100000*10^(-9),100000*10^(-9),50000*10^(-9),50000*10^(-9)];
A = [];
b = [];
Aeq = [];
beq = [];
x0 =[14.65*10^(-6),98.5*10^(-6),6.8*10^(-6),0.56*10^(-6)] ;
options = optimset('TolCon',1e-18,'TolX',1e-19,'PlotFcns',@optimplotfval);
[a,b]=fmincon(@objective,x0,A,b,Aeq,beq,lb,ub,@Filter_function,options);
I want to plot ratiioOfID vs Breciprocal. however this plot gives the following figure and the figure is giving me iteration vs some value. I want to plot the results of ratiioOfID vs Breciprocal. Any help appriciated
  댓글 수: 1
Athul Prakash
Athul Prakash 2020년 11월 24일
I have suggested a solution in my answer below. However, it is not clear how the outputs of your Obj. fun relate to the optimization being performed. objfun should return a single scalar value, which fmincon then tries to minimize. However, objective() in your code returns 2 values and in my experience, fmincon ignores the second output and minimizes the first output value alone (just ratioOfID and doesn't optimize for Breciprocal)
The "some value" that you referred to for the y-axis in your plot may be the value of the first output ratioOfID as it is being optimized over many iterations of the solver running.
Walking through the documentation for 'fmincon' may help you.
Hope it helps!

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

답변 (1개)

Athul Prakash
Athul Prakash 2020년 11월 24일
Hi Amanuel,
@optimplotfval is designed to plot the output of the Objective Function against the number of iterations.
In your case, you may write a custom plotting function and pass that instead of optimplotfval. The syntax of writing a cusotm plot function is described in this doc:
Also have a look at plot functions here:
Hope it helps!

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by