Converging Workflow
Get a copy of this example
$ cylc get-resources examples/converging-workflow
A workflow which runs a pattern of tasks over and over until a convergence condition has been met.
- The - incrementtask runs some kind of model or process which increments us toward the solution.
- The - check_convergencetask, checks if the convergence condition has been met.
[meta]
    title = Converging Workflow
    description = """
        A workflow which runs a pattern of tasks over and over until a
        convergence condition has been met.
    """
[scheduling]
    cycling mode = integer
    initial cycle point = 1
    [[graph]]
        P1 = """
            # run "increment" then check the convergence condition
            check_convergence[-P1]:not_converged? => increment => check_convergence
            # if the workflow has converged, then do nothing
            check_convergence:converged?
        """
[runtime]
    [[increment]]
        # a task which evolves the data
    [[check_convergence]]
        # a task which checks whether the convergence condition has been met
        script = """
            if (( CYLC_TASK_CYCLE_POINT == 4 )); then
                # for the purpose of example, assume convergence at cycle point 4
                cylc message -- 'convergence condition met'
            else
                cylc message -- 'convergence condition not met'
            fi
        """
        [[[outputs]]]
            converged = 'convergence condition met'
            not_converged = 'convergence condition not met'
Run it with:
$ cylc vip converging-workflow
Example - Genetic algorithms
An example of a converging workflow might be a genetic algorithm, where you “breed” entities, then test their “fitness”, and breed again, over and over until you end up with an entity which is able to satisfy the requirement.