-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_5-10.py
33 lines (23 loc) · 1020 Bytes
/
test_5-10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
import sccapy
from sccapy.main import Problem
from sccapy.utilities.generate_data import gen_data
from sccapy.utilities.problem_data import ProblemData
from sccapy.research_algorithms.local_search import localsearch
from sccapy.research_algorithms.objective_eval import fval
from sccapy.research_algorithms.variable_fix import varfix
from sccapy.research_algorithms.upper_bound import upper_bound
n1, n2 = 40, 40
s1, s2 = 10, 10
prob: ProblemData = ProblemData(n1, n2, s1, s2)
A, B, C = gen_data(n1, n2, s1, s2)
setattr(prob, "A", np.matrix(np.copy(A)))
setattr(prob, "B", np.matrix(np.copy(B)))
setattr(prob, "C", np.matrix(np.copy(C)))
lb, _ = localsearch(prob)
_, fixed_vars, var_scores, var_fixing_time = varfix(prob, lb)
ub, _ = upper_bound(prob, [], fixed_vars)
# print("OUTSIDE CALL GAP: ", ub - lb) # DEBUG
prob1: Problem = Problem(n1, n2, s1, s2, A=A, B=B, C=C)
prob1.solve(lower_bound_func=localsearch, upper_bound_func=upper_bound,
var_fix=varfix, objective_func=fval)