I have no way of knowing what your user defined program does, but it *appears* that it somehow eliminates the reference bus before calling opf(). You may try putting a breakpoint at line 126 in mipsopf_solver() to confirm that there is no reference bus at that point in the code.
dbstop 126 mipsopf_solver -- Ray Zimmerman Senior Research Associate 419A Warren Hall, Cornell University, Ithaca, NY 14853 phone: (607) 255-9645 On Sep 17, 2012, at 5:32 PM, Richard Ngonga wrote: > Thanks Ray, but I do have a reference bus and my case file is giving me the > right results when I run a pf or opf. > My network has 80 buses and two generators, on of which is a refernce bus. > From: [email protected] > Subject: Re: Branch minimisation loss error message > Date: Mon, 17 Sep 2012 09:17:07 -0400 > To: [email protected] > > It means that you do not have a reference bus defined in your case file. One > of the buses should have the BUS_TYPE column (2) set to REF (3). > > -- > Ray Zimmerman > Senior Research Associate > 419A Warren Hall, Cornell University, Ithaca, NY 14853 > phone: (607) 255-9645 > > > > > On Sep 14, 2012, at 1:41 AM, Richard Ngonga wrote: > > I am getting the following error message whenever I try running a user > defined program to minimize branch losses(min_power_exchange) using my case > file. This problem doesn't occur when I try running the program with a > Matpower supplied case file. Can you please tell me what the error message > means? > > ??? Attempted to access Varefs(1); index out of bounds because > numel(Varefs)=0. > Error in ==> mipsopf_solver at 127 > x0(vv.i1.Va:vv.iN.Va) = Varefs(1); %% angles set to first reference angle > Error in ==> opf_execute at 106 > [results, success, raw] = feval(solver, om, mpopt); > Error in ==> opf at 225 > [results, success, raw] = opf_execute(om, mpopt); > Error in ==> runopf at 96 > [r, success] = opf(casedata, mpopt); > Error in ==> min_power_exchange at 237 > [results, success] = runopf(mpc, mpopt); > Error in ==> testng at 15 > results = min_power_exchange(mpc,mpopt); > > Bellow is my program code > > mpc = loadcase('case803.m'); > > mpopt = mpoption( > > 'VERBOSE',0,'OUT_ALL',0); > > mpc = runopf(case803,mpopt); > > define_constants; > % %% create map of external bus numbers to bus indices > i2e = mpc.bus(:, BUS_I); > > e2i = sparse(max(i2e), 1); > > e2i(i2e) = (1:size(mpc.bus, 1))'; > > % %% ties lines > > ties = find(mpc.bus(e2i(mpc.branch(:, F_BUS)), BUS_AREA) ~= > mpc.bus(e2i(mpc.branch(:, T_BUS)), BUS_AREA)); > > ties_idx = [mpc.branch(ties, F_BUS) mpc.branch(ties, T_BUS)]; > > flow_t0 = [mpc.branch(ties, PF) mpc.branch(ties, QF)]; > > % % Reduction of the load at bus 26 > > %mpc.bus(26,[PD QD]) = 0.8*mpc.bus(26,[PD QD]); > > results = min_power_exchange(mpc,mpopt); > > flow_tf = [results.branch(ties, PF) results.branch(ties, QF)]; > > % % difference of the tie flows > > flow_t0 - flow_tf > >
