Java - Help Converting Math Function Into Code - Linear Kalman Particle Swarm Optimization - Stack Overflow

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

3/13/13

java - Help Converting Math function into Code : Linear Kalman Particle Swarm Optimization - Stack Overflow

Help Converting Math function into Code : Linear Kalman Particle Swarm Optimization

I'm trying to convert the math presented on this paper: http://www.bouncingchairs.net/pskalman-lategecco.pdf Around page 3 forward into working code. The algorithm itself is given around page 6, but I don't speak greek or math; so for the time being I'm stuck. If I understand the code, it should run down like this: v =pril vlct,1 ary t atce eoiy d ra vet=bs pril vlct 1 ary bs et atce eoiy d ra vpie=1 soaeary _rm d trg ra vht=1 soaeary _a d trg ra apa=04 lh .5 sga=06 im .0 dnm=fot eo la dnmbs =fot eo_et la Prep: friti=0 i<v.egh i+ o(n ; tlnt; +) { dnm+ v[]^2 eo = ti dnmbs + veti ^2 eo_et = bs[] } dnm=dnm^(/) eo eo 12 dnmbs =dnmbs ^(/) eo_et eo_et 12 Equation 7: friti=0 i<v.egh i+ o(n ; tlnt; +) { vpiei =apa*(ti/eo)+( -apa *(bs[]dnmbs) _rm[] lh v[]dnm 1 lh) veti/eo_et } Equation 8:

friti=0 i<v.egh i+ o(n ; tlnt; +) { vhti =Rn_as(_rm[] sga /gusa rno nme wt _a[] adGusvpiei, im) /asin adm ubr ih /vpiei aeae adsgaSDv /_rm[] vrg, n im te } Equation 9: friti=0 i<v.egh i+ o(n ; tlnt; +) { v[]=(lh *dnm+( -apa *dnmbs)*vhti ti apa eo 1 lh) eo_et _a[] } Is this even close to what the math is saying? Thanks in advance, -JW
java c++ ruby optimization pso

asked Apr 30 '11 at 22:34 JWally 47 7

1 If you don't understand the maths, wouldn't it be better to spend some time to learn the maths, rather than stackoverflow.com/questions/5845064/help-converting-math-function-into-code-linear-kalman-particle-swarm-optimizat

1/2

3/13/13
1

java - Help Converting Math function into Code : Linear Kalman Particle Swarm Optimization - Stack Overflow
If you don't understand the maths, wouldn't it be better to spend some time to learn the maths, rather than just blindly implementing stuff? Oli Charlesworth Apr 30 '11 at 22:52 Oli, thanks for the comment. I've already constructed a bare-bones version of PSO JWally Apr 30 '11 at 23:08 which works nicely, but gets stuck sub-optimally in a 30 dimensional rastrigen(sp) function. I wanted to experiment with this cookbook approach to ensure that it behaves how I want; before investing the time and effort learning the notation and theory behind something that is of little use to me. If there's anything else I can provide please don't hesitate to let me know. JWally Apr 30 '11 at 23:15 My comment wasn't meant to be facetious. It's just that with something this complicated, if you don't have a good grasp of what the maths means, you're going to have great difficulty debugging it or experimenting with it in any meaningful way. Oli Charlesworth Apr 30 '11 at 23:20

1 Answer
I think you might be missing the calls to "norm(...)". Normalizing a vector is just dividing each component of the vector by the length. In Equation 9, they calculate the weighted sum of the lengths of vt and vbest and multiply that average length by norm(vbar). You're just multiplying it by vbar directly. The intent behind that equation seems to be to create a new vector v_{t+1} whose length is the average length of vt and vbest. However, vhat could be any length at all, so the multiplication in Equation 9 most of the time won't give you the correct answer unless you force the length of the vhat vector to be exactly one. That's what the vector norm does. The norm is just the components of the vector divided by the length. So replace your code for equation 9 with something like this: vln0 te= friti0 iv.egh i+ o(n =; <tlnt; +) { vln=ti*ti; te+v[]v[] } vlnsr(te) te=qtvln; friti0 iv.egh i+ o(n =; <tlnt; +) { v[]=(lh *dnm+( -apa *dnmbs)*(_a[]/vln; ti apa eo 1 lh) eo_et vhti te) } You've also ignored the norm operation in Equation 7. I haven't read the paper, but it may not be strictly necessary here as the weights sum to one and the vectors are already normalized. I'd have to spend a bit more time to convince myself one way or the other, but it certainly wouldn't hurt to go ahead and normalize that calculated v' vector too.
answered May 1 '11 at 2:53 deong 1,729 3 10

Not the answer you're looking for? Browse other questions tagged java c++ ruby
optimization pso or ask your own question.

stackoverflow.com/questions/5845064/help-converting-math-function-into-code-linear-kalman-particle-swarm-optimizat

2/2

You might also like