Hi Monisha,
I don’t have time to debug this further, but hopefully this will point you the
right direction. Your call to om.add_nln_constraint() in toggle_power_flow() is
not valid. You should instead use something like the following …
fcn = @(x)power_flow_fcn(x, mpc, Pf, Qf, Pt, Qt);
hess = @(x, lam)power_flow_hess(x, lam, Pf, Qf, Pt, Qt);
om.add_nln_constraint('Flow_constraints', 4*nl, 1, fcn, hess);
Also, may I suggest that, rather than loading values from a .mat file, you put
any additional input data you need in a new field in mpc, which is already
available to the formulation callback.
Ray
> On Jan 4, 2018, at 6:43 PM, Monisha Raju <[email protected]> wrote:
>
> I've attached the .mat file here
> Monisha Raju
> Graduate Research Assistant
> University at Buffalo
>
>
> On Thu, Jan 4, 2018 at 3:45 PM, Ray Zimmerman <[email protected]> wrote:
>> It seems I also need a file named M.mat. Could you send it to me off-list?
>>
>> Here’s what I get now ...
>>
>>
>>>> mpc = loadcase('case9');
>>>> mpc = toggle_power_flow(mpc, 'on');
>>>> r = runopf(mpc);
>> Error using toggle_power_flow>userfcn_power_flow_formulation (line 22)
>> Cannot access 'Mat' because '/Users/ray/Desktop/M.mat' does not exist.
>>
>> Error in run_userfcn (line 32)
>> rv = feval(userfcn.(stage)(k).fcn, rv, varargin{2:end}, args);
>>
>>
>> — Ray
>>
>>
>> On Jan 4, 2018, at 12:25 PM, Monisha Raju <[email protected]> wrote:
>>
>> Hello,
>>
>> I've been using case9 and runopf
>>
>>
>> On Jan 4, 2018 11:39 AM, "Ray Zimmerman" <[email protected]> wrote:
>>>
>>> What commands (esp. which case file?) can I use to duplicate this error?
>>>
>>> Ray
>>>
>>>
>>> On Dec 29, 2017, at 11:38 PM, Monisha Raju <[email protected]> wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to add additional power flow constraints Pf, Qf, Pt and Qt such
>>> that,
>>> V'FpV = Pf ----> V'FpV-Pf = 0
>>>
>>> I've used both the direct and indirect methods of adding user defined
>>> constraints but I'm still unable to get results. These are the errors I'm
>>> getting.
>>>
>>> Insufficient number of outputs from right hand side of equal sign to
>>> satisfy
>>> assignment.
>>>
>>> Error in opt_model/eval_nln_constraint (line 81)
>>> [gk, dgk] = fcn(xx); %% evaluate kth constraint and gradient
>>> Error in opf_consfcn (line 53)
>>> [g, dg] = om.eval_nln_constraint(x, 1); %% equalities (power flow)
>>> Error in
>>> mipsopf_solver>@(x)opf_consfcn(x,om,Ybus,Yf(il,:),Yt(il,:),mpopt,il) (line
>>> 116)
>>> gh_fcn = @(x)opf_consfcn(x, om, Ybus, Yf(il,:), Yt(il,:), mpopt, il);
>>> Error in mips (line 353)
>>> [hn, gn, dhn, dgn] = gh_fcn(x); %% nonlinear constraints
>>> Error in mipsopf_solver (line 119)
>>> mips(f_fcn, x0, A, l, u, xmin, xmax, gh_fcn, hess_fcn, opt);
>>> Error in opf_execute (line 70)
>>> [results, success, raw] = mipsopf_solver(om, mpopt);
>>> Error in opf (line 232)
>>> [results, success, raw] = opf_execute(om, mpopt);
>>> Error in runopf (line 75)
>>> [r, success] = opf(casedata, mpopt);
>>>
>>> I've attached the required files for clarity. I'm hoping for some
>>> clarification with how to formulate nln constraints.
>>>
>>> Regards,
>>> Monisha Raju
>>> Graduate Research Assistant
>>> University at Buffalo
>>> <power_flow_fcn.m><power_flow_hess.m><toggle_power_flow.m>
>>>
>>>
>>
> <M.mat>