[R] Help: concurrent R sessions for different settings of simulations

(Ted Harding) Ted.Harding at wlandres.net
Sun Sep 29 20:31:33 CEST 2013


[See at end]
On 29-Sep-2013 17:22:24 Chee Chen wrote:
> Dear All, 
> I have spent almost 2 days but did not succeed yet.
> 
> Problem description:  I have 3 parameters, p1, p2 and p3, for which
> p1 take 1 of 5 possible distributions (e.g., normal, laplace),
> p2 takes 1 of 3 possible distributions, and p3 takes 1 of 5 possible
> distribution. These 3 parameters create 75 settings, and these 3
> parameters are arguments of a function F; and F is part of simulation
> codes. To summarize: different value of the ordered triple (p1,p2,p3)
> means different setting and this is the only difference in the
> simulation codes. 
> 
> Target to achieve: instead of loop through each of the 75 settings
> one after another, I would like to concurrently run all 75 settings
> on the cluster.
> 
> My attempts: via loops, I used Perl to create 75 files, each for a
> different triple (p1,p2,p3), and Perl uses "system(R ..)" to execute
> this setting once it is created. The Perl codes are submitted to
> cluster correctly. But when I looked into the log file, the cluster
> still executes it one setting after another setting. 
> 
> Request: any help is appreciated!  It is because of the loops of Perl
> that executes a setting once it is created?
> 
> Have a nice day!
> Chee

Just a simple comment (which does not cionsider the technicalities
of using Perl, using a cluster, etc.).

>From your description, it looks as though the system waits for one
item in the loop to finish before it starts the next one.

If that is the case, and *if* you are using UNIX/Linux (or other
UNIX-like OS), then you could try appending " &" to each submitted
command. An outline exemplar:

  for( s in settings ){
    system("R <something depending on s> &")
  }

The " &" has the effect, in a UNIX command line, of detaching the
command from the executing program. So the program can continue to
run (and take as long as it likes) while the system command-shell
is immediately freed up for the next command.

Therefore, with the above exemplar, is there were say 75 settings,
then that loop would complete in a very short time, after which
you would have 75 copies of R executing simulations, and your
original R command-line would be available.

Just a suggestion (which may have missed the essential point of
your query, but worth a try ... ).

I have no idea how to achieve a similar effect in Windows ...

Ted.

-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 29-Sep-2013  Time: 19:31:29
This message was sent by XFMail



More information about the R-help mailing list