How can I write a constraint for optimization which includes the decision variable (x)? The constraint is:
max (0, x(i-1) - P) <= x(i) <= min (C, x(i-1) + D)
Best Answer
You should use a couple of different kinds of constraints. But you are only constraining variable #i, so we have to initialize the constraints so the other variables are not affected
Nx = length(x);
%no equality constraints
Aeq = [];
beq = [];
%the constraint has to be for some _specific_ i
i = 13;
%now to construct x(i-1) - P <= x(i) and x(i) <= x(i-1) + D
Best Answer