Hello,
I'm trying to add a nonlinear cost constraint : cost = x' H x+e'x+M
I've used the direct method to create field
mpc.user_constraints.nli={
{'f_cost', 1, 'gh_fcn', 'hess_fcn', { },{ }}
};
where
f_fcn = @(x)f_cost(x, H, e, M);
gh_fcn = @(x) nli_constraint(x, H, e, M);
hess_fcn = @(lam) nli_constraint_hess(lam, H);
I've attached .m files for reference. The opf_setup evaluates fcn and hess
that requires nlc{6}. Even though I've added a cell { } in nlc{6} there are
errors and gh_fcn is said to be undefined. Could you guide me on how to
proceed?
These are the errors I'm getting:
> MATPOWER Version 6.1-dev, 27-Sep-2017 -- AC Optimal Power Flow
> Undefined function or variable 'gh_fcn'.
>
> Error in opf_setup>@(x)gh_fcn(x,nlc{6}{:})
>
> Error in opt_model/eval_nln_constraint (line 81)
> [gk, dgk] = fcn(xx); %% evaluate kth constraint and gradient
>
> Error in opf_consfcn (line 54)
> [h, dh] = om.eval_nln_constraint(x, 0); %% inequalities (branch flow
> limits)
>
> Error in
> mipsopf_solver>@(x)opf_consfcn(x,om,Ybus,Yf(il,:),Yt(il,:),mpopt,il) (line
> 118)
> gh_fcn = @(x)opf_consfcn(x, om, Ybus, Yf(il,:), Yt(il,:), mpopt, il);
>
> Error in mips (line 354)
> [hn, gn, dhn, dgn] = gh_fcn(x); %% nonlinear constraints
>
> Error in mipsopf_solver (line 121)
> 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 217)
> [results, success, raw] = opf_execute(om, mpopt);
>
> Error in runopf (line 75)
> [r, success] = opf(casedata, mpopt);
>
> Error in Add_constraints (line 30)
> r = runopf(mpc, mpopt);
>
Thank you,
Monisha Raju
Graduate Research Assistant
University at Buffalo
Add_constraints
Description: Binary data
function [f, df, d2f] = f_cost(x, H, e, M)
f = x'*H*x + e'*x + M;
if nargout > 1 %% gradient is required
df = 2*H*x+e;
if nargout > 2 %% Hessian is required
d2f = 2*H; %% actually not used since
end %% hess_fcn is provided
endfunction [h, g, dh, dg] = nli_constraint(x,H,e,M) h = x'*H*x +e' *x +M; dh = 2*H*x+e; g=[]; dg=[];
function Lxx = nli_constraint_hess(lam,H) cost_mult = 1; mu = lam.ineqnonlin; Lxx = 2 * (cost_mult + mu) * H;
