title: MATLAB Optimization Error
body: <p>My Genetic Algorithm optimization script on Matlab runs, but at the end produces the following message: <strong>"Optimization terminated: average change in the penalty fitness value less than options.TolFun but constraints are not satisfied."</strong></p>
  
  <p>Why would it say that? I replaced my fitness function with one that does nothing but returns a constant number, and nothing changed. It may be the case that my constraints are not defined correctly, though I can't find the mistake. Here is the relevant part of the code:</p>
  
  <pre><code>nGenerators = 9;
  monthlyHours = 24*daysInJanuary;
  
  (some irrelevant code here)
  
  steamCapacities = [31.46*ones(1,2) 5.5*ones(1,3) 4*ones(1,4)];
  
  nVars = xSize;
  IntCon = 1:nVars;
  LB = zeros(1, nVars);
  UB = ones(1, nVars);
  
  b = -1*steamLoad; % Ax &lt;= b
  
  A = zeros(monthlyHours, xSize);
  for p = 1:monthlyHours
      A(p, 9*p-8:9*p) = -1*steamCapacities;
      % disp(p);
  end
  
  (some more code here)
  
  anonFitness = @(x)mosb_test(x, fitnessData);
  
  gaOptions = gaoptimset('Vectorized', 'off', 'UseParallel', 'always', ...
  'Display', 'diagnose', 'PlotFcn', @gaplotbestf, 'Generations', 300, ...
  'TolFun', 1e-15, 'StallGenLimit', 200);
  
  [x, fval, exitFlag] = ga(anonFitness, nVars, A, b,[],[], LB, UB, [], IntCon, gaOptions);
  </code></pre>
  
  <p>Here, x represents the on/off states for a set of 9 generators for each hour of the month. Their steam production capacities are as in the variable steamCapacities, and there is a constant steam load that has to be met at every hour. This is represented by the inequality constraint.</p>
  
  <p>Any help appreciated.</p>