MATLAB: Set fmincon for a maximization problem when there are N agents and T periods of time

fminconOptimization Toolbox

Hi,
I have to maximize an objective function given linear and non linear constraints.
I have five variables, i.e. c l n K g. K and g take a value for each period of time, t=1:T; the other three variable vary according to time and the agent index, i=1:N.
Given these framework, my objective function is the sum for each "i" and "t" of a non linear expression depending on c(t,i), l(t,i) and g(t). I have two set of constraints.
1) for each t and i, l(t,i) + n(t,i) = 1
2) for each t, a non linear constraint depending on K(t), K(t+1), g(t) and the sum for each i of c(t,i) and n(t,i).
Do you think that this type of problem could be solved with fmincon? If the answer is yes, how could I specify these variables that varies or in one dimension, t, or in two, i.e. t,i?
Best,
Tiziano

Best Answer

If I understand you, it sounds straightforward to set up the problem for solution by fmincon. I assume that your control variables are continuous; for example, T and N are not control variables, but are fixed.
fmincon requires you to put all of your control variables into one vector, typically called x. So, for example, your c variable is of size T-by- N, but you would code it as x(1) through x(T*N). Similarly, I would be x(T*N+1) through x(2*T*N) and n would be x(2*T*N+1) through x(3*T*N). Set K as x(3*T*N+1) through x(3*T*N+T) and g as x(3*T*N+T+1) through x(3*T*N+2*T). For your objective function you would have code like the following:
function f = objfun(x,T,N)
c = reshape(x(1:T*N),T,N);
I = reshape(x(T*N+1:2*T*N),T,N);
% etc. Then your actual code in terms of c, I, etc.
You would call the objective function as fun = @(x)objfun(x,T,N).
Alan Weiss
MATLAB mathematical toolbox documentation