can I pass these nonlinear constraints to lsqnonlin?

34 vues (au cours des 30 derniers jours)
SA-W
SA-W le 15 Juin 2023
Commenté : Matt J le 30 Juin 2023
Let denote a function of two variables and the parameters of the optimization problem
which I want to solve with lsqnonlin. To calculate , fmust be convex at all iterations. Otherwise, it is purely a matter of luck that the identification works.
My idea is to enforce the convexity by enforcing the Hessian of fto be positiv definite. The determinant of the Hessian is given by (please correct me if I am wrong)
Given that, I would implement the constraints
c =
in a function
function [c,ceq] = mycon(x)
ceq = [];
c = ... % the above formula
end
I evaluate the above equation at n points in the {x,y} space, i.e., c is a vector with nentries.
Can I implement those constraints as nonlinear constraints or do I make things too complicated?
  1 commentaire
Matt J
Matt J le 15 Juin 2023
To calculate sim , f must be convex at all iterations.
Convex as a function of (x,y), I assume you mean. Is is already a convex function of E.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 15 Juin 2023
Modifié(e) : Matt J le 15 Juin 2023
Can I implement those constraints as nonlinear constraints
You can, but you have a few problems:
(1) Nonlinear constraints cannot be enforced at all iterations. In fact, only simple bounds constraints can be.
(2) det(A)>0 is not a sufficient condition for the positive definiteness of A. By Sylvester's criterion, you need to ensure as well, although that will be a simpler, linear constraint in E.
(3) The constraints need to be satisfied for all (x,y) in whatever domain f(x,y) is defined on. In theory, that gives you an unaccountably infinite number of constraints. To be practical, you could relax the constraint, imposing it on some discrete grid of points (x_j, y_j), but in theory, you could not be sure that f(x,y) is convex everywhere between these points.
or do I make things too complicated?
Maybe. You would need to tell us more about the properties of the N_i(x,y) functions and what g^sim() is doing. If the N_i(x,y) functions are all convex individually, then it would be sufficient (although not necessary) to impose the much simpler constraints E_i>=0.
  44 commentaires
Matt J
Matt J le 20 Juin 2023
Modifié(e) : Matt J le 20 Juin 2023
I also mentioned the possibility of adding an additional parameter on the exponentials.
N=@(x) 10*log( 1 + A*exp(a*(x-5)));
With the right selection of A, it doesn't seem too bad
A=0.1;
avalues=linspace(-0.5,0.5,9);
for a=avalues
N=@(x) 10*log( 1 + A*exp(a*(x-5)));
hold on
fplot(N,[0,10])
hold off
end; legend("a="+avalues,'Location','north')
SA-W
SA-W le 20 Juin 2023
I also mentioned the possibility of adding an additional parameter on the exponentials.
Yes, but the additional parameters require additional constraints and, more important, increase the number of parameters by . So it is probably a trade-off: if I do not situate a basis function at every support point, I have to introduce the additional parameters on the exponentials to make the basis more flexible. If I have a higher density of basis functions, I can probably set them to one. Makes intuitively sense?

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 20 Juin 2023
Modifié(e) : Matt J le 27 Juin 2023
Most of the f(x,y) that I am working on are indeed of the form f(x,y)=h(x)+g(y).
If this is true, then ensuring the convexity of f(x,y) is the same as ensuring the convexity of h(x) and g(y) as 1D functions, which is much simpler. I you use 1D linear interpolating basis functions,
h=@(x) interp1([E(1),E(2),E(3),...,En] ,x)
then you can ensure the convexity of h just by ensuring that the second order finite differences are increasing, which is a simple linear constraint on the E(i),
E(i+1)-2*E(i) + E(i+1)>=0
No need for nonlinear constraints at all. Moreover, if you make the change of variables
E=cumsum([C2,cumsum([C1,D])]);
where D(j), C1, and C2 are the new set of unknowns, then the constraints on D required for convexity are simple positivity bounds D(j)>=0. As you'll recall, bound constraints can indeed be enforced at all iterations, which you said is what you wanted.
D=rand(1,20);
C1=-5;
C2=0;
E=cumsum([C2,cumsum([C1,D])]);
fplot( @(x) interp1( E,x ) ,[1, numel(E)] ); xlabel x; ylabel h(x)
  89 commentaires
SA-W
SA-W le 29 Juin 2023
Modifié(e) : SA-W le 29 Juin 2023
I'm not convinced that resnorm is not changing, but maybe it's only doing so to decimal places that are beyond the precision of the display.
Yes, resnorm still changes but at the fifth/sixth digit after the decimal point only.
Or mabe you've landed in a region where the resnorm is unchanging, but the constraints have not yet been satisfied.
What could be a region where the resnorm is unchanging? Where one parameter say increases the objective value and another parameter cancels this out again?
So, more iterations are necessary.
But in those iterations (to satisfy the constraints), I would expect the parameters to change also, which however happens only at the 7th, 8th, 9th digit ... after the decimal point.
Matt J
Matt J le 30 Juin 2023
What could be a region where the resnorm is unchanging?
For example,
fmincon(@(x) 0 ,[5,1],[1,1],1,[],[],[0,0],[],[],optimoptions('fmincon','Display','iter'))
First-order Norm of Iter F-count f(x) Feasibility optimality step 0 3 0.000000e+00 5.000e+00 0.000e+00 1 7 0.000000e+00 4.829e+00 0.000e+00 1.211e-01 2 10 0.000000e+00 2.691e+00 0.000e+00 1.527e+00 3 13 0.000000e+00 0.000e+00 0.000e+00 2.934e+00 Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
ans = 1×2
0.7572 0.1630
which however happens only at the 7th, 8th, 9th digit ... after the decimal point.
Why expect larger changes? You have a StepTolerance of 1e-12.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Nonlinear Least Squares (Curve Fitting) dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by