<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Jobs and Experiments — makeJob • batchtools</title>


<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>

<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>

<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>

<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>

<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>




<meta property="og:title" content="Jobs and Experiments — makeJob" />
<meta property="og:description" content="Jobs and Experiments are abstract objects which hold all information necessary to execute a single computational
job for a Registry or ExperimentRegistry, respectively.
They can be created using the constructor makeJob which takes a single job id.
Jobs and Experiments are passed to reduce functions like reduceResults.
Furthermore, Experiments can be used in the functions of the Problem and Algorithm.
Jobs and Experiments hold these information:
 job.idJob ID as integer.
 parsJob parameters as named list.
   For ExperimentRegistry, the parameters are divided into the sublists &amp;#8220;prob.pars&amp;#8221; and &amp;#8220;algo.pars&amp;#8221;.
 seedSeed which is set via doJobCollection as scalar integer.
 resourcesComputational resources which were set for this job as named list.
 external.dirPath to a directory which is created exclusively for this job. You can store external files here.
   Directory is persistent between multiple restarts of the job and can be cleaned by calling resetJobs.
 funJob only: User function passed to batchMap.
 prob.nameExperiments only: Problem id.
 algo.nameExperiments only: Algorithm id.
 problemExperiments only: Problem.
 instanceExperiments only: Problem instance.
 algorithmExperiments only: Algorithm.
 replExperiments only: Replication number.



Note that the slots &amp;#8220;pars&amp;#8221;, &amp;#8220;fun&amp;#8221;, &amp;#8220;algorithm&amp;#8221; and &amp;#8220;problem&amp;#8221;
lazy-load required files from the file system and construct the object on the first access.
The realizations are cached for all slots except &amp;#8220;instance&amp;#8221; (which might be stochastic).
Jobs and Experiments can be executed manually with execJob." />




<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->



  </head>

  <body data-spy="scroll" data-target="#toc">
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">batchtools</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.14</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fas fa fas fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../articles/batchtools.html">Get started</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li>
  <a href="../news/index.html">Changelog</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/mllg/batchtools/">
    <span class="fab fa fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Jobs and Experiments</h1>
    <small class="dont-index">Source: <a href='https://github.com/mllg/batchtools/blob/master/R/Job.R'><code>R/Job.R</code></a></small>
    <div class="hidden name"><code>JobExperiment.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Jobs and Experiments are abstract objects which hold all information necessary to execute a single computational
job for a <code><a href='makeRegistry.html'>Registry</a></code> or <code><a href='makeExperimentRegistry.html'>ExperimentRegistry</a></code>, respectively.</p>
<p>They can be created using the constructor <code>makeJob</code> which takes a single job id.
Jobs and Experiments are passed to reduce functions like <code><a href='reduceResults.html'>reduceResults</a></code>.
Furthermore, Experiments can be used in the functions of the <code><a href='addProblem.html'>Problem</a></code> and <code><a href='addAlgorithm.html'>Algorithm</a></code>.
Jobs and Experiments hold these information:</p><dl>
 <dt><code>job.id</code></dt><dd><p>Job ID as integer.</p></dd>
 <dt><code>pars</code></dt><dd><p>Job parameters as named list.
   For <code><a href='makeExperimentRegistry.html'>ExperimentRegistry</a></code>, the parameters are divided into the sublists &#8220;prob.pars&#8221; and &#8220;algo.pars&#8221;.</p></dd>
 <dt><code>seed</code></dt><dd><p>Seed which is set via <code><a href='doJobCollection.html'>doJobCollection</a></code> as scalar integer.</p></dd>
 <dt><code>resources</code></dt><dd><p>Computational resources which were set for this job as named list.</p></dd>
 <dt><code>external.dir</code></dt><dd><p>Path to a directory which is created exclusively for this job. You can store external files here.
   Directory is persistent between multiple restarts of the job and can be cleaned by calling <code><a href='resetJobs.html'>resetJobs</a></code>.</p></dd>
 <dt><code>fun</code></dt><dd><p>Job only: User function passed to <code><a href='batchMap.html'>batchMap</a></code>.</p></dd>
 <dt><code>prob.name</code></dt><dd><p>Experiments only: Problem id.</p></dd>
 <dt><code>algo.name</code></dt><dd><p>Experiments only: Algorithm id.</p></dd>
 <dt><code>problem</code></dt><dd><p>Experiments only: <code><a href='addProblem.html'>Problem</a></code>.</p></dd>
 <dt><code>instance</code></dt><dd><p>Experiments only: Problem instance.</p></dd>
 <dt><code>algorithm</code></dt><dd><p>Experiments only: <code><a href='addAlgorithm.html'>Algorithm</a></code>.</p></dd>
 <dt><code>repl</code></dt><dd><p>Experiments only: Replication number.</p></dd>

</dl>

