Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help: Generic non-linear constraint with multiple inputs #1015

Closed
fabrizioleone opened this issue Oct 20, 2022 · 1 comment
Closed

Help: Generic non-linear constraint with multiple inputs #1015

fabrizioleone opened this issue Oct 20, 2022 · 1 comment

Comments

@fabrizioleone
Copy link

Hi,

Thanks you for this great package. I am dealing with an optimization problem with generic non-linear constraints. I am reading the relative documentation here.

I understand that non-linear constraints take this form

con_c!(c, x) = (c[1] = x[1]^2 + x[2]^2; c)

and must be passed to optim this way

lc  = [-Inf]
uc  = [1.0]
dfc = TwiceDifferentiableConstraints(con_c!, lc, uc)

How should I supply multiple inputs to con_c!? I would need something like

con_c!(c, x, a) = (c[1] = a*x[1]^2 + x[2]^2; c)

How shall I pass con_c! to TwiceDifferentiableConstraints(con_c!, lc, uc) then?

Thank you

@fabrizioleone
Copy link
Author

OK, never mind. I figured it out. I post my solution just for reference in case others are interested:

con_c!(c, x, a) = (c[1] = a*x[1]^2 + x[2]^2; c)
lc  = [-Inf]
uc  = [1.0]
dfc = TwiceDifferentiableConstraints((cox) -> con_c!(c, x, a), lc, uc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant