def materialize_ensembles(components, ensembles):
    """
    Performs the materialization of all ensembles. That includes actuating the materialized ensembles and collecting data for the estimates.

    Parameters
    ----------
    components : List['Component']
        All components in the system.
    ensembles : List['Ensemble']
        All potential ensembles in the system.

    Returns
    -------
    List['Ensemble']
        The materialized ensembles.
    """
    materializedEnsembles = []

    potentialEnsembles = sorted(ensembles)
    for ens in potentialEnsembles:
        if ens.materialize(components, materializedEnsembles):
            materializedEnsembles.append(ens)
            ens.actuate()
    for ens in potentialEnsembles:
        ens.collectEstimatesData(components)

    return materializedEnsembles