def eld_another(U,p_min,p_max,d,brk):
    """eld -- economic load dispatching in electricity generation
    Parameters:
        - U: set of generators (units)
        - p_min[u]: minimum operating power for unit u
        - p_max[u]: maximum operating power for unit u
        - d: demand
        - brk[u][k]: (x,y) coordinates of breakpoint k, k=0,...,K for unit u
    Returns a model, ready to be solved.
    """
    model = Model("Economic load dispatching")

    # set objective based on piecewise linear approximation
    p,F,z = {},{},{}
    for u in U:
        abrk = [X for (X,Y) in brk[u]]
        bbrk = [Y for (X,Y) in brk[u]]
        p[u],F[u],z[u] = convex_comb_sos(model,abrk,bbrk)
        p[u].lb = p_min[u]
        p[u].ub = p_max[u]

    # demand satisfaction
    model.addCons(quicksum(p[u] for u in U) == d, "demand")

    # objective
    model.setObjective(quicksum(F[u] for u in U), "minimize")

    model.data = p
    return model
def eld_another ( U , p_min , p_max , d , brk ) : model = Model ( "Economic load dispatching" ) p , F , z = { } , { } , { } for u in U : abrk = [ X for ( X , Y ) in brk [ u ] ] bbrk = [ Y for ( X , Y ) in brk [ u ] ] p [ u ] , F [ u ] , z [ u ] = convex_comb_sos ( model , abrk , bbrk ) p [ u ] . lb = p_min [ u ] p [ u ] . ub = p_max [ u ] model . addCons ( quicksum ( p [ u ] for u in U ) == d , "demand" ) model . setObjective ( quicksum ( F [ u ] for u in U ) , "minimize" ) model . data = p return model
eld -- economic load dispatching in electricity generation
    Parameters:
        - U: set of generators (units)
        - p_min[u]: minimum operating power for unit u
        - p_max[u]: maximum operating power for unit u
        - d: demand
        - brk[u][k]: (x,y) coordinates of breakpoint k, k=0,...,K for unit u
    Returns a model, ready to be solved.