You can add the user-defined cost parameters directly to the case struct as 
described in section 6.1 of the manual. Since the costs you want are on 
existing variables, there is no need to introduce any new variables.

Suppose you have a two generator example, with the cost as indicated in your 
e-mail, where C1 and C2 are already included in mpc.gencost and you just want 
to add the cross-term with the a coefficient. Since MATPOWER uses reasonable 
defaults for parameters that are not specified (e.g. fparm), you can simply set 
N to pull out the Pg variables (w = Pg), then define H with the a coefficient 
on the off-diagonals, like this ...

nb = size(mpc.bus, 1);
ng = size(mpc.gen, 1);
mpc.N = [sparse(ng, nb) speye(ng,ng)];
mpc.H = sparse([0 a; a 0]);
mpc.Cw = zeros(ng,1);

I think that should do it.

-- 
Ray Zimmerman
Senior Research Associate
419A Warren Hall, Cornell University, Ithaca, NY 14853
phone: (607) 255-9645




On Mar 1, 2012, at 10:54 AM, Niamh O'Connell wrote:

> Dear all,
> 
> I am wondering if it is possible to add costs to a DCOPF based on the 
> existing variables. Specifically, I wish to define a cost function based on 
> the product of the outputs of two generators on the system, so that the 
> resulting objective function is a minimisation of C1(P1) + C2(P2) + aP1P2, 
> where a is a constant. 
> 
> I have looked at the add_costs function and I'm not clear on whether this 
> requires me to define new variables and associate the costs with these 
> variables, or just add costs to the existing variables. If it is possible to 
> use this function for my purpose, could somebody please explain how to derive 
> the H matrix. I understand how this would be done for conventional cost 
> parameters, i.e. including off diagonal elements, however I am looking at the 
> paper "Matpower's Extensible OPF Power Flow Architecture" (section III - 
> User-Defined Costs) and I am not certain on how I should define the m, N and 
> r^ values in this case.
> 
> Thank you for any help you can provide,
> 
> Kind Regards,
> 
> Niamh O'Connell
> 
>  

Reply via email to