guesses of parameters in fmincon do not satisfy the constraints in nonlcon

5 visualizzazioni (ultimi 30 giorni)
Hi all,
I am trying to maximize an objective function over few coefficients using fmincon with two non-linear constraints. However, despite the constraints I put, the algorithm chooses guesses of the parameters which violate the contraints I imposed. The coefficients I am maximizing over define a function with time support and domain . In other words, by guessing the coefficients, i am guessing a functional form over . In particular, my function is:
where are chebyshev polynomials of order i and are the weights associated with those polynomials, is a known and fixed scalar. Optimization is done over in order to maximize some function of the functional form above. Now, I want that guesses for the coefficients to be such that: 1) the maximum over t of the functional form above is smaller than 0.5 and 2) the minimum over t of the functional form above is larger than 0.05 . To this end I wrote the following constraint:
function [c,ceq]=constr(coeff,pol,xstar)
T=700;
tgrid=1:T;
c1=max(sum(coeff(2:end).*pol).*exp(-coeff(1).*tgrid)+(1-exp(-coeff(1).*tgrid))*xstar)-0.5;
c2=max(-(sum(coeff(2:end).*pol).*exp(-coeff(1).*tgrid)+(1-exp(-coeff(1).*tgrid))*xstar))-0.05;
c=[c1; c2]
ceq=[];
end
where pol is a mxT matrix of chebyshev polynomials of order m on the interval .
The line in which I am calling the maximizer is the following:
[coeff]=fmincon(@(coeff) optimphi_approx(param,coeff,pol),coeff0,[],[],[],[],[],[], @(coeff) constr(coeff,pol,xstar));
I don't manage to understand why fmincon chooses guesses of parameters which violate my non-linear constraints. Any idea and comment is welcomed.
Thanks in advance,
Sarah

Risposta accettata

Matt J
Matt J il 14 Apr 2021
Modificato: Matt J il 14 Apr 2021
Did fmincon report successful convergence? The code you've shown doesn't call fmincon with the exitflag output or show the exit message, so we don't know if fmincon even thinks it succeeded. Also, you haven't mentioned the size of the violation in relation to he ConstraintTolerance parameter, so I'm assuming you may not be aware that even when it succeeds, we do not expect fmincon to perfectly satisfy the constraints.
One suggestion I would make as well is that you omit max operations in your constraints because it violates fmincon's assumption of differentiability. Note that an expression max(z)<=C can alternatively be written z<=C.
  1 Commento
Matt J
Matt J il 14 Apr 2021
Modificato: Matt J il 14 Apr 2021
Note that an expression max(z)<=C can alternatively be written z<=C.
And if you do this, I believe your constraints become linear in the a_i for each fixed lambda. It may therefore be a good alternative strategy to do a loop over samples of lambda and use fmincon or similar to solve the linearly constrained sub-problem over a_i for each candidate value of lambda. This way, you may avoid the knotty issues associated with non-linear constraints.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 14 Apr 2021
Solvers can violate bounds constraints with some options:
But that is talking about bounds constraints, not about nonlinear constraints.
All fmincon algorithms are permitted to violate the nonlinear constraints during the initial evaluations to estimate the jacobian.

Community Treasure Hunt

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

Start Hunting!

Translated by