forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 4:25 am

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  [ 2 posts ] 
Author Message
 Post subject: how to get Levenberg-Marquardt to work
PostPosted: Sun Dec 16, 2012 4:13 am 
Offline

Joined: Sun Dec 16, 2012 4:03 am
Posts: 1
Hi,

I've created a small wrapper in F# for the Levenberg-Marquardt alglib interface. Upon testing with simple functions, it seems to work. However, upon a real-life data set I encounter problems, which lead me to believe that this is due to me not understanding what is going on with the optimizer rather than my wrapper.

Basically my wrapper is a small class that where there are a few tolerances to be set and then a bunch of overloaded "Minimize" methods. The one I am using is:

member this.Minimize (n, (f : float [] -> float), lb, ub, ?startValue) =
let startValue = defaultArg startValue [| for i in 1 .. n do yield 0.|]
let x = ref startValue
let lb = ref lb
let ub = ref ub

alglib.minlmcreatev(1, !x, dstep, state)
alglib.minlmsetcond(!state, epsg, epsf, epsx, maxits)
alglib.minlmsetbc(!state, !lb, !ub)
alglib.minlmoptimize(!state, (fun xa y o -> y.[0] <- (f xa) ), null, null)
alglib.minlmresults(!state, x, rep)

!rep, !x

In particular, I've got a function which takes 40 input parameters and produces a log likelihood function given those values. When I call this:

let r, sol = LM.Minimize(paramCount, targetAlglibFunc, lowerBound, upperBound, allParams)

with
let targetAlglibFunc (x : float []) =
let a= x.[0..tCount-1]
let d = x.[tCount..2*tCount-1]
let rho = x.[paramCount-2]
let hf = x.[paramCount-1]
-(pseudoLogLikelihoodData data t dffunc a d rho hf)

then I get as a result:
alglib+minlmreport {funcidx = -1;
innerobj = alglib+minlm+minlmreport;
iterationscount = 0;
ncholesky = 0;
nfunc = 81;
ngrad = 0;
nhess = 0;
njac = 1;
terminationtype = 4;
varidx = -1;

which seems to indicate that the numerical gradient is 0. However, when evaluating the targetAlglibFunc at typical values and then shifting these by 1% or so, I do get changes in the pseudologlikihood function (a typical order of magnitude here is ~2000 and shifting all input parameters by 1% might shift that value to 5 points or so).

Is there anything obviously/glaringly wrong here?


Top
 Profile  
 
 Post subject: Re: how to get Levenberg-Marquardt to work
PostPosted: Sun Dec 16, 2012 3:06 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Can you post actual code here? It is hard to debug algorithm without looking at code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group