comment + checking DE optimizer
Andrew: bugfixes
Anrew: test-density.R and test-models.R
Andrew: PSO related debugging

Not unexpectedly the dfun.stop intergral can sometimes give
divergence errors with the pso and de fitter which usually
explore very bad areas early on.
I think this is usually when pstop=0 in reality.

Anyway, as a solution I set the integrate option stop.on.error=FALSE.
You can turn that back on and play to see if you can find a solution when
running a pso or de fit. When you do and it bugs I put some code around
things to return the offending values (using the <<- assign which puts
things into the environment where you launch the fit from). You can then
use those values (pl.bad and SSD.bad) as inputs to dfun.stop to see if
you can figure it out but I found sometime the values that caused the
stop then evaluted fine ... which is puzzling ... hence I just turned
off the stop and put protection in to turn any NA integrate$value
returns to zero (which I hope is usually right)!

With this tweak I seem to get sensible pso performance (didnt get
timet to test DE). As I said pso and de may be overkill in our problems,
nlm seems to be working nicely, although if I were you I would compare
it to repeated simplex (you can try repeated nlm but it rarely needs
more than one fit). At least de or pso might be a check we run
(from the best starts from other methods) to make sure our preferred
model is OK, or if the other methods get stuck (can happen for some
subjects) and return obvious local minima (often evident by a failure
to fit choice probabilities or I guess in this context frequency of
non-responses as well).
Andrew: parallel fitting of subjects

Attached updated files now allow parallel
fitting of subjects. Needed a function added to
fitter.R and of course a file to run the fits
(NLMpLBAmA.R). Also realized the code at the
start of  test-models.R that reads in data
and makes sleep.RData didnt convert RT to
seconds so that is now done and attached.
Andrew: minor edits
Andrew: initial fits of model A

I tried to run fits of mA to the data, which mostly worked OK
except P012 and P017 caused nlm fits to crash (parameter
values heading off to infinity), but simplex fits of these
ran OK (the usual finding that simplex is more robust).
In playing with this I tweaked mA to have lower = 1e-6 for
Vs and V, which effects only PSO and DE, but did similar
with the other fitters by changing these two parameters to
a log scale. Not now sure that was necessary (some bad
fits had big negative V and Vs but after this fix I still
got some crashes although less) but left it in.

I stored the output in the attached pLBAmAnlm.RData (note
the fits are actually a mix of simplex for the first 8 subjects
and nlm for the last 6, as I ran them in chunks trying to track
down which subjects caused the crash when I ran in parallel).

Next I tried PSO. That seemed to work fine but rather slow as
you would expect. I am having trouble with DEoptim because it
crashes R on my mac. It works fine on linux.