title: Optimization of values in a matrix
body: <p>I typically use Rsolnp for optimization but I am having trouble figuring out how to ask R to find values to fill a matrix (instead of a vector).  Is that possible with Rsolnp or any other optimizer?</p>
  
  <p>Here is a simplified example that is not working:</p>
  
  <pre><code>library(Rsolnp)
  
  a&lt;-matrix(rnorm(9), ncol=3)
  b&lt;-matrix(rnorm(9), ncol=3)
  
  f1&lt;-function(H) {
      return(sum(H*a))
  }
  
  f2&lt;-function(H) {
      return(sum(H*b))
  }
  
  lH&lt;-matrix(rep(0, 9), ncol=3)
  uH&lt;-matrix(rep(1, 9), ncol=3)
  pars&lt;-uH
  target&lt;-1.2
  
  sol &lt;- gosolnp(pars, fixed=NULL, fun=f1, eqfun=f2, eqB=target, LB=lH, UB=uH, distr=uH, n.restarts=10, n.sim=20000, cluster= NULL)
  </code></pre>
  
  <p>As you can see from the output, Rsolnp seems to be confused by the request:</p>
  
  <pre><code>&gt; sol
  $values
  [1] 1e+10
  
  $convergence
  [1] 0
  
  $pars
  [1] NA NA NA NA NA NA NA NA NA
  
  $start.pars
  [1] 0.90042133 0.33262541 0.94586530 0.02083822 0.99953060 0.10720068 0.14302770 0.67162637 0.25463806
  
  $rseed
  [1] 1487866229
  </code></pre>