Conjugate gradient method
kdipakj
02-27-2004, 05:48 AM
Dear Friends,
I want to know some of the points about Conjugate Gradient method.
I am using this method for cone fitting problem. In this case I want to minimise deviation function d(defined below)
suppose we have function d(i,j,k,a,b,c, A)
where i, j, k -are axis direction coeff.
a, b,c -is apex of cone
A- slope of the cone.
Now I want to Know
(1)should i use directly function d for mionimization
or is it required to find out function as given on page 414(nr)
(2). is convergence always possible.
If anybody knows about this, please do mail.
With regards,
Dipak
lionchong
10-10-2005, 02:45 PM
on my book there is no function on page 414, you'd better specify the function name and sections
if you mean the f1dim function, it depends on wrt. how many parameters you want to optimize your function. if only 1, you can directly use ur own function. otherwise, you'd better use the f1dim function to transform the changes in abscissa to changes of vectors. the f1dim is a bridge between the linmin and frprm
janvanderpeet
12-13-2005, 10:44 AM
lionchong,
I apologize for breaking in in your answer to a question of someone else than myself. I have some problems with working with f1dim and you appear to know how to handle
f1dim.
I want to minimize the function
F = (X(1) - 2) ^ 4 + (X(1) - 2 * X(2)) ^ 2
and calculate the value of F in FUNC2 which is called by DFPMIN. In fact is my user function much more complicated, but because I do not completely understand the routine DFPMIN I use, I work with an worked-out example to learn how everything works.
According to the NR documentation the function
F1DIM is used as a means to calculate the parameterrs one by one and F1Dim has the parametervector X as parameter. Can I manintain de vector X as (X(1), X(2)) or should I use X(1) the first time and X(2) the second time. If so, the use of F1Dim seems useless to me.
To keep it short: Can you explain to me what to do with
F1DIM and what in my case the function should look like?
Thanks in advance.
lionchong
12-13-2005, 11:09 AM
janvanderpeet, you're welcome.
As far as i understand, in order to compute the value of F, the inputs of your function FUNC2 should be a vector with two elements, say X = (X1, X2). However, if you use the conjugate gradients method or what else introduced in chapter 10 of the NR book, you will find that the output of those optimization methods are a scalar value, say, a. This "a" describes the shift from your original vector X to a new point vector Y, along a certain direction D, which is also a vector. Therefore, in order to compute the value of F in your function FUNC2 at the point Y (which is a better estimate of the minimum point than X), you need the f1dim function to transform the output a to the input Y. This is what the function f1dim did. In equation, it is
Y = X + a*D.
janvanderpeet
02-08-2006, 07:01 AM
Dear lionchong,
Thank you for your respons to my question about f1dim. It took me some time to thank you because I had other work to do for a while. I am still struggling with DFPMIN. My question about f1dim arose because I thought I had to do something with it, but apparently DFPMIN calculates the various values of X.
I have another question. In calculating the partial derivatives I asssume that I have to add the partial derivatives per line to the derivatives for the whole sample to optimize. Otherwise you would get as many solutions as there are values in the sample. From the book of George Levy: Computational Finance I have, this is not clear. Am I right aboput this?
janvanderpeet
03-11-2006, 08:52 AM
Dear lionchong,
I continue to have problems with DFPMIN in the Basic version of NR. DFPMIN requires calculation of derivatives. DFPMIN calls LINMIN which in turn calls MNBRAK. MNBRAK calls BRENT (fret = BRENT) which requires no derivatives. And according to the introduction to chapter 10 DBRENT should be used in case of derivatives.
So I assume I should in MNBRAK call DBENT instead of (as indicated in the code) BRENT. Am I right?
Anoher problem I have is the following:
DFPMIN uses as user function FUNC2 and as derivative function DFUNC. BRENT and DBRENT use as user function FUNC and as derivatives function DF. Can I use FUNC2 and DFUNC in MNBRAK?.
MNBRAK is initialized by AX and XX (AX and BX in the declaration) and then FUNC(AX) and FUNC(BX) are calculated. But because I use DFPMIN for calculation of the parameters for a GARCH-model my user function cannot use the values of AX and BX.
What should I do? As you see I am new to NR and think the explanations are sometimes not very clear.
Thanks in advance for your help.