Your help is appreciated!
The main code is as follows:
Load=given
PV=given
cvx_begin
variables Cap N_PV;
u=find_u(Cap, N_PV); the function is given below
battery= 1000*Cap*u
grid_=Load'+battery-N_PV*PV';
minimize (sum(grid_)+10*max(grid_)+1000*Cap +200*N_PV
subject to
Cap>=0
N_PV>=0
Cap<=100
N_PV<=100
cvx_end
the function to find u is as follows:
function cvx_optval =find_u(Cap, N_PV)
global Load
global PV
E0=Cap/2;
L = 0.5*tril(ones(50));
cvx_begin
variables u(50)
*battery= 1000*Cap*u;*
Es = Cap*L*u;
grid_=Load'+battery-N_PV*PV';
minimize sum(grid_)+10*max(grid_)
subject to
u <= 0.4;
u >= -1;
Es <= Cap;
Es >= 0;
Es(end)>=0.99*Cap;
cvx_end
I was able to decouple the problem and find u using CVX and find Cap and N_PV using another optimization algorithm (for example surrogate optimization or gentic algorithm) but I am interested to see if it can be solved using convex.
If I use the code given above the following error I will get: {real affine} .* {convex}
the equation inside the function (find_u)
battery= 1000*Cap*u
causes the issue which is: u is CVX variable and Cap is the input of the function (find_u) but the function does not deal with Cap as constant since it is obtained by the main code