Maximization under non-linear constraints in MATLAB using fmincon
<p>I am trying to solve maximize a function s.t. 14 constraints and with 15 variables.
Some of them are linear, some are not. They are all equations (no inequalities).</p>

<p>I have tries using 'fsolve' and 'solve', using lagrange (ended up with 29 equations and 30 variables) - that didn't go that well...</p>

<p>I moved on to fmincon. I've set a script with an objective function in a file named objectfun.m:</p>

<pre><code>function f = objectfun(x,I,rho)

% SWAPPING VARIABLE NAMES FOR READABILITY:
w = x(1);
t = x(2);
beta = x(3);
r = x(4);

% VALUE FUNCTION TO BE MINIMIZES:
f = -(rho*w*(1-t)+beta+I*(1+(1-t)*r));
</code></pre>

<p>I have set another one with the constraints:</p>

<pre><code>function [c, ceq] = confun(x,...
    Bs,Bu,sigma_s,sigma_u,rho,c_bar,I,A,alpha)

% SWAPPING VARIABLE NAMES FOR READABILITY:
w = x(1);
t = x(2);
beta = x(3);
r = x(4);
vum = x(5);
vsm = x(6);
ms = x(7);
cstar = x(8);
zs = x(9);
zu = x(10);
H = x(11);
K = x(12);
Y = x(13);
L = x(14);
mu = x(15);

% INEQUILITY CONSTRAINTS:
c = [];

% EQUALITY CONSTRAINTS:
ceq = [ms-Bs*vsm^sigma_s;               % 1
    mu-Bu*vum^sigma_u;                  % 2
    (1+r*(1-t))*cstar-(1-rho)*w*(1-t);  % 3
    zs-cstar/c_bar;                     % 4
    zu-1+zs;                            % 5
    H-(cstar^2)/(2*c_bar);              % 6
    I-K-H;                              % 7
    A*(K^alpha)*(L^(1-alpha))-Y;        % 8
    L-(zs+rho*zu+ms+rho*mu);            % 9
    w-(1-alpha)*A*(K/L)^alpha;          % 10
    r-alpha*A*(K/L)^(alpha-1);          % 11
    t*Y-beta*(1+ms+mu);                 % 12
    vum-rho*w*(1-t)-beta;               % 13
    vsm-w*(1-t)-beta];                  % 14
</code></pre>

<p>And a main script:</p>

<pre><code>%% Parameters:
Bs =0.0;
Bu =0.0;
sigma_s = 1.5;
sigma_u = 1.5;
rho = 0.33;
c_bar = 6;
I = 3;
A = 1;
alpha = 0.33;

%% Numeric Solution:
x0 = 0.5*ones(length(var_names),1);

objective = @(x)objectfun(x,I,rho);

constraints = @(x)confun(x,...
    Bs,Bu,sigma_s,sigma_u,rho,c_bar,I,A,alpha);

options = optimoptions(@fmincon);

[s,fval] = fmincon(objective,x0,[],[],[],[],[],[],constraints,options);
</code></pre>

<p>The question:
The solution is nonsense. I went over the equations many times - let's assume their good! (please...[= ) </p>

<ol>
<li>Did I choose the right application for my problem (fmincon)?</li>
<li>Is there a problem with the structure or in the code specifically?</li>
<li>Do you have any suggestions on how to make my life a bit easier?</li>
<li>I plan on iterating on the solution using different parameter values. Is there any way of verifying the solution, for a given set, just to see if the solution is correct?</li>
</ol>

<p>Thanks in advance!!!</p>