[Python] What Python function should I use to perform this discrete maximization function that...

Discussão em 'Python' iniciado por Stack, Fevereiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    Please see the optimization problem in this image, and let me know what the best way to implement this in Python. I have all the available data needed for this. This is my first time posting on stack overflow, so sorry if I'm unaware of built in LaTeX--hopefully the handwriting isn't too bad.

    def access_equity(p:int, M:gpd.GeoDataFrame=homes):

    zsum = 0
    curr_constraints = []
    results = []
    for index, row in M.iterrows():
    g_i = row['transit_dependent_population']
    c_i = row['PRT_ground_coverage']
    if row['no_access_routes']:
    Y = 0
    else:
    Y = 1
    zsum += g_i * Y * c_i
    constraint = LinearConstraint([[-1], [1]], [-Y, p])
    results.append(milp(c=(1/zsum), bounds=(0,1), integrality=1, constraints=constraint).success)
    return results

    Continue reading...

Compartilhe esta Página