In the user-defined constraints, where l <= A * x <= u, the variable x is in p.u., so the definitions of A, l and u should be consistent with that. So if Load is in MW you need to divide it by mpc.baseMVA.
If you have 41 buses, then A_V should be 1 x 82. Yes, you are correct about the typo in my example. Thanks for pointing it out. -- Ray Zimmerman Senior Research Associate 419A Warren Hall, Cornell University, Ithaca, NY 14853 phone: (607) 255-9645 On Jan 31, 2013, at 5:53 PM, Evangelos Galinas <[email protected]> wrote: > Dear Ray, > > while trying to find a way to add a user defined constraint I came across > this example posted by you a couple years ago: > > What I want to do is to create an equality constraint that will allow only > above a limit of operation of certain units. In fact, I have 14 gens of which > 11 are conventional. I want the output of those eleven gens to be always > above 50% of the total load. So the inequality should be sth like: > > Pg1+Pg2+...Pg11> 0.5* Load > > I have 41 buses so I believe that the following can produce my extra > constraint: > > A_V = sparse(1, 80); > A_Pg = sparse( [ 1 1 1 1 1 1 1 1 1 1 1 0 0 0] ); > A_Qg = sparse(1, 14); > > mpc.A = [A_V A_Pg A_Qg]; > mpc.l = [0.5*Load]; > > Questions: > > In the example following, you only put pu values at the limits of the struct. > Can I use absolute values? > > Does what I present here makes sense? > > In the following example is there a chance there is a typo and it is mpc.u = > [0; 0.09] instead of mpc.u = [0; 0.01] or I am getting sth wrong? > > Best Regards, > > Vagelis > > > > > > > > > > Ok, here's a simple example ... > > Suppose you wanted to add the following two constraints to case9.m: > 1) generator 1 and generator 2 real power output must be equal > 0 <= Pg1 - Pg2 <= 0 > 2) the difference in voltage magnitudes between buses 1 and 9 must be less > than > 0.01 p.u. > -0.01 <= Vm1 - Vm9 <= 0.09 > Since we have 9 buses and 3 generators, the A matrix will be 2 x 24 (9 > angles, > 9 magnitudes, 3 real injections, 3 reactive injections). > > mpc = loadcase('case9'); > A_Va = sparse(2, 9); > A_Vm = sparse( [ 0 0 0 0 0 0 0 0 0; > 1 0 0 0 0 0 0 0 -1 ] ); > A_Pg = sparse( [ 1 -1 0; > 0 0 0 ] ); > A_Qg = sparse(2, 3); > mpc.A = [A_Va A_Vm A_Pg A_Qg]; > mpc.l = [0; -0.01]; > mpc.u = [0; 0.01]; > > opt = mpoption('OUT_BRANCH', 0, 'OUT_ALL_LIM', 0, 'OUT_SYS_SUM', 0); > r = runopf(mpc, opt); > > > >
