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

Passing constraint values to tell #258

Open
nikohansen opened this issue Aug 28, 2024 · 1 comment
Open

Passing constraint values to tell #258

nikohansen opened this issue Aug 28, 2024 · 1 comment

Comments

@nikohansen
Copy link
Contributor

nikohansen commented Aug 28, 2024

Should we allow using tell like (based on a suggestion by @brockho)

tell(solutions, objective_values, constraints_values=constraints_values)

Implementation thoughts: the above call would probably instantiate a AugmentedLagrangian instance and call set_coefficients. The instance call takes a g-value list and returns a penalties list. The penalties sum is meant to be added to the objective value similar to penalty boundary handling. update can be called with the best solution afterwards.

See also ConstrainedFitnessAL which uses an AugmentedLagrangian instance and cma.fmin_con2 which uses the former.

Next steps:

  • outline/implement a AugmentedLagrangian ask-and-tell use case scenario similar to the one with ConstrainedFitnessAL found in this notebook trying to be less opaque than in these docs
  • evaluate the advantages/disadvantages to incorporate this functionality directly into tell.
@nikohansen
Copy link
Contributor Author

nikohansen commented Aug 28, 2024

Attempt of a simplified ask-and-tell use case:

def F_penalized(al, F, G):
    """update `al` and return penalized `F`"""
    al.set_coefficients(F, G)
    F1 = [f + sum(al(g)) for f, g in zip(F, G)]
    i = F1.index(min(F1))  # argmin
    al.update(F[i], G[i])
    return [f + sum(al(g)) for f, g in zip(F, G)]

es = cma.CMAEvolutionStrategy(...)
al = AugmentedLagrangian(es.N)
while not es.stop():
    X = es.ask()
    F = [objective(x) for x in X]
    G = [constraints(x) for x in X]
    es.tell(X, F_penalized(al, F, G))

This looks like it could be easily implemented as an F-penalization within tell which creates an AugmentedLagrangian instance (only) when constraints are passed.

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

No branches or pull requests

1 participant