How to solve geometric (nonlinear) least-square problem?
Subject: How to solve geometric (nonlinear) least-square problem?
From: Clemens Koller
Date: Tue, 26 May 2009 00:22:06 +0200
Hello, Leo,
thank you for your help!
(Thank you too, Rupert, I just wasn't able to test your code yet.)
I was able to follow most of your steps, but it doesn't really work out in
the end. Attached is a sample with real numbers, maybe I can get this example
solved, somehow.
Things that work:
Leo Butler schrieb:
> You haven't set up your problem as you have stated it. The 4-gons
> P and Q are defined by their 4 vertices.
>
> Try:
> (%i2) A: matrix([cos(w),-sin(w),tx],[sin(w),cos(w),ty],[0,0,1]);
>
> (%o2) matrix([cos(w),-sin(w),tx],[sin(w),cos(w),ty],[0,0,1])
> (%i3) P : makelist(matrix([xp[i]],[yp[i]],[1]),i,1,4)$
>
> (%i4) Q : makelist(matrix([xq[i]],[yq[i]],[1]),i,1,4)$
>
> (%i5) R : makelist(A.P[i]-Q[i],i,1,4); LIST OF RESIDUES
>
> (%o5) [matrix([-yp[1]*sin(w)+xp[1]*cos(w)+tx-xq[1]],
> [xp[1]*sin(w)+yp[1]*cos(w)+ty-yq[1]],[0]),
> matrix([-yp[2]*sin(w)+xp[2]*cos(w)+tx-xq[2]],
> [xp[2]*sin(w)+yp[2]*cos(w)+ty-yq[2]],[0]),
> matrix([-yp[3]*sin(w)+xp[3]*cos(w)+tx-xq[3]],
> [xp[3]*sin(w)+yp[3]*cos(w)+ty-yq[3]],[0]),
> matrix([-yp[4]*sin(w)+xp[4]*cos(w)+tx-xq[4]],
> [xp[4]*sin(w)+yp[4]*cos(w)+ty-yq[4]],[0])]
> (%i6) mse : sum( transpose(R[i]).R[i], i,1,4);
>
> (%o6) matrix([(-yp[4]*sin(w)+xp[4]*cos(w)+tx-xq[4])^2
> +(xp[4]*sin(w)+yp[4]*cos(w)+ty-yq[4])^2
> +(-yp[3]*sin(w)+xp[3]*cos(w)+tx-xq[3])^2
> +(xp[3]*sin(w)+yp[3]*cos(w)+ty-yq[3])^2
> +(-yp[2]*sin(w)+xp[2]*cos(w)+tx-xq[2])^2
> +(xp[2]*sin(w)+yp[2]*cos(w)+ty-yq[2])^2
> +(-yp[1]*sin(w)+xp[1]*cos(w)+tx-xq[1])^2
> +(xp[1]*sin(w)+yp[1]*cos(w)+ty-yq[1])^2])
... up to here, everything seems clear to me.
> (%i7) mse : mse[1,1];
But what is this assignment supposed to do?
> Now, substitute for the points on the vertices of the 4-gons. After
> which
That's what I did, I think...
> load(lbfgs)$
> lbfgs(mse,'[w,tx,ty],[0,0,0],1e-4,[1,3]);
This solver seems to do work a bit, but it doesn't really spit out a solution;
it just wraps the lbfgs() operator around the prior input.
Can some of you please feed me with some more details, here.
Thank you very much,
Clemens
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Solution1_Try1.wxm
Url: http://www.math.utexas.edu/pipermail/maxima/attachments/20090526/bc39b0fa/attachment.diff