Skip to content

Commit 7a1f7bb

Browse files
authored
SymPy .subs() bug fixed via dummy variables
Fix substitution bug in dt systems, pull request corrects bug in all places. Thanks Zinoex!
2 parents c70d121 + f6e6a47 commit 7a1f7bb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/functions/dt_DS.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def dt_DS(b_degree, dim, L_initial, U_initial, L_unsafe, U_unsafe, L_space, U_sp
113113
# ========================= Sub Difference Equations =========================
114114

115115
# substitute the result of the difference equations
116-
Barrier_f = Barrier.subs([(x[i], f[i]) for i in range(len(x))])
116+
y = [sp.Dummy(f'y{i}') for i in range(len(x))]
117+
Barrier_f = Barrier.subs([(x[i], y[i]) for i in range(len(x))])
118+
Barrier_f = Barrier_f.subs([(y[i], f[i]) for i in range(len(y))])
117119

118120
# ========================= Constraints =========================
119121
try:

src/functions/dt_SS.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def dt_SS(b_degree, dim, L_initial, U_initial, L_unsafe, U_unsafe, L_space, U_sp
167167
return {"error": "Gamma, Lambda, or c value definition issues","b_degree":b_degree}
168168

169169
# ========================= Sub Difference Equations =========================
170-
BB = Barrier.subs([(x[i], f[i]) for i in range(len(x))])
170+
y = [sp.Dummy(f'y{i}') for i in range(len(x))]
171+
BB = Barrier.subs([(x[i], y[i]) for i in range(len(x))])
172+
BB = BB.subs([(y[i], f[i]) for i in range(len(y))])
171173
BB = sp.expand(BB)
172174

173175
for i in range(len(varsigma)):

0 commit comments

Comments
 (0)