-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_SMO.py
26 lines (19 loc) · 697 Bytes
/
test_SMO.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
import numpy as np
import timeit as tm
import StQPAlgorithmSMO as stqpSMO
prob_file_name = "Problems/Dataset_Generic/Problem_200x200(0.75)_1.txt"
Q = np.loadtxt(prob_file_name)
n = Q.shape[0]
c = np.zeros(n, dtype=float)
# Punto di partenza x0 = (1, 0, . . ., 0)
#x0 = np.zeros(n, dtype=float)
#x0[0] = 1.0
# Punto di partenza x0 = (1/n, . . ., 1/n)
x0 = np.full(n, (1.0/n), dtype=float)
problemSMO = stqpSMO.SMOAlgorithm(n, Q, c, x0)
start_time = tm.default_timer()
solution = problemSMO.solve_problem()
stop_time = tm.default_timer()
print("\nPROBLEM:", prob_file_name.split("/")[2][:-4])
print("Objective function minimum:", solution)
print("Minimization time:", stop_time - start_time)