From ff30661ddb31584d51e6b0029c4ddc36935edb6e Mon Sep 17 00:00:00 2001 From: Mai Peng Date: Mon, 1 Apr 2024 17:26:57 -0700 Subject: [PATCH] added switch to control the bias term in making constraints --- examples/8_trapping_sindy_examples/trapping_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/8_trapping_sindy_examples/trapping_utils.py b/examples/8_trapping_sindy_examples/trapping_utils.py index 1b2cb6b1b..520881e3e 100644 --- a/examples/8_trapping_sindy_examples/trapping_utils.py +++ b/examples/8_trapping_sindy_examples/trapping_utils.py @@ -54,9 +54,11 @@ def obj_function(m, L_obj, Q_obj, P_obj): # Define some setup and plotting functions # Build the skew-symmetric nonlinearity constraints -def make_constraints(r): +def make_constraints(r, include_bias=True): q = 0 - N = int((r**2 + 3 * r) / 2.0) + 1 # + 1 for constant term + N = int((r**2 + 3 * r) / 2.0) + if include_bias is True: + N = N + 1 # + 1 for constant term p = r + r * (r - 1) + int(r * (r - 1) * (r - 2) / 6.0) constraint_zeros = np.zeros(p) constraint_matrix = np.zeros((p, r * N))