title: comparing MATLAB fmincon and ga (genetic algorithm) results: issue with ga
body: <p>I have a fairly complex optimization problem set up that I've solved through fmincon by calling it like this</p>
  
  <pre><code>myfun = @(x5) 0.5 * (norm(C*x5 - d))^2 + 0.5 * (timeIntervalMeanGlobal * powerAbsMaxMaxGlobal * sum(x5(28:128),1))^2;
  [x5, fval] = fmincon(myfun, initialGuess, -A, b, Aeq, beq, lb, []);
  </code></pre>
  
  <p>The components are far to long to print here, but here are the dimensions</p>
  
  <pre><code>C: 49 x 128  
  x5: 128 x 1  
  d: 49 x 1  
  timeIntervalMeanGlobal, powerAbsMaxMaxGlobal: constants  
  initialGuess: 128 x 1  
  A: 44541 x 128  
  b: 44541 x 1  
  Aeq: 24 x 128  
  beq: 24 x 1  
  lb: 128 x 1  
  </code></pre>
  
  <p>This works in code, but I don't get results that I'm completely happy with. I'd like to compare it with the built in ga function in MATLAB, which is called in a similar way, but I get an error when I try to run it like this  </p>
  
  <pre><code>[x5, fval] = ga(myfun, nvars, -A, b, Aeq, beq, lb, []);  
  </code></pre>
  
  <p>where nvars = 128.  There's a long list of about 8 errors starting with</p>
  
  <blockquote>
    <p>??? Error using ==> mtimes<br>
    Inner matrix dimensions must agree. </p>
  </blockquote>
  
  <p>and ending with  </p>
  
  <blockquote>
    <p>Caused by:<br>
       Failure in user-supplied fitness function evaluation. GA cannot continue.</p>
  </blockquote>
  
  <p>Can someone please instruct me on how to call ga properly, and give insight on why this error might occur with the ga call when the same code doesn't cause an error with fmincon?  I've tried all the MATLAB help files and examples with a few different permutations of this but no better luck. Thanks.</p>
  
  <p>UPDATE:  I think I found the problem but I don't know how to fix it. The ga documentation says "The fitness function should accept a row vector of length nvars".  In my case, myfun is the fitness function, but x5 is a column vector (so is lb).  So while mathematically I know that C*x5 = d is the same as x5'*C' = d' even for non-square matrices, I can't formulate the problem that way for the ga solver.  I tried - it makes it past the fitness function but then I get the error </p>
  
  <blockquote>
    <p>The number of rows in A must be the same as the length of b.</p>
  </blockquote>
  
  <p>Any thoughts on how to get this problem in the right format for the solver? Thanks!</p>