I tried to write the code using Salver Mosek, but I didn’t succeed. Can anyone help me?
t=1:24;
UT=[1 3 2 1];
DT=[4 2 2 2];
Show us what you tried, and what didn’t succeed. There are many posts on https://or.stackexchange.com/ which show how to use binary variables for various purposes in optimization problems
My problem is with intervals, for example,in Eq18 how to model sum from t - t+DT-1 for every moment ?
i have to use loop “for”?
T=24;
cvx_begin
cvx_solver Mosek
variable u_on(T,4) binary
variable u(T,4) binary
variable u_off(T,4) binary
minimize ...
subject to
for t=1:T
sum(1-u(t:t+DT(i)-1,1))>=DT(i)*u_on(t,2)
sum(u(t:t+UT(i)-1,1))>=UT(i)*uu(t,1)
end
is it correct?
I think the code is dirty, how can i rewrite it with this manner i don;t have to use loop
You need to have another level of for loop over j. and change u_on(t,2)
to u_on(t,j)
and change uu(t,1)
to u_off(t,j)
.
Perhaps some for loops could be eliminated,with vectorization. That’s not necessary, but would speed up CVX processing of the constraints.
I’ll let you check this, and work out the rest of the details.