I have been able to formulate the problem for the Unit Commitment problem using the optimproblem approach with the help from a similar example on the MATLAB page. So far I have ensured that the total power generated meets the load demand and that power generated by any unit is within limits. I have also included the minimum up and down time constraint. I now have to include the power loss with the equality constraint. That is the total power generated must meet the load demand plus losses.
The method I use to find this power loss uses a B coefficient matrix, which determines the power loss as follows:
P_loss = [P_1 P_2] * [B_11 B_12; * [P_1;
B_21 B_22] P_2]
That is for a system with two generating units, the power loss is given as P * B * P'.
Now for my particular case, I have linearized the cost function for each generator and therefore,
P_1 = P_1min + P_11 + P_12 + … + P_1N
Where N is the number of segments used to linearized the curve. But the same concept applies with respect to the calculation: P * B * P' except that B is now larger and follows a different configuration of the values. Now P in my code is a optimization variable 'power'. Without actually coding anything, I attempted to determine P * B * P' from the command line and ran into an error. Firstly I did B * P', and since P' is the transpose of the 'power' variable, it returned an optimization variable. Next when I tried to premultiply P to this optimization variable, I got an error telling me that one of the variables need to be numeric. A quick search of this error revealed that I cannot have any quadratic terms apparently as is indicated would happen here:
P_loss = [P_1 P_2]*[B_11 B_12; * [P_1;
B_21 B_22] P_2]
= [P_1 P_2]*[B_11*P_1 + B_12*P_2;
B_21*P_1 + B_22*P_2]
= P_1(B_11*P_1 + B_12*P_2) + P_2(B_21*P_1 + B_22*P_2)
My initial approach involves creating some optimization expression in terms of P and B which correspond to the power loss and just including it in the load demand constraint. That is based on my code:
powerprob.Constraints.isDemandMet = sum(power,2) >= Load - sum((minPowConst.*isOn),2) + P_loss;
(sum((minPowConst.*isOn),2)) can be ignored for now. This is the subtraction of the P_min values due to linearization.
I have attached my working code which includes everything except the inclusion of any power losses. I would greatly appreciate some guidance in this matter.