0

While trying to use the pso or hydroPSO package from R-CRAN, I have a need to use/access the counts (current iteration, current number function evaluation, and current restart) to work with the function I've been writing. However, I can't seem to wrap my head around this. Any suggestions on figuring out how to call the current iteration/function/restarts within the objective function would be great. A piece of example code would be appreciated as I seem to fail to fully understand the documentation.

Background:
My function requires the iteration number as it is a wrapper to some code written in FORTRAN where the input files are generated and the output files are read back in to R. I want the iteration number surviving so that I can return back to the previous output files for further analysis. An example of this would be:
~/runs/<restart #>/<iteration>/<particle>/input/
~/runs/<restart #>/<iteration>/<particle>/output/

The wrapper function accepts the parameters, automatically generates the input files, runs the FORTRAN model, then parses in the output and post-processes them (e.g. performance index calculations).

Don
  • 170
  • 1
  • 11
  • You can actually call (compiled) fortran code from R. That should be faster than reading and writing files (these heuristics often do a lot of function evaluations). – Erwin Kalvelagen Mar 06 '18 at 02:44
  • Hey @ErwinKalvelagen, thanks for that comment! I did look into that option but the way the FORTRAN code I'm using is made that really isn't much of an option for me. Thanks for that comment though! – Don Mar 06 '18 at 14:41

0 Answers0