def load_shedding(network, **kwargs):
    """ Implement load shedding in existing network to identify
    feasibility problems
    
    Parameters
    ----------
    network : :class:`pypsa.Network
        Overall container of PyPSA
    marginal_cost : int
        Marginal costs for load shedding
    p_nom : int
        Installed capacity of load shedding generator
    Returns
    -------

    """

    marginal_cost_def = 10000  # network.generators.marginal_cost.max()*2
    p_nom_def = network.loads_t.p_set.max().max()

    marginal_cost = kwargs.get('marginal_cost', marginal_cost_def)
    p_nom = kwargs.get('p_nom', p_nom_def)

    network.add("Carrier", "load")
    start = network.generators.index.to_series().str.rsplit(
        ' ').str[0].astype(int).sort_values().max() + 1
    index = list(range(start, start + len(network.buses.index)))
    network.import_components_from_dataframe(
        pd.DataFrame(
            dict(marginal_cost=marginal_cost,
                 p_nom=p_nom,
                 carrier='load shedding',
                 bus=network.buses.index),
            index=index),
        "Generator"
    )
    return
def load_shedding ( network , ** kwargs ) : marginal_cost_def = 10000 p_nom_def = network . loads_t . p_set . max ( ) . max ( ) marginal_cost = kwargs . get ( 'marginal_cost' , marginal_cost_def ) p_nom = kwargs . get ( 'p_nom' , p_nom_def ) network . add ( "Carrier" , "load" ) start = network . generators . index . to_series ( ) . str . rsplit ( ' ' ) . str [ 0 ] . astype ( int ) . sort_values ( ) . max ( ) + 1 index = list ( range ( start , start + len ( network . buses . index ) ) ) network . import_components_from_dataframe ( pd . DataFrame ( dict ( marginal_cost = marginal_cost , p_nom = p_nom , carrier = 'load shedding' , bus = network . buses . index ) , index = index ) , "Generator" ) return
Implement load shedding in existing network to identify
    feasibility problems
    
    Parameters
    ----------
    network : :class:`pypsa.Network
        Overall container of PyPSA
    marginal_cost : int
        Marginal costs for load shedding
    p_nom : int
        Installed capacity of load shedding generator
    Returns
    -------