I caught a couple of errors in the code I sent in my previous e-mail. Sorry 
about that ...

First, the constraints are formulated in p.u., so Pupper and Plower need to be 
divided by mpc.baseMVA.

Second, A2 should use sp instead of sm …
A2 = [Zb Zb I Zg Zg -I m_0];

Also, you should be able to just do …

mpc.u = [u1; u2; u3; u4;u5;u6];
mpc.l = -Inf(length(mpc.u), 1);

Finally, I’ll just mention that, since there is no cost directly on the sm and 
sp variables, except for the one equal to T, their values may lie anywhere 
between the “tight” value (the soft limit violations) and T. If you are 
interested, you can make them tight by adding a (relatively) small cost on 
them, such as …

mpc.N = [sparse(2*ng+1, 2*nb+2*ng) speye(2*ng+1, 2*ng+1)];   % select sm, sp, T
mpc.Cw = [0.001*ones(2*ng, 1); 1];

Hope this helps,

    Ray




On Jun 25, 2020, at 4:38 AM, m.drabe...@onet.eu<mailto:m.drabe...@onet.eu> 
wrote:

Dear Ray,

As promised I am coming back with the feedback.
I added the mpc.l matrix (as apparently was required) , zeroed the mpc.gencost 
matrix and  tested the code on ‘case9’ test system.

The code seems to be giving the desired results  in terms of generation in 
res.gen matrix (res=runopf(mpc)). However, I do not understand the values of 
res.x variables – please see below:

Plower=[10;10;sum(mpc.bus(:,PD))]; % preferably let the third unit cover the 
demand completely
Pupper=[10;10;sum(mpc.bus(:,PD))];

And the results are

  *   Res.gen:

PG                 QG
1    18,8686331862694    46,3306849578324
2    37,4758584872943    9,01478391826475
3    269,999995145612    32,3104904279087


Whereas the res.x matrix last rows give:
157,648217200393
157,649905532785
312,300153184647
156,150153162622
156,150153162622
156,150153162622
312,300306325243

Frankly,  I do not understand where the “X” variables values come from. They 
seem  not to be reflecting the  soft limit violations. Yet, the generation 
results look good – as we might be expecting.

Do you have an idea on the “x” variables values?

I am attaching the code.


With best regards,


Mariusz Drabecki,

Operations and Systems Research Division
Institute of Control and Computation Engineering
Warsaw University of Technology



PS: the complete  code:

clear all
define_constants;
mpc1=loadcase('case9');
mpc=loadcase('case9');
nb = size(mpc.bus, 1);
ng = size(mpc.gen, 1);
Plower=[10;10;sum(mpc.bus(:,PD))];
Pupper=[10;10;sum(mpc.bus(:,PD))];
I = speye(ng,ng);       % ng x ng identity matrix
Zb = sparse(ng, nb);    % ng x nb zero matrix
Zg = sparse(ng, ng);    % ng x ng zero matrix
m_0=sparse(ng,1);
% -Pg - sm <= -Plower
A1 = [Zb Zb -I Zg -I Zg m_0];
u1 = -Plower;

% Pg - sp >= Pupper
A2 = [Zb Zb I Zg -I Zg m_0];
u2 = Pupper;
% sm - T <= 0
A3 = [Zb Zb Zg Zg I Zg -ones(ng,1)];
u3 = zeros(ng, 1);
% sp - T <= 0
A4 = [Zb Zb Zg Zg Zg I -ones(ng,1)];
u4 = zeros(ng, 1);
%
% sp>=0  <=> -sp <=0
A5 = [Zb Zb Zg Zg Zg -I m_0];
u5 = zeros(ng, 1);
% sm>=0  <=> -sm <=0
A6 = [Zb Zb Zg Zg -I Zg m_0];
u6 = zeros(ng, 1);
%
u_added=[u1; u2; u3; u4;u5;u6];
mpc.A = [A1; A2; A3; A4;A5;A6];
size_dif=size(mpc.A,1)-length(u_added);
mpc.u = [1e10.*ones(size_dif,1);u_added];
mpc.l=[-1e10.*ones(length(u_added),1)];
mpc.N = [sparse(1, 2*nb+4*ng) 1];   % select T

