You simply need to build an A matrix that has all of your constraints in it. In 
other words, in addition to the rows for the power factor constraints, you will 
be adding additional rows for the constraints that include your new variables. 
But new variables mean new columns in A as well. These must be added to all 
rows, including those for the power factor constraints.

When you have multiple sets of constraints like this that you are adding, it is 
often best to use the callback mechanism described in Chapter 6. You can then 
treat them separately, using the add_vars and add_constraints functions and 
MATPOWER will then form the overall matrix at runtime. It allows you to 
implement and then enable/disable multiple OPF extensions independently.

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



On Jun 20, 2011, at 10:21 AM, Dailan Xu wrote:

> I have used the following code to impose power factor constraint for 
> generators (as you have written for one of the users). How can I 
> differenciate these two problems, i.e. adding a variable z and specified 
> power factor as follows: because we will have 2 matix of A 
> mpc = loadcase('t_auction_case');
> 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;
> Best Regards
> 
> D. Xu
> 
> 
> 
> On Mon, Jun 20, 2011 at 16:08, Ray Zimmerman <[email protected]> wrote:
> Section 6.4 references two examples included in MATPOWER. These both use the 
> callback mechanism. There is another very basic example at about line 184 of 
> t/t_opf_mips.m  that defines the A, l, u and N, fparm, H and Cw parameters to 
> be passed directly to opf. As described in the first paragraph of chapter 6, 
> these parameters can also be specified as additional fields in the case 
> struct, which is how you would need to do it when calling runmarket.
> 
> -- 
> Ray Zimmerman
> Senior Research Associate
> 211 Warren Hall, Cornell University, Ithaca, NY 14853
> phone: (607) 255-9645
> 
> 
> 
> On Jun 20, 2011, at 9:41 AM, Dailan Xu wrote:
> 
>> Thank U. Where can I find an example? or could you please give me an example?
>> 
>> Best Regards
>> 
>> D. Xu
>> 
>> 
>> On Mon, Jun 20, 2011 at 15:28, Ray Zimmerman <[email protected]> wrote:
>> The runmarket code is simply a wrapper around the OPF solver, so it's the 
>> same as adding variables to extend the OPF. The bus voltages are already 
>> control variables, but please see section 5.3 and chapter 6 of the manual 
>> for details on how to extend the OPF with other variables, constraints and 
>> costs.
>> 
>> --
>> Ray Zimmerman
>> Senior Research Associate
>> 211 Warren Hall, Cornell University, Ithaca, NY 14853
>> phone: (607) 255-9645
>> 
>> 
>> 
>> On Jun 20, 2011, at 9:15 AM, Dailan Xu wrote:
>> 
>> > Dear Prof. Zimmerman
>> >
>> > How can I add an optimization variable to runmarket, for example, adding 
>> > voltage of buses as control variable? Is it possible?
>> >
>> > Best Regards
>> >
>> > D. Xu
>> >
>> >
>> 
>> 
>> 
>> 
>> 
> 
> 

Reply via email to