Find constraints on polynomial coefficients optimization

조회 수: 3 (최근 30일)
AdarG
AdarG 2019년 7월 11일
댓글: AdarG 2019년 7월 13일
I am trying to find the optimal coefficients of the polynomial of the form:
theta=a1*t^2 +a2*t+a3 (i.e., to find a1,a2,a3) for some cost function.
I'm using patternsearch and I need to formulate the nonlinear/linear constraints on a1,a2,a3.
The problem is that I have constraints on theta (say [lb,ub]) and the range of t (say [0,T]), but not on the coefficients themselves.
So far, I've managed to formulate these constraints:
lb<a3<ub;
lb<a1*T^2+a2*T+a3<ub;
I can't figure out the 3rd constraint on the extrimum on t=-a2/(2*a1). I care only if is in the rectancle [0,T],[lb,ub].
Any idea?
  댓글 수: 6
Walter Roberson
Walter Roberson 2019년 7월 11일
Those are not real constraints on the variables, only on theta.
AdarG
AdarG 2019년 7월 11일
Now I understand. I will clarify,
  1. I don't want to find the minimum of theta, but a minimum of some cost function that the polynomial is producing (it envolves a very complicated ode).
  2. I have constraints on theta.
  3. Since my design parameters are a1,a2,a3, I need to reformulate the constraints on them.

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

채택된 답변

Bruno Luong
Bruno Luong 2019년 7월 12일
편집: Bruno Luong 2019년 7월 12일
Why can't you implement
ts := max(min(-a2/(2*a1),T),0);
Then add the 6 constraints into your minimization pb:
two non-linear (and not differentiable):
lb <= theta(ts) <= ub
four non equality linear contstraints;
lb <= theta(0) <= ub
lb <= theta(T) <= ub
  댓글 수: 5
AdarG
AdarG 2019년 7월 13일
Thanks, that did the trick.
I used your function
function [c,ceq] = nlcon(a,T,lb,ub,thetafun)
ts = max(min(-a(2)/(2*a(1)),T),0);
yts = thetafun(a,ts);
c = [yts-ub;
lb-yts];
ceq = [];
end
I understood that c must give the same number of elements at every call, so I can't use the syntax I was using with the if statement.
AdarG
AdarG 2019년 7월 13일
Although this issue is solved, when I run the optimization, the optimizator runs alot of function evaluations but with no iteration progress, so the optimization is verrrrrry slow.
I checked that the non linear constratint function works properly and it does.
Any idea why so many evaluations performed?

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

추가 답변 (2개)

Matt J
Matt J 2019년 7월 11일
편집: Matt J 2019년 7월 11일
What's to figure out? You've already articulated that the (nonlinear) constraints on the extremum are,
0<=-a2/(2*a1)<=T
The only thing I might recommend is that converting them to linear constraints,
0<=-a2<=2*T*a1
a1>=0
might make things easier for patternsearch.
  댓글 수: 6
AdarG
AdarG 2019년 7월 12일
My cost function throws an error when input out-of-bounds values, so I am forced to do the optimization in one go. :(
Matt J
Matt J 2019년 7월 12일
You should just set out of bound values to Inf.

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


Matt J
Matt J 2019년 7월 11일
편집: Matt J 2019년 7월 11일
It might be more natural here to use fseminf,
x = fseminf(fun,[a1,a2,a3], 2, @(a,s) seminfcon(a,s,T,lb,ub));
function [c,ceq,K_ub,K_lb,s]= seminfcon(a,s,T,lb,ub)
% No finite nonlinear inequality and equality constraints
c = [];
ceq = [];
% Sample set
if isnan(s(1))
% Initial sampling interval
s = [0.01 0; 0.01 0];
end
t1 = 0:s(1):T;
t2 = 0:s(2):T;
% Evaluate the semi-infinite constraint
K_ub = polyval(a,t1)-ub;
K_lb = lb - polyval(a,t2);
end

Community Treasure Hunt

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

Start Hunting!

Translated by