Skip to content

How to change a value in a constraint in each generation using NSGA-II in Pymoo? #548

Answered by jadiazgu
jadiazgu asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you Julian for your advice.
I tried by declaring a global variable inside the Callback Class and with this I was able to use this variable inside the constraint in every generation.

from pymoo.core.callback import Callback

class CustomCallback(Callback):
    def __init__(self):
        super().__init__()

    def notify(self, algorithm):
	global value_f1min
        solutions = algorithm.pop.get("F")
        value_f1min = min([row[0] for row in solutions])

        return

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jadiazgu
Comment options

@blankjul
Comment options

@jadiazgu
Comment options

Answer selected by jadiazgu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants