diff --git a/_scripts/run_other_study.py b/_scripts/run_other_study.py index 7d6d5d7..f70099b 100644 --- a/_scripts/run_other_study.py +++ b/_scripts/run_other_study.py @@ -13,7 +13,8 @@ DEBUG = False RESULTS_DIR = "_results" -#RESULTS_DIR = "_results_server" +# RESULTS_DIR = "_results_server" + def lifter_tightness( Lifter=MonoLifter, robust: bool = False, d: int = 2, n_landmarks=4, n_outliers=0 diff --git a/examples/robust_lifter.py b/examples/robust_lifter.py index 046a51f..64826da 100644 --- a/examples/robust_lifter.py +++ b/examples/robust_lifter.py @@ -13,13 +13,20 @@ def get_problem(robust=True): # Create lifter np.random.seed(0) n_landmarks = 4 - d= 3 + d = 3 if robust: n_outliers = 1 else: n_outliers = 0 - lifter = Lifter(d=d, n_landmarks=n_landmarks+n_outliers, robust=robust, n_outliers=n_outliers, level=level, variable_list=None) + lifter = Lifter( + d=d, + n_landmarks=n_landmarks + n_outliers, + robust=robust, + n_outliers=n_outliers, + level=level, + variable_list=None, + ) Q, y = lifter.get_Q() from auto_template.learner import Learner @@ -71,4 +78,4 @@ def plot_problem(prob, lifter, fname=""): prob, lifter = get_problem(robust=robust) fname = f"certifiable-tools/_examples/test_prob_{number}G.pkl" save_test_problem(**prob, fname=fname) - #plot_problem(prob, lifter, fname=fname.replace(".pkl", ".png")) \ No newline at end of file + # plot_problem(prob, lifter, fname=fname.replace(".pkl", ".png")) diff --git a/lifters/state_lifter.py b/lifters/state_lifter.py index 6403ade..94fb1d9 100644 --- a/lifters/state_lifter.py +++ b/lifters/state_lifter.py @@ -4,11 +4,11 @@ import numpy as np import scipy.sparse as sp from cert_tools.linalg_tools import get_nullspace - from lifters.base_class import BaseClass -from poly_matrix import PolyMatrix, unroll from utils.common import upper_triangular +from poly_matrix import PolyMatrix, unroll + def ravel_multi_index_triu(index_tuple, shape): """Equivalent of np.multi_index_triu, but using only the upper-triangular part of matrix.""" diff --git a/lifters/stereo_lifter.py b/lifters/stereo_lifter.py index 8048e9d..906190d 100644 --- a/lifters/stereo_lifter.py +++ b/lifters/stereo_lifter.py @@ -50,8 +50,8 @@ class StereoLifter(StateLifter, ABC): ["h", "x"], ["h", "z_0"], ["h", "x", "z_0"], - ["h", "z_0", "z_1"], # should achieve tightness here - # ["h", "x", "z_0", "z_1"], + ["h", "z_0", "z_1"], # should achieve tightness here + # ["h", "x", "z_0", "z_1"], # ["h", "z_0", "z_1", "z_2"], ] diff --git a/lifters/wahba_lifter.py b/lifters/wahba_lifter.py index 71e27e9..470ba36 100644 --- a/lifters/wahba_lifter.py +++ b/lifters/wahba_lifter.py @@ -83,17 +83,17 @@ def get_Q(self, noise: float = None): def get_Q_from_y(self, y): """ - every cost term can be written as - (1 + wi)/b^2 r^2(x, zi) + (1 - wi) - - residual term: - (Rpi + t - ui).T Wi (Rpi + t - ui) = - [t', vec(R)'] @ [I (pi x I)]' @ Wi @ [I (pi x I)] @ [t ; vec(R)] - ------x'----- -----Pi'----- - - 2 [t', vec(R)'] @ [I (pi x I)]' Wi @ ui - -----x'------ ---------Pi_xl-------- - + ui.T @ Wi @ ui - -----Pi_ll------ + every cost term can be written as + (1 + wi)/b^2 r^2(x, zi) + (1 - wi) + + residual term: + (Rpi + t - ui).T Wi (Rpi + t - ui) = + [t', vec(R)'] @ [I (pi x I)]' @ Wi @ [I (pi x I)] @ [t ; vec(R)] + ------x'----- -----Pi'----- + - 2 [t', vec(R)'] @ [I (pi x I)]' Wi @ ui + -----x'------ ---------Pi_xl-------- + + ui.T @ Wi @ ui + -----Pi_ll------ """ from poly_matrix.poly_matrix import PolyMatrix @@ -107,9 +107,9 @@ def get_Q_from_y(self, y): ui = y[i] Pi = np.c_[np.eye(self.d), np.kron(pi, np.eye(self.d))] - Pi_ll = ui.T @ Wi @ ui - Pi_xl = -(Pi.T @ Wi @ ui)[:, None] - Qi = Pi.T @ Wi @ Pi + Pi_ll = ui.T @ Wi @ ui + Pi_xl = -(Pi.T @ Wi @ ui)[:, None] + Qi = Pi.T @ Wi @ Pi if NORMALIZE: Pi_ll /= norm Pi_xl /= norm diff --git a/poly_matrix b/poly_matrix index 14ee250..abdd3cb 160000 --- a/poly_matrix +++ b/poly_matrix @@ -1 +1 @@ -Subproject commit 14ee25087e9d46265985825ad5d028c67f3b9491 +Subproject commit abdd3cbaf5fafffb61b7baf661071213dbac3df1 diff --git a/solvers/common.py b/solvers/common.py index 301ce51..f404231 100644 --- a/solvers/common.py +++ b/solvers/common.py @@ -214,7 +214,6 @@ def solve_sdp_cvxpy( return X, info - def solve_sdp_cvxpy_new( Q, A_b_list,