Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created May 13, 2021 14:24

Revisions

  1. samirsaci created this gist May 13, 2021.
    18 changes: 18 additions & 0 deletions model.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # Solve Model
    model.solve()
    print("Total Costs = {:,} ($/Month)".format(int(value(model.objective))))
    print('\n' + "Status: {}".format(LpStatus[model.status]))


    # Dictionnary
    dict_plant = {}
    dict_prod = {}
    for v in model.variables():
    if 'plant' in v.name:
    name = v.name.replace('plant__', '').replace('_', '')
    dict_plant[name] = int(v.varValue)
    p_name = name
    else:
    name = v.name.replace('production__', '').replace('_', '')
    dict_prod[name] = v.varValue
    print(name, "=", v.varValue)