mpc.Cw = 1;
mpc.gencost(:,5:7)=0;
res=runopf(mpc)
res2=runopf(mpc1);

From: 
bounce-124729550-81515...@list.cornell.edu<mailto:bounce-124729550-81515...@list.cornell.edu>
 
<bounce-124729550-81515...@list.cornell.edu<mailto:bounce-124729550-81515...@list.cornell.edu>>
 On Behalf Of m.drabe...@onet.eu<mailto:m.drabe...@onet.eu>
Sent: Wednesday, June 24, 2020 6:30 PM
To: 'MATPOWER discussion forum' 
<matpowe...@list.cornell.edu<mailto:matpowe...@list.cornell.edu>>
Subject: RE: Extension to AC OPF - soft limits

Thanks Ray very much for your support!  I greatly appreciate it

I will it give the code a go and come back to you with feedback

Thanks and regards
Mariusz

From: 
bounce-124729090-81515...@list.cornell.edu<mailto:bounce-124729090-81515...@list.cornell.edu>
 
<bounce-124729090-81515...@list.cornell.edu<mailto:bounce-124729090-81515...@list.cornell.edu>>
 On Behalf Of Ray Daniel Zimmerman
Sent: Wednesday, June 24, 2020 4:10 PM
To: MATPOWER-L <matpowe...@list.cornell.edu<mailto:matpowe...@list.cornell.edu>>
Subject: Re: Extension to AC OPF - soft limits

I don’t think there is a way to do this using the existing soft limits 
functionality in MATPOWER. However, it should be fairly straightforward to 
implement using user-defined linear constraints and costs, since all of your 
constraints and costs are linear. The simplest approach would probably be to 
use Direct Specification as described in Section 7.1 of the User’s Manual.

Simply add A, l and u as extra fields in mpc to defined the constraints, with 
extra columns in A to define the s and T variables. Then add N and Cw as extras 
fields to define the cost on the new T variable (using the legacy cost format). 
I suppose you will also want to set the generator costs to zero in the gencost 
matrix.

For example, A and N can be defined with 2*nb + 4*ng + 1 columns, corresponding 
to Va, Vm, Pg, Qg, sm, sp, T. The following (untested) code, should at least be 
close to what you want …

nb = size(mpc.bus, 1);
ng = size(mpc.gen, 1);
I = speye(ng,ng);       % ng x ng identity matrix
Zb = sparse(ng, nb);    % ng x nb zero matrix
Zg = sparse(ng, ng);    % ng x ng zero matrix

% -Pg - sm <= -Plower
A1 = [Zb Zb -I Zg -I Zg 0];
u1 = -Plower;

% Pg - sp >= Pupper
A2 = [Zb Zb I Zg -I Zg 0];
u2 = Pupper;

% sm - T <= 0
A3 = [Zb Zb Zg Zg I Zg -1];
u3 = zeros(ng, 1);

% sp - T <= 0
A4 = [Zb Zb Zg Zg Zg I -1];
u4 = zeros(ng, 1);

mpc.A = [A1; A2; A3; A4];
mpc.u = [u1; u2; u3; u4];

mpc.N = [sparse(1, 2*nb+4*ng) 1];   % select T
mpc.Cw = 1;

Let me know how it works,

    Ray


On Jun 23, 2020, at 2:58 PM, m.drabe...@onet.eu<mailto:m.drabe...@onet.eu> 
wrote:

Dear community,,


I am now working with soft limits on generation in AC-OPF. I know that these 
are natively supported by  Matpower.

However, I would like to change the formulation so to minimize the maximum 
value of limit violation on P_G  , i.e. as in the model below:
<image001.jpg>

I would like to ask you all if this is anyhow supported by Matpower  ? If yes, 
what would be the easiest way to do that?


Thanks in advance and regards,

Mariusz Drabecki,

Operations and Systems Research Division
Institute of Control and Computation Engineering
Warsaw University of Technology


Reply via email to