Skip to content

Commit

Permalink
Add suboptimal solution test using JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
torressa committed Sep 18, 2024
1 parent 82c0b19 commit ac8091a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_solcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ def test_suboptimal_solution(self):

self.assertEqual(self.afirofix_md5, md5_ret)

def test_suboptimal_json_solution(self):
afirofix_file = cwd.joinpath("afirofix.sol")
self.assertFalse(afirofix_file.exists())
cmd = (
f"gurobi_solcheck --model {str(here / 'dataset' / 'afiro.mps')} "
+ f"--sol {str(here / 'dataset' / 'afiro.json')} --result afirofix"
)
result = subprocess.getoutput(cmd)
self.assertIn(
"Solution is feasible for feasibility tolerance of 1e-06",
result,
)
self.assertIn("Difference: -5.0613", result)
self.assertTrue(afirofix_file.exists())

md5_ret = None
with open(afirofix_file, "rb") as f:
d = f.read()
md5_ret = hashlib.md5(d).hexdigest()

self.assertEqual(self.afirofix_md5, md5_ret)

def test_infeasible_solution(self):
misc07fix_vio_file = cwd.joinpath("misc07fix.vio")
self.assertFalse(misc07fix_vio_file.exists())
Expand Down

0 comments on commit ac8091a

Please sign in to comment.