Use NumPy to compute AlvLouWeh2017 features

This commit is contained in:
2021-08-10 10:28:30 -05:00
parent e852d5cdca
commit 60b9a6775f
2 changed files with 94 additions and 92 deletions

View File

@@ -2,6 +2,7 @@
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
import os
import sys
import time
from typing import Any
@@ -63,11 +64,11 @@ def test_knapsack() -> None:
sample.get_vector_list("static_var_features"),
np.array(
[
[23.0, 505.0, 1.0, 0.32899, 0.0, 0.0, 505.0, 1.0],
[26.0, 352.0, 1.0, 0.229316, 0.0, 0.0, 352.0, 1.0],
[20.0, 458.0, 1.0, 0.298371, 0.0, 0.0, 458.0, 1.0],
[18.0, 220.0, 1.0, 0.143322, 0.0, 0.0, 220.0, 1.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 67.0],
[23.0, 505.0, 1.0, 0.32899, 0.0, 505.0, 1.0],
[26.0, 352.0, 1.0, 0.229316, 0.0, 352.0, 1.0],
[20.0, 458.0, 1.0, 0.298371, 0.0, 458.0, 1.0],
[18.0, 220.0, 1.0, 0.143322, 0.0, 220.0, 1.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 67.0],
]
),
)
@@ -163,22 +164,20 @@ def test_knapsack() -> None:
1.0,
0.32899,
0.0,
0.0,
505.0,
1.0,
1.0,
0.32899,
0.0,
0.0,
1.0,
1.0,
5.265874,
46.051702,
0.0,
193.615385,
-inf,
-0.111111,
1.0,
311.384615,
inf,
570.869565,
0.913043,
2.043478,
1.0,
@@ -189,24 +188,22 @@ def test_knapsack() -> None:
1.0,
0.229316,
0.0,
0.0,
352.0,
1.0,
1.0,
0.229316,
0.0,
0.076923,
1.0,
1.0,
3.532875,
5.388476,
0.0,
-inf,
0.0,
-0.111111,
0.923077,
317.777778,
570.869565,
0.923077,
inf,
69.0,
0.923077,
],
[
@@ -215,22 +212,20 @@ def test_knapsack() -> None:
1.0,
0.298371,
0.0,
0.0,
458.0,
1.0,
1.0,
0.298371,
0.0,
0.0,
1.0,
1.0,
5.232342,
46.051702,
0.0,
187.230769,
-inf,
-0.111111,
1.0,
270.769231,
inf,
570.869565,
0.9,
2.2,
1.0,
@@ -241,24 +236,22 @@ def test_knapsack() -> None:
1.0,
0.143322,
0.0,
0.0,
220.0,
1.0,
1.0,
0.143322,
0.0,
0.0,
1.0,
-1.0,
46.051702,
3.16515,
5.453347,
0.0,
-23.692308,
-0.111111,
1.0,
-inf,
-13.538462,
243.692308,
0.0,
inf,
69.0,
0.0,
],
[
@@ -268,21 +261,19 @@ def test_knapsack() -> None:
0.0,
0.0,
0.0,
0.0,
67.0,
0.0,
0.0,
0.0,
0.0,
1.0,
-1.0,
0.0,
5.453347,
0.0,
13.538462,
-inf,
-0.111111,
67.0,
-13.538462,
inf,
570.869565,
43.0,
69.0,
67.0,
@@ -391,7 +382,7 @@ class MpsInstance(Instance):
return gp.read(self.filename)
def main() -> None:
if __name__ == "__main__":
solver = GurobiSolver()
instance = MpsInstance(sys.argv[1])
solver.set_instance(instance)
@@ -404,7 +395,4 @@ def main() -> None:
extractor.extract_after_lp_features(solver, sample, lp_stats)
cProfile.run("run()", filename="tmp/prof")
if __name__ == "__main__":
main()
os.system("flameprof tmp/prof > tmp/prof.svg")