First of all, your sparse() command has 7 inputs, it should only have 5.
Second, the resulting A matrix only has ng rows, it should have 2*ng rows. What 
you want is essentially what you get if you build it twice, once with each of 
the QPratio values, then stack the matrices on top of each other. You can do 
this with a single call to sparse() or with two calls, stacking the results.
Then, you need to modify l and u so that one set of constraints is bounded only 
above (l = -Inf) and the other set is bounded only below (u = Inf).

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




On Feb 7, 2012, at 5:35 AM, Roberto Carvalini wrote:

> Dear Dr. Zimmerman,
> 
> I want to set PF between 0.8 and 0.9 for all generators. I have changed A as 
> follows and I am not sure whether it is true or not. It always gives last PF. 
> I don't know why?
> mpc.A = sparse([1:ng 1:ng  1:ng 1:ng]', [2*nb+(1:ng) 2*nb+ng+(1:ng) 
> 2*nb+(1:ng) 2*nb+ng+(1:ng)]', [QPratio1*ones(ng,1); -ones(ng,1), 
> QPratio2*ones(ng,1); -ones(ng,1)], ng, 2*nb+2*ng, ng, 2*nb+2*ng)
> mpc.A = mpc.A(2:end, :);
> mpc.l = zeros(ng-1, 1);
> mpc.u = mpc.l;
> 
> 
> Best Wishes
> 
> Roberto 
> 
> 
> On Mon, Feb 6, 2012 at 22:03, Ray Zimmerman <[email protected]> wrote:
> You simply replace the single equality constraint (per gen) with two 
> inequality constraints with the two corresponding QPratio values.
> 
> pf1 = 0.8;
> pf2 = 0.9;
> QPratio1 = sqrt(1/pf1^2 -1);
> QPratio2 = sqrt(1/pf2^2 -1);
> % then write the constraints for 
> % QPratio1 * Pg(i) - Qg(i) > 0
> % QPratio2 * Pg(i) - Qg(i) < 0
> 
> I don't have time to work out the details for you, I think I got the 
> inequalities correct.
> -- 
> Ray Zimmerman
> Senior Research Associate
> 419A Warren Hall, Cornell University, Ithaca, NY 14853
> phone: (607) 255-9645
> 
> 
> 
> 
> On Feb 6, 2012, at 9:13 AM, Roberto Carvalini wrote:
> 
>> Dear Ray,
>> 
>> According to your reply to one of the posts as you specified a predefined PF 
>> as follow. Now, I want to have only a range of Power Factor, for example, 
>> between 0.9 and 0.8. What changes I have to do in the following program in 
>> order to have variable PF between 0.8 and 0.9.
>> 
>> define_constants;
>> mpc = loadcase('case9');
>> nb = size(mpc.bus, 1);
>> ng = size(mpc.gen, 1);
>> pf = 0.95;
>> QPratio = sqrt(1/pf^2 -1);
>> %% add constraint that QPratio * Pg(i) - Qg(i) = 0, for i = 2 .. ng
>> mpc.A = sparse([1:ng 1:ng]', [2*nb+(1:ng) 2*nb+ng+(1:ng)]', 
>> [QPratio*ones(ng,1); -ones(ng,1)], ng, 2*nb+2*ng);
>> mpc.A = mpc.A(2:end, :);
>> mpc.l = zeros(ng-1, 1);
>> mpc.u = mpc.l;
>> r = runopf(mpc);
>> 
>> Regards
>> 
>> Roberto 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 

Reply via email to