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

Allow ConstrainedFitnessAL to accept constraint values #263

Closed
jordan-cork opened this issue Sep 2, 2024 · 2 comments
Closed

Allow ConstrainedFitnessAL to accept constraint values #263

jordan-cork opened this issue Sep 2, 2024 · 2 comments

Comments

@jordan-cork
Copy link

Currently, ConstrainedFitnessAL works by taking in a constraints function in its constructor. I have a situation where I'm not able to provide this function, but am able to provide the constraint values during the call to ConstrainedFitnessAL. Would it be possible to amend ConstrainedFitnessAL so that it is able to work in the way seen below?

al = cma.ConstrainedFitnessAL(fitness_function) # Doesn't require the constraint function

penalised_fitness_values = al(solutions, constraint_values) # Accepts the already calculated constraint values

Additionally, I can also imagine an even more black box situation, where the fitness function is not known either. Perhaps, ConstrainedFitnessAL could also be adapted for this situation (see below)?

al = cma.ConstrainedFitnessAL() # Doesn't require fitness function or constraint function

penalised_fitness_values = al(fitness_values, constraint_values) # Accepts precalculated fitness and constraint values (probably without the need for x values)

Thanks

@nikohansen
Copy link
Contributor

Thanks for the suggest! Issue #258 looks to be related.

To my understanding, cma.ConstrainedFitnessAL is meant to be a callable fitness wrapper around cma.constraints_handler.AugmentedLagrangian. That is, if you don't want a callable fitness, you probably don't want to use cma.ConstrainedFitnessAL in the first place. Hence, you probably want to check out how to use the underlying cma.constraints_handler.AugmentedLagrangian, maybe along the lines of this code.

@jordan-cork
Copy link
Author

Thanks. It looks like constraints_handler.AugmentedLagrangian serves my purposes.

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