<p>Note that the slots &#8220;pars&#8221;, &#8220;fun&#8221;, &#8220;algorithm&#8221; and &#8220;problem&#8221;
lazy-load required files from the file system and construct the object on the first access.
The realizations are cached for all slots except &#8220;instance&#8221; (which might be stochastic).</p>
<p>Jobs and Experiments can be executed manually with <code><a href='execJob.html'>execJob</a></code>.</p>
    </div>

    <pre class="usage"><span class='fu'>makeJob</span><span class='op'>(</span><span class='va'>id</span>, reader <span class='op'>=</span> <span class='cn'>NULL</span>, reg <span class='op'>=</span> <span class='fu'><a href='getDefaultRegistry.html'>getDefaultRegistry</a></span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span></pre>

    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>id</th>
      <td><p>[<code><a href='https://rdrr.io/r/base/integer.html'>integer(1)</a></code> or <code>data.table</code>]<br />
Single integer to specify the job or a <code>data.table</code> with column <code>job.id</code>
and exactly one row.</p></td>
    </tr>
    <tr>
      <th>reader</th>
      <td><p>[<code>RDSReader</code> | <code>NULL</code>]<br />
Reader object to retrieve files. Used internally to cache reading from the file system.
The default (<code>NULL</code>) does not make use of caching.</p></td>
    </tr>
    <tr>
      <th>reg</th>
      <td><p>[<code><a href='makeRegistry.html'>Registry</a></code>]<br />
Registry. If not explicitly passed, uses the default registry (see <code><a href='getDefaultRegistry.html'>setDefaultRegistry</a></code>).</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>[<code>Job</code> | <code>Experiment</code>].</p>

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'> <span class='fu'>batchtools</span><span class='fu'>:::</span><span class='fu'>example_push_temp</span><span class='op'>(</span><span class='fl'>1</span><span class='op'>)</span> 
<span class='va'>tmp</span> <span class='op'>=</span> <span class='fu'><a href='makeRegistry.html'>makeRegistry</a></span><span class='op'>(</span>file.dir <span class='op'>=</span> <span class='cn'>NA</span>, make.default <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>No readable configuration file found</span></div><div class='output co'>#&gt; <span class='message'>Created registry in '/tmp/batchtools-example/reg' using cluster functions 'Interactive'</span></div><div class='input'><span class='fu'><a href='batchMap.html'>batchMap</a></span><span class='op'>(</span><span class='kw'>function</span><span class='op'>(</span><span class='va'>x</span>, <span class='va'>y</span><span class='op'>)</span> <span class='va'>x</span> <span class='op'>+</span> <span class='va'>y</span>, x <span class='op'>=</span> <span class='fl'>1</span><span class='op'>:</span><span class='fl'>2</span>, more.args <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>y <span class='op'>=</span> <span class='fl'>99</span><span class='op'>)</span>, reg <span class='op'>=</span> <span class='va'>tmp</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>Adding 2 jobs ...</span></div><div class='input'><span class='fu'><a href='submitJobs.html'>submitJobs</a></span><span class='op'>(</span>resources <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>foo <span class='op'>=</span> <span class='st'>"bar"</span><span class='op'>)</span>, reg <span class='op'>=</span> <span class='va'>tmp</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>Submitting 2 jobs in 2 chunks using cluster functions 'Interactive' ...</span></div><div class='input'><span class='va'>job</span> <span class='op'>=</span> <span class='fu'>makeJob</span><span class='op'>(</span><span class='fl'>1</span>, reg <span class='op'>=</span> <span class='va'>tmp</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span><span class='op'>(</span><span class='va'>job</span><span class='op'>)</span>
</div><div class='output co'>#&gt; &lt;Job&gt;
#&gt;   Inherits from: &lt;BaseJob&gt;
#&gt;   Public:
#&gt;     external.dir: active binding
#&gt;     file.dir: /tmp/batchtools-example/reg
#&gt;     fun: active binding
#&gt;     id: 1
#&gt;     initialize: function (file.dir, reader, id, job.pars, seed, resources) 
#&gt;     job.id: active binding
#&gt;     job.pars: list
#&gt;     pars: active binding
#&gt;     reader: RDSReader, R6
#&gt;     resources: list
#&gt;     seed: 15284</div><div class='input'>
<span class='co'># Get the parameters:</span>
<span class='va'>job</span><span class='op'>$</span><span class='va'>pars</span>
</div><div class='output co'>#&gt; $x
#&gt; [1] 1
#&gt; 
#&gt; $y
#&gt; [1] 99
#&gt; </div><div class='input'>
<span class='co'># Get the job resources:</span>
<span class='va'>job</span><span class='op'>$</span><span class='va'>resources</span>
</div><div class='output co'>#&gt; $foo
#&gt; [1] "bar"
#&gt; </div><div class='input'>
<span class='co'># Execute the job locally:</span>
<span class='fu'><a href='execJob.html'>execJob</a></span><span class='op'>(</span><span class='va'>job</span><span class='op'>)</span>
</div><div class='output co'>#&gt; ### [bt]: Setting seed to 15284 ...</div><div class='output co'>#&gt; [1] 100</div></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <p>Developed by Michel Lang, Bernd Bischl.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>

      </footer>
   </div>

  


  </body>
</html>


