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

equal constraints #8

Open
TsingQAQ opened this issue Apr 17, 2017 · 4 comments
Open

equal constraints #8

TsingQAQ opened this issue Apr 17, 2017 · 4 comments

Comments

@TsingQAQ
Copy link

Hi there, I've tried to find a way to define some equal constraints but didn't find one, is there a way to do that?

@tisimst
Copy link
Owner

tisimst commented Apr 18, 2017

Not directly, no.

Equality constraints are inherently difficult to satisfy in optimization routines because the basically force your solution to lie on an infinitely thin line, which, especially for algorithms like PSO, is really hard to land on and stay on by simply guessing values for the input.

A better approach, if possible, is to refactor your objective code to use the equality constraint as a driving calculation that helps determine the objective value. That way, you are guaranteed to satisfy the constraint at all times.

In other words, if you have the constraint ab = c-d and the objective function uses d as an input, then I would change it so that d is calculated, rather than guessed: d = c-(ab)

@tisimst
Copy link
Owner

tisimst commented Apr 18, 2017

Another option, if you aren't able to refactor your code, would be to use a tolerance band around the equality constraint g(x), changing it to two inequality constraints. So, instead of
g(x) = b
you would have
g(x)<= b+tol
and
g(x)>=b-tol
where tol is some small value, relative to the constraint value b.

@TsingQAQ
Copy link
Author

thanks tisimst , very detailed and clear answer.
Since My parameter constrainted are state variables which comes from a black box function, there may not be any hope to refractor that(a iterator may be a solution), then I may choose the latter approach in my case.

@tisimst
Copy link
Owner

tisimst commented Apr 19, 2017

That makes sense. In that case, I'd start with a generous tolerance and see if you can fine-tune it to something more narrow.

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

2 participants