genp = [500 150 1 5 10 40 60
Pmax = genp(:,1).*ones(6,24);
Pmin = genp(:,2).*ones(6,24);
a = genp(:,3).*ones(6,24);
b = genp(:,4).*ones(6,24);
c = genp(:,5).*ones(6,24);
RU = genp(:,6).*ones(6,24);
RD = genp(:,7).*ones(6,24);
Demand = [2000 1753 1521 1318 1159 1051 1003 1016 1091 1222 ...
1402 1618 1859 2108 2351 2572 2757 2895 2978 2999 ...
Reserve = [263 282 125 283 227 119 155 209 292 293 131 295 ...
292 197 260 128 184 284 259 292 231 107 270 287];
p = optimvar('p',6,24,'LowerBound',0);
opt.Objective = sum(sum(a.*p.*p) + sum(b.*p) + sum(c));
opt.Constraints.consmax = optimconstr(6,24);
opt.Constraints.consmin = optimconstr(6,24);
opt.Constraints.consmax(g,t) = Pmin(g,t) <= p(g,t);
opt.Constraints.consmin(g,t) = p(g,t) <= Pmax(g,t);
opt.Constraints.consG = optimconstr(24);
opt.Constraints.consG(t) = sum(p(:,t)) == Demand(t) + Reserve(t);
opt.Constraints.consRU = optimconstr(6,24);
opt.Constraints.consRD = optimconstr(6,24);
opt.Constraints.consRU(g,t) = p(g,t) - p(g,t-1) <= RU(g,t);
opt.Constraints.consRD(g,t) = p(g,t-1) - p(g,t) <= RD(g,t);
problem = prob2struct(opt,'ObjectiveDerivative','finite-differences',...
[sol,fval,exitflag,output] = quadprog(problem);
The interior-point-convex algorithm does not accept an initial point.
Ignoring X0.
No feasible solution found.
quadprog stopped because it was unable to find a point that satisfies
the constraints within the value of the constraint tolerance.
g(:,t) = sol(6*(t-1)+1:6*t);