-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
67 lines (50 loc) · 1.52 KB
/
Copy pathutils.py
File metadata and controls
67 lines (50 loc) · 1.52 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import numpy as np
import scipy as sp
import os, shutil
def get_average_solvetime(df):
size = set(df["size"])
size = [*size]
size.sort()
time = []
for sz in size:
idx = df[df["size"] == sz].index
time.append(np.nanmean(df["run_time"][idx]))
return size, time
def export_figures():
source_dir = "./plots/"
for file_name in os.listdir(source_dir):
source_file = os.path.join(source_dir, file_name)
destination_file = os.path.join("../qoco-paper/img", file_name)
# Check if it is a file and not a directory
if os.path.isfile(source_file):
shutil.copy(source_file, destination_file)
def parse_maros(mm_data):
n = len(mm_data["lb"])
P = mm_data["Q"]
c = np.squeeze(mm_data["c"], axis=1)
Amm = mm_data["A"].tocsc()
rl = np.squeeze(mm_data["rl"], axis=1)
ru = np.squeeze(mm_data["ru"], axis=1)
lb = np.squeeze(mm_data["lb"], axis=1)
ub = np.squeeze(mm_data["ub"], axis=1)
eq_idx = np.where(rl == ru)[0]
ineq_idx = np.where(rl != ru)[0]
Aeq = Amm[eq_idx]
beq = rl[eq_idx]
Aineq = Amm[ineq_idx]
uineq = ru[ineq_idx]
lineq = rl[ineq_idx]
G = sp.sparse.vstack(
(sp.sparse.identity(n), -sp.sparse.identity(n), Aineq, -Aineq)
).tocsc()
h = np.hstack((ub, -lb, uineq, -lineq))
# Drop inf
idx = np.where(h != np.inf)
G = G[idx]
h = h[idx]
m = G.shape[0]
p = Aeq.shape[0]
l = m
nsoc = 0
q = []
return n, m, p, P, c, Aeq, beq, G, h, l, nsoc, q