I’m not certain, without seeing the exact error message, but I think there are
two problems in your second line below. You need to provide all 6 elements
listed in Table 7-1 (you only have the first 4) and the 3rd and 4th elements
are provided as string values containing the function names. So I think it
should be ...
mpc.user_constraints.nli = {{'cost', 5, 'nli_constraint',
'nli_constraint_hess', {}, {}}};
In response to the question in your previous email, the functions are called
automatically from within opf_consfcn() and opf_hessfcn(), which are in turn
called at every iteration of the solver (MIPS, fmincon, Ipopt, or Knitro) with
the current value of x and lambda.
— Ray
> On Oct 22, 2017, at 8:32 PM, Viswanath Hariharan <[email protected]> wrote:
>
> I tried using mpc.user_constraints.nli = {.....} as suggested by the manual.
> I created 2 functions one which returns constraint values and gradients and
> one which returns the hessian. After adding the field to mpc, I used runopf.
> It showed an error saying "Not enough input arguments" in the line where I
> use x to calculate constraint value in nli_constraint (from the code below).
>
> mpc = loadcase('case5.m')
> mpc.user_constraints.nli = {{'cost', 5, nli_constraint, nli_constraint_hess}}
> r = runopf(mpc)
>
> nli_constraint and nli_constraint_hess were functions I created with x and x,
> lambda as input arguments respectively.
> Could you guide me as to where I might be going wrong with this?
>
> Regards
> Viswanath
>
>
>
> On Thu, Oct 19, 2017 at 11:31 AM, Viswanath Hariharan <[email protected]
> <mailto:[email protected]>> wrote:
> Sir
> So where does these functions obtain x and where does the hess function
> obtain lambda from?
> Because when I define these functions and I provide X and lambda as inputs,
> it'll show error, I thought.
>
> Regards
> Viswanath
>
>
> On Oct 19, 2017 10:47 AM, "Ray Zimmerman" <[email protected]
> <mailto:[email protected]>> wrote:
> Hi Viswanath,
>
> Since your constraint is an inequality, let’s call it h(x). And since, h(x)
> <= 0, you need to define it as …
>
> h(x) = x'Hx + e'x + C – N
>
> 1. The function you need to implement computes the Hessian of lambda’ * h(x)
> for a given value of lambda and x. Both lambda and x are provided as inputs,
> you provide the Hessian of lambda’ * h(x) as output. Since h(x) (and also
> lambda) is a scalar in your case, the Hessian is simply lambda * H.
>
> 2. I assume N is a constant that is entered as part of your definition of
> h(x).
>
> Ray
>
>
>> On Oct 18, 2017, at 3:10 PM, Viswanath Hariharan <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Sir
>> I have a doubt about the method you asked me to try to add non-linear
>> constraints.
>> The constraint I want to add is x'Hx + e'x + C < = N (where N is cost let's
>> say 20000 or 15000).
>>
>> The above method asks me to create 2 functions, one that calculates gradient
>> values and constraint values and the other that calculates Hessian of one of
>> the lagrangian term that consists of lambda.
>>
>> 1. Say f = x'Hx + e'x + C < = N, Should I be computing the hessian of
>> lambda*f ? How do I compute lambda?
>> 2. Also, could you guide me as to where should I be inputting N?
>>
>> Thank you.
>>
>> Regards
>> Viswanath
>>
>> On Thu, Oct 5, 2017 at 10:41 AM, Ray Zimmerman <[email protected]
>> <mailto:[email protected]>> wrote:
>> (Btw, simply reply to the list, no need to copy the list owner)
>>
>> MATPOWER 6.0 and earlier does not have the capability to add nonlinear
>> constraints to the OPF. However, this feature was just added to the master
>> branch in GitHub <https://github.com/MATPOWER/matpower/>. See options 2 or 3
>> under “Getting MATPOWER” in the README
>> <https://github.com/MATPOWER/matpower/blob/master/README.md>. The PDF manual
>> for the latest development version of MATPOWER can typically be found here:
>>
>> https://www.dropbox.com/s/3qkji1cuyi075uj/MATPOWER-manual.pdf?dl=0
>> <https://www.dropbox.com/s/3qkji1cuyi075uj/MATPOWER-manual.pdf?dl=0>
>>
>> You’ll probably want to use the method described in Section 7.1.2 for
>> Nonlinear Constraints. In particular, you’ll want to look at the example
>> mentioned in t_opf_mips().
>>
>> Hope this helps,
>>
>> Ray
>>
>>
>>
>>> On Oct 4, 2017, at 5:59 PM, Viswanath Hariharan <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> Hello Sir
>>> I want to add non linear cost constraints to the opf solver.
>>> cost = x'Hx + C'x + constant <= 20000
>>>
>>> How do I use the add_constraints function to add this constraint? Should I
>>> be adding new fields to om and then should I be passing it to
>>> add_constraints?
>>>
>>> Regards
>>> Viswanath Hariharan
>>>
>>
>>
>
>