forum.alglib.net
http://forum.alglib.net/

Fitting superquadratics
http://forum.alglib.net/viewtopic.php?f=2&t=469
Page 1 of 1

Author:  Lorenz747 [ Fri Nov 04, 2011 2:18 pm ]
Post subject:  Fitting superquadratics

Hi there,
I'm trying to fit a superquadratic to a given 3D point set. Im using a so called "inside out function" for this. In order to find the minimum of this function I want to use the conjugate gradient method.
I tried a lot but it just wont work with my code. I get an error thwron when I’m trying to call the minlbfgsoptimize() function with my mincgstate-, and function-pointer. It says: "None of the 2 overloads could convert all the argument types".

I hope u guys can help me out with this.
Kind regards
Lorenz

Attachments:
Superquadratics.h [936 Bytes]
Downloaded 676 times
Superquadratics.cpp [3.36 KiB]
Downloaded 702 times

Author:  Lorenz747 [ Fri Nov 04, 2011 5:02 pm ]
Post subject:  Re: Fitting superquadratics

Hi

I just found the solution to my problem:
1. I used the wrong function -_- It should've been the mincgoptimize() instead of the minlbfgsoptimize() function
2. The protected global variable OriginalData_ needs to be a static variable

With these changes I get my three values in x[] and they work fine with my calculations. But a another problem just came up. My "inside out function" is not 3 dimensional but instead has 5 arguments. I thought it would be no problem to just write two more elements in my x vector: x[1,1,1,0,0]. But with this vector I just get NaN's as results. Is it even possible to let ALGLIB calculate the minimum of a 5 or >5 dimensional function? Or maybe the derivatives of the "inside out function" is to difficult to calculate? The "inside out function" of a superquadratic is defined as followed:
Image
The following function is then to be minimized:
Image

Also I added the new code.

Kind regards
Lorenz

Attachments:
File comment: New code
Superquadratics.cpp [3.42 KiB]
Downloaded 720 times
File comment: New code
Superquadratics.h [907 Bytes]
Downloaded 642 times

Author:  Sergey.Bochkanov [ Sun Nov 06, 2011 10:03 am ]
Post subject:  Re: Fitting superquadratics

That depends on the specific parameters you want to tweak. I suppose that you want to find minimum in the (x,y,z) space leaving a1/a2/a3/eps1/eps2 fixed. Then you should either:
a) minimize in 3-dimensional space (x,y,z) and use additional ptr parameter of the mincgoptimize() to pass a1/a2/a3/eps1/eps2 to the staticFunction1_grad
b) minimize in 8-dimensional space (x,y,z,a1,a2,a3,eps1,eps2) with MinLM optimizer and fix last 5 variables to some specific values with bound constraints

Author:  Lorenz747 [ Mon Nov 07, 2011 10:32 am ]
Post subject:  Re: Fitting superquadratics

Hi,
thank your very much for your response. Actually, i want to do the exact opposite. I want to find the minimum in the (a1/a2/a3/eps1/eps2) space. The x y z coordinates are known and therefore used as constant values.
I tried to set the derivatives manually using "Wolfram Alpha's" derivatives. I still get the NAN results :-(.

Author:  Sergey.Bochkanov [ Mon Nov 07, 2011 11:19 am ]
Post subject:  Re: Fitting superquadratics

I've looked at your problem one more time - it seems that you need boundary constraints on all of your variables. You have to constrain x so it is non-negative, a1 so it is strictly positive and so on. Otherwise you will have situations like raising negative number to the fractional power.

You should switch to minLM optimizer, which allows you to work with sum-of-squares problems subject to bound constraints. Unfortunately, you can't set constraint like a1>some_value - only a1>=some_value is possible. So positivity constraint should be written as a1>0.00001 (or some other small value).

Author:  Lorenz747 [ Mon Nov 07, 2011 2:21 pm ]
Post subject:  Re: Fitting superquadratics

Hi there,

I tried computing the minimum with the minLM optimizer. Strangley I get the input vector x [1,1,1,0.1,0.1] as result. Sry but I cant figure out what I did wrong again.
It would be nice if you could take a look at my code one more time.

Thanks in advance

Lorenz

Attachments:
Superquadratic.h [917 Bytes]
Downloaded 577 times
Superquadratic.cpp [2.95 KiB]
Downloaded 655 times

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/