Solve linear least square problems with non-linear constraints

I currently have a variable vector A in 3x3 and a set of points X in 3xN.
And I want to minimize the || A*X - X'||, where X' is the target point matrix in 3xN also.
However, I have some non-linear constraints where the elements in matrix A should follow:
  1. , ,
  2. , ,
Do any one know which function should I use? Thanks!

 Réponse acceptée

John D'Errico
John D'Errico le 6 Juin 2020
Someone might tell you to use fmincon. And they would be right, in a sense. But they would be missing an important point.
The constraints in 1 imply these points lie on the surface of spheres of unit radius. However, that also means you can write those sets of THREE numbers in the form of TWO angles per set. That is, since you tell us that
a11^2 + a12^2 + a13^2 = 1
then you can transform the problem into a set of 6 angles, instead of 9 numbers. That is, IF we can write a11,a12,a13 as:
a11 = sin(theta1)*cos(phi1)
a12 = sin(theta1)*sin(phi1)
a13 = cos(theta1)
Then they AUTOMATICALLY, IMPLICITLY satisfy those sum of squares constraints. Likewise, we would have:
a21 = sin(theta2)*cos(phi2)
a22 = sin(theta2)*sin(phi2)
a23 = cos(theta2)
a31 = sin(theta3)*cos(phi3)
a32 = sin(theta3)*sin(phi3)
a33 = cos(theta3)
So you really don't need 9 unknowns. You need to estimate 6 unknown angles.
That will still leave you with 3 other equality constraints. They will look like this, when re-written:
cos(theta1)*cos(theta2) + cos(phi1)*cos(phi2)*sin(theta1)*sin(theta2) + sin(phi1)*sin(phi2)*sin(theta1)*sin(theta2) = 0
You will still want to use fmincon to solve the problem. But now it is a problem with 6 unknowns, not 9. And that will make it much more simple to estimate.

3 commentaires

Thanks for your anwser, that is actually where I start from. The 9 elements represents the 9 positions in a rotation matrix in 3D. I want to estimate this matrix with only rotation(no scaling and translation) between 2 point sets. So I added thoes constraints. I'll try fmincon.
Also, with these 3 unknowns represents in sin and cos functions, is there any possible I could use non-linear least square to solve this problem?
Best,
Chenxi
You cannot use tools like lsqnonlin or lsqcurvefit as I have formulated it in my answer, since there remain nonlinear constraints on the unknowns.
Compute the sum of squares of the errors, returning that to fmincon as the objective function. Supply the remaining constraints as nonlinear constraints, and let it work. You will want to make some guess as to the rotations.
In fact, probably better is to formulate the problem directly as a pure rotation matrix. That really leaves you with only 3 variables, so Euler angles.
With the proper toolbox, you could use quaterions.
Thus, if we look at this as a problem of simple rotations in the form of euler angles, now you could solve it using lsqnonlin, since then all of the constraints are built directly into the matrix, since it becomes a rotation matrix.
Thanks for your reply and help!
I solved this optimization problem by building the objective function direcly with 3 angles(unknowns) in sinusoid function using fmincon with no constraints.

Connectez-vous pour commenter.

Plus de réponses (1)

James Tursa
James Tursa le 8 Juin 2020
Modifié(e) : James Tursa le 10 Juin 2020
If you have two sets of corresponding points from two different coordinate systems and you are simply trying to find the "best" estimated rotation matrix in a least squares sense, see this FEX submission by Matt J:

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by