title: Upper Bound Error in nloptr
body: <p>I use <code>nloptr</code> to model a non linear optimization problem using <code>R.Net</code> . I pass initial values of the parameters to the Rscript where I define <code>lb</code> and <code>ub</code>to the variables. </p>
  
  <p><code>lb</code> for all the variables is 0 whereas <code>ub</code>is "1" for some &amp; "Inf" for some variables.</p>
  
  <p>When I run the model, I am continuously getting an error as </p>
  
  <pre><code>Additional information: Error in is.nloptr(ret) : at least one element in x0 &gt; ub
  </code></pre>
  
  <p>Interestingly if I provide the same initial input data from EXCEL to "R.Script", it runs fine and I never get error about <code>x0&gt;ub</code>. 
  Any insights on how to debug this or know what might be wrong? I can'f fathom why it would work with excel but not with C#.</p>
  
  <p>Some details are below:
  Example:  Parameters are in the form of Matrix as below (called my.data.var)</p>
  
  <p><a href="https://i.stack.imgur.com/6kZKx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6kZKx.png" alt="enter image description here"></a></p>
  
  <p>The constraints are such that sum of the second col and third col should be <strong>&lt;=1</strong> respectively. i.e,
  <a href="https://i.stack.imgur.com/iIb2I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iIb2I.png" alt="enter image description here"></a></p>
  
  <p>The lb for all parameters is 0 and i define it as:</p>
  
  <pre><code>lb = vector("numeric",length= length(my.data.var))
  </code></pre>
  
  <p>ub as:</p>
  
  <pre><code>ub.matrix &lt;- matrix(,nrow = 2, ncol=4)  
  ub.matrix
  for(rownum in 1:2)  
  {
    ub.matrix[rownum,1] = Inf                     
    ub.matrix[rownum,4] = Inf    
    for(colnum in 2:3) 
    {
      ub.matrix[rownum,colnum] = 1              
    }
  }
  </code></pre>
  
  <p>The constraint func is defined as:</p>
  
  <pre><code>constraint.func &lt;- function(my.data.var)
  {
    column = 1
  
    constr &lt;- vector("numeric",length = 2)   
    my.data.var.mat &lt;- matrix(my.data.var,nrow = 2,ncol = 4,byrow = TRUE)  
  
  
    for(index in 2:3)
    {
      sum.constraint = 0
      for(prodwells in 1:2)
      {
        sum.constraint &lt;- sum.constraint + my.data.var.mat[prodwells,index]
  
      }
      constr[column] &lt;- sum.constraint - 1
      column = column+1
    }
    return(constr)
  
  }
  
  result &lt;- nloptr(my.data.var,eval_f = Error.func, lb=lb,
                   ub = ub,eval_g_ineq=constraint.func,
                   opts = opts)
  </code></pre>
  
  <p>When I run the script, I noticed that "sum" of the first col is >1 and hence the error!</p>