Commit b5bcb514 authored by Bowen Wu's avatar Bowen Wu
Browse files

Extend Cplex MIP solution status

parent 65bfcccd
......@@ -3,7 +3,6 @@ import sys
from pysmps.pysmps.smps_loader import load_mps, MPSParseError
from generator import MPSProgram
import glob
import pandas as pd
# A simple wrapper to suppress talkative APIs from printing
# Inspired from https://stackoverflow.com/a/45669280
......@@ -54,41 +53,26 @@ def print_mps_dict(mps: dict):
for k in mps:
print(f"{bcolors.OKBLUE}{k}\n{bcolors.ENDC}", mps[k])
def read_benchmark_mps(max_size):
def read_benchmark_mps():
"""
Check if the current parser can handle all possible cases in the seed pool
Parameter:
maxsize: maximum size of the file interested in bytes
"""
tests = glob.glob("benchmark/*.mps")
tests = glob.glob("/Users/bowenwu/optfuzz_seeds/*.mps")
import time
for test in tests:
if os.stat(test).st_size > max_size: continue
print("Reading ", test)
start = time.time()
try:
load_mps_dict(test)
print(test, "succeeds.\n")
d = load_mps_dict(test)
MPSProgram(**d).__str__()
except MPSParseError as e:
print(test, " fails.\n", e)
print("Time taken = ", time.time() - start)
def prepare_seed_pool():
"""
Prepare the seeds obtained from https://miplib.zib.de/tag_benchmark.html
Requirement:
1. Questions labeled as easy (hard problems take a long time to solve)
2. Questions that contain binary or integer variables (MIP is more prone to bugs)
3. Reasonable problem size
"""
bm_file = "benchmark/benchmark.csv"
max_var_num = 150
df = pd.read_csv(bm_file)
print(df.head)
df = df[df['Status Sta.'] == "easy"]
df = df[df['Binaries Bin.'] + df['Integers Int.'] > 0]
df = df[df['Variables Var.'] <= max_var_num]
print(df.head)
def print_load_mps_ret(path):
name, objsense, objective_name, row_names, col_names, col_types, types, c, A, rhs_names, rhs, bnd_names, bnd = load_mps(path)
......
......@@ -42,7 +42,10 @@ class CplexSolver(Solver):
# MIP
101 : OPTIMAL,
102 : OPTIMAL,
103 : INFEASIBLE
115 : OPTIMAL, # https://www-eio.upc.edu/lceio/manuals/cplex-11/html/usrcplex/solveLP19.html
103 : INFEASIBLE,
118 : UNBOUNDED,
119 : INF_OR_UNBD
}
def __init__(self, verbose = False) -> None:
......
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