Sets the task running condition that will be evaluated during the optimisation cycle.

def with_condition(self, condition: Callable[[MonitorContext], bool]) -> 'MonitorTask':
        """
        Sets the task running condition that will be evaluated during the optimisation cycle.
        """
        self._condition = condition
        return self