title: R optimization with equality and inequality constraints
body: <p>I am trying to find the local minimum of a function, and the parameters have a fixed sum. For example,</p>
  
  <p><strong>Fx = 10 - 5x1 + 2x2 - x3</strong></p>
  
  <p>and the conditions are as follows,</p>
  
  <p><strong>x1 + x2 + x3 = 15</strong></p>
  
  <p><strong>(x1,x2,x3) >= 0</strong></p>
  
  <p>Where the sum of x1, x2, and x3 have a known value, and they are all greater than zero. In R, it would look something like this,</p>
  
  <pre><code>Fx = function(x) {10 - (5*x[1] + 2*x[2] + x[3])}
  opt = optim(c(1,1,1), Fx, method = "L-BFGS-B", lower=c(0,0,0), upper=c(15,15,15))
  </code></pre>
  
  <p>I also tried to use inequalities with constrOptim to force the sum to be fixed. I still think this may be a plausible work around, but I was unable to make it work. This is a simplified example of the real problem, but any help would be very appreciated.</p>