Skip to content

Termination with an expression of objectives #527

Answered by blankjul
dinohsu1019 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes you have full control over termination and can write your own logic. I have coded up an example for you below where I am testing if the ideal point is below a specific value. The MyTermination overwrites the _update method where you can return a 1 if terminated and a 0 otherwise.

import numpy as np

from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.core.termination import Termination
from pymoo.optimize import minimize
from pymoo.problems import get_problem
from pymoo.visualization.scatter import Scatter


class Mytermination(Termination):

    def _update(self, algorithm):
        ideal = algorithm.opt.get("F").min(axis=0)
        print(ideal)
        return 1 if np.all(ideal <…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dinohsu1019
Comment options

Answer selected by dinohsu1019
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