forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:38 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Fitting superquadratics
PostPosted: Fri Nov 04, 2011 2:18 pm 
Offline

Joined: Fri Nov 04, 2011 1:55 pm
Posts: 4
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
Top
 Profile  
 
 Post subject: Re: Fitting superquadratics
PostPosted: Fri Nov 04, 2011 5:02 pm 
Offline

Joined: Fri Nov 04, 2011 1:55 pm
Posts: 4
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
Top
 Profile  
 
 Post subject: Re: Fitting superquadratics
PostPosted: Sun Nov 06, 2011 10:03 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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


Top
 Profile  
 
 Post subject: Re: Fitting superquadratics
PostPosted: Mon Nov 07, 2011 10:32 am 
Offline

Joined: Fri Nov 04, 2011 1:55 pm
Posts: 4
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 :-(.


Top
 Profile  
 
 Post subject: Re: Fitting superquadratics
PostPosted: Mon Nov 07, 2011 11:19 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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).


Top
 Profile  
 
 Post subject: Re: Fitting superquadratics
PostPosted: Mon Nov 07, 2011 2:21 pm 
Offline

Joined: Fri Nov 04, 2011 1:55 pm
Posts: 4
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
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group