title: Why does the function `GenSA` not honor lower bounds for components?
body: <p>Quoting <a href="https://cran.r-project.org/web/packages/GenSA/GenSA.pdf" rel="nofollow noreferrer">the official documentation of the <code>GenSA</code> function from the <code>GenSA</code> package from CRAN</a>:</p>
  
  <blockquote>
    <h2>Usage</h2>
  
  <pre><code>GenSA(par, fn, lower, upper, control=list(), ...)
  </code></pre>
    
    <h2>Arguments</h2>
    
    <ul>
    <li><code>par</code> Vector. Initial values for the components to be
    optimized.  Default is <code>NULL</code>, in which case, default values will be
    generated automatically.</li>
    <li><code>fn</code> A function to be minimized, with first
    argument the vector of parameters over which minimization is to take
    place. It should return a scalar result.</li>
    <li><code>lower</code> Vector with length of <code>par</code>.
    Lower bounds for components.</li>
    <li><code>upper</code> Vector with length of <code>par</code>. Upper
    bounds for components.</li>
    </ul>
  </blockquote>
  
  <p>Very well. So, if I undestand correctly, the arguments passed to <code>fn</code> should never be lower or higher than the bounds I specify in <code>lower</code> and <code>higher</code>.</p>
  
  <p>This seems not to be the case:</p>
  
  <pre><code>library(GenSA)
  
  GenSA(c(1.0/90, 1.0, 0.02), function(args){
    arg1 = args[1]; arg2 = args[2]; arg3 = args[3]
    print(args)
    if(arg2 &lt;= 0) stop("WTF")
    0
  }, lower=c(0, 1.0, 0), upper=c(Inf, Inf, 0.4))
  </code></pre>
  
  <p>The results of running this code are unforgiving:</p>
  
  <pre><code>[1] 0.01111111 1.00000000 0.02000000
  [1] 0.0000000 0.0000000 0.2891973
  Error in fn(par, ...) : WTF
  Calls: GenSA -&gt; &lt;Anonymous&gt; -&gt; fn
  Execution halted
  </code></pre>
  
  <p>Why did <code>GenSA</code> call my function with the second component equaling <code>0.0</code>? I thought I was clear when I said: <code>lower=c(0, 1.0, 0)</code>!</p>
  
  <p>Am I misunderstanding something? What is my mistake? How can this be forced to work correctly?</p>