-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path1_test_solve.py
More file actions
46 lines (33 loc) · 1.88 KB
/
1_test_solve.py
File metadata and controls
46 lines (33 loc) · 1.88 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
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'XM/build/'))
import numpy as np
import XM
from utils.io import save_matrix_to_bin, load_matrix_from_bin
# The XM solver takes in the Q matrix for the SDP problem
# (more details refer to our paper: https://arxiv.org/abs/2502.04640)
# and it output the R matrix and the s vector. Note these may in rank higher than 3
# so you will need more information for previous matrix process to recover the XM solution
"""
Solves the XM problem using the provided Q matrix.
This function reads the Q matrix from a .bin file (I/O operations are handled by utils.io)
located in the specified dataset path. It then applies the XM algorithm to compute the R matrix
and the s vector. The computed results are saved back as .bin files in the same dataset directory.
Parameters:
dataset_path (str): The path to the dataset containing the Q.bin file.
max_rank (int, optional): The maximum allowed rank for the solution.
For a full XM solution, a larger value (e.g., 10 or 5) may be used to achieve certifiable global minimum.
Defaults to 10.
tol (float, optional): The convergence tolerance. The algorithm will stop iterating when the norm of gradient falls below this threshold.
Defaults to 1e-6.
lam (float, optional): The regularization parameter on scale.
Defaults to 0.0.
max_time (float, optional): The maximum allowed computation time (s) for the algorithm.
Defaults to 1000.
Returns:
None
C++ function:
void solve(const std::string& dataset_path, size_t max_rank = 10, double tol = 1e-6, double lam = 0.0, double max_time = 1000)
"""
# full XM
XM.solve("./assets/SIMPLE1/",3,1e-16,0.0,1000)