fminunc for upper and lower bound variable definition ?

조회 수: 18 (최근 30일)
HN
HN 2020년 11월 4일
편집: HN 2020년 11월 5일
Isn't it possible to give upper and lower bound for the variables in the objective function while using fminunc ?
Thank you.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 4일
No, fminunc() is for unconstrained optimization. If you want to do constrained optimization, then use fmincon().
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 11월 4일
right, fminunc is UNConstrained
HN
HN 2020년 11월 4일
Is fmincon() quasi-newton as well ?
Thank

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

추가 답변 (1개)

Bruno Luong
Bruno Luong 2020년 11월 4일
편집: Bruno Luong 2020년 11월 4일
You could transform variables, x will be opened bounded by lo/hi
xfun = @(y) lo + (hi-lo).*sin(y).^2
...
y = fminunc(obj(xfun(y)), ...)
x = xfun(y)
Honestly I don't like those kind of transformation.
Use the right tool: fmincon as others have suggested.
  댓글 수: 9
Walter Roberson
Walter Roberson 2020년 11월 5일
fun = @(x)[x1L;x2L;x3L]+([x1U;x2U;x3U]-[x1L;x2L;x3L]).*PRSopt_QN1(x(1,:),x(2,:),x(3,:))
Unless two of x1L, x2L, x3L are empty and the third is a scalar, then you can be sure that function is going to return something that is not a scalar. You do not take the mean() there.
HN
HN 2020년 11월 5일
편집: HN 2020년 11월 5일
Thank you Walter Roberson,
I correct it like this. But it only gives some of the output arguments . Moreover, How can I define the option without defined Hessian ? Thanks
A = [];
b = [];
Aeq = [];
beq = [];
%%
LB = [deg2rad(120),deg2rad(-150)];
UB= [deg2rad(150),deg2rad(-120)]
x=[1;deg2rad(130);deg2rad(-130)];
fun = @(x)PRSopt_QN(x(1),x(2))
% [V,fval] = fmincon(fun,x)
[V,fval,exitflag,output,lambda,grad,hessian] = fmincon(fun,x,A,b,Aeq,beq,LB,UB)
AverageF=PRSopt_QN(x(1,:),x(2,:));

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by