Commit 9bca4717 authored by Bowen Wu's avatar Bowen Wu
Browse files

Add replay script and change solution status

parent 8099ff8c
......@@ -42,7 +42,7 @@ class CplexSolver(Solver):
# MIP
101 : OPTIMAL,
102 : OPTIMAL,
115 : OPTIMAL, # https://www-eio.upc.edu/lceio/manuals/cplex-11/html/usrcplex/solveLP19.html
115 : INFEASIBLE, # https://www-eio.upc.edu/lceio/manuals/cplex-11/html/usrcplex/solveLP19.html
103 : INFEASIBLE,
118 : UNBOUNDED,
119 : INF_OR_UNBD
......
from optimizer import OPTIMAL, CplexSolver, GurobiSolver
import glob
import os
import sys
def replay(path):
cpx = CplexSolver()
grb = GurobiSolver()
diff_mps = glob.glob(os.path.join(path, "*.mps"))
print(diff_mps)
for mps in diff_mps:
print(mps)
cpx_sol = cpx(mps)
print("Cplex: Status = ", cpx_sol["status"], end="")
if cpx_sol["status"] == OPTIMAL:
print(", Obj Val = ", cpx_sol["obj_val"])
grb_sol = grb(mps)
print("Gurobi: Status = ", grb_sol["status"], end="\n\n" if grb_sol["status"] != OPTIMAL else "")
if grb_sol["status"] == OPTIMAL:
print(", Obj Val = ", grb_sol["obj_val"], "\n")
if __name__ == "__main__":
assert len(sys.argv) >= 2, "Number of arguments must be larger than 2"
replay(sys.argv[1])
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment