why points examined in Pattern Search exceed the lower or Upper bounds and is there any way to avoid this?

조회 수: 3 (최근 30일)
hello everyone,
recently I was using patternsearch to minimize a function. I set the lower bound to lb = [1e-6 -1e6] and the upper bound to ub = [1e-1 -1e4].
However, during the run, an error came out saying
"Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 797)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in globalsearchnlp
X =
0.0091296875 -169992.606079102"
Clearly, the examination point lead to the error exceed the lower bound I set. I don't know why this happens and if there is any way to avoid it.
Thanks
Adam

채택된 답변

Gifari Zulkarnaen
Gifari Zulkarnaen 2020년 4월 5일
편집: Gifari Zulkarnaen 2020년 4월 5일
What is your initial point and initial mesh size? Perhaps these already exceeds your bounds.
Edit:
Hmm, what if you normalize your variables and bounds (and modify the objective function too) into similar range? For example:
global lb_ori ub_ori % make global so that these variables can be called inside a function
% Original bounds
lb_ori = [1e-6 -1e6];
ub_ori = [1e-1 -1e4];
% Normalized bounds
lb_norm = [0 0];
ub_norm = [1 1];
% Run pattern search with normalized variables, bounds, and objective function
x0 = rand(1,2); % random number within 0 and 1 (normalized bounds)
[x,fval] = patternsearch(@objective_norm,x0,[],[],[],[],lb,ub)
% Original objective function
function fval = objective_ori(x)
fval = sum(x.^2); % an example objective function
end
% Normalized objective function
function fval = objective_norm(x_norm)
global lb_ori ub_ori
x = x_norm.*(ub_ori - lb_ori) + lb_ori;
fval = sum(x.^2);
end
Not sure if this code works, but do you get my idea of normalization?
I am not sure how the mesh size behaves in Matlab pattern search when the variables have significant different ranges, we can only see one mesh size even though it should be different for each variable. But normalization should solves this.
  댓글 수: 3
Haitao zhao
Haitao zhao 2020년 4월 7일
Hi Gifari
Thank you very much for your reply.
It is absolutely my fault that I set the wrong lower bound which should be [1e-6 -1e5 ] not [1e-6 -1e6]. Actually, it is this wrong setting leads to the error message. Thank you very much for your time. I am very sorry for my careless.
Best regards,
Adam

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by