Thank you.

Apart from the second point you mentioned(True as you said).

How would I model/represent the same for all the values of variables from 1:tn?

i.e if Pb(tn) takes only the value of the final value(@tn=1000) , how to model the code so that t varies from 1:tn.

```
cvx_begin
variables Esc(tn) Pb(tn) Psc(tn) Psca(tn)
minimize (A1*max(0,abs((Pb(tn)/Pb_thres)-1))+A2*max((Pb(tn)-Pb(tn-1))/Pb_thres_var-1)+A3*(Pb(tn)/Vb(tn-1)).^2*Rb...
+A4*Ron*((Psca(tn)/Vb(tn-1)).^2*(D/(1-D).^2))+A5*(Esc(tn)-Esc_ref)/(Esc_max-Esc_min))
subject to
Pb(tn)+Psca(tn)-Preq(tn)== 0;
Psca(tn)== Psc(tn)-abs(Pconv_loss(tn));
Esc(tn)-Esc(tn-delta)== -Psc(tn)*delta;
Esc_min<=Esc(tn)<=Esc_max;
cvx_end
```

This is the exact code layout am working. Besides the decision variables, all other variables are given or calculated before the âcvx beginâ.

What I am trying to implement is,

- Every variable is a function of t as t varies from t=1 to tn.
- Even the non decision variables are also function of t(1:tn).
- For final result i will have the plot for t vs Pb(t) and other variables.
- As of now, the CVX runs, either it shows inaccurate/solved or sometimes solved but not the expected values.

This is based on the Penalty Function approximation given in CVX examples. I have checked most of the examples regarding the same and still checking if anyone has done similar in the forum. If you have come across similar optimization problem then please link the same.

Note: The problem was solved using CVX by the author of the paper. But i am sure my model layout is wrong.