build(deps): update cvxpy version from 1.5.3 to 1.6.5 in requirements (#1203)

* build(deps): update cvxpy version from 1.5.3 to 1.6.5 in requirements

* Add ECOS solver and improve solver handling for stability

Added ECOS to requirements and enhanced compatibility with cvxpy solvers by specifying 'order' for matrix reshaping. Updated solver configurations in rocket landing and pendulum control for consistency and reliability. Improved test behavior by enforcing stricter warning handling in pytest.
This commit is contained in:
Atsushi Sakai
2025-05-01 13:08:29 +09:00
committed by GitHub
parent f466f25f53
commit af0442d358
4 changed files with 9 additions and 7 deletions

View File

@@ -31,6 +31,7 @@ W_DELTA = 1e-3 # difference in state/input
W_DELTA_SIGMA = 1e-1 # difference in flight time
W_NU = 1e5 # virtual control
print(cvxpy.installed_solvers())
solver = 'ECOS'
verbose_solver = False
@@ -462,11 +463,11 @@ class SCProblem:
# x_t+1 = A_*x_t+B_*U_t+C_*U_T+1*S_*sigma+zbar+nu
constraints += [
self.var['X'][:, k + 1] ==
cvxpy.reshape(self.par['A_bar'][:, k], (m.n_x, m.n_x)) @
cvxpy.reshape(self.par['A_bar'][:, k], (m.n_x, m.n_x), order='F') @
self.var['X'][:, k] +
cvxpy.reshape(self.par['B_bar'][:, k], (m.n_x, m.n_u)) @
cvxpy.reshape(self.par['B_bar'][:, k], (m.n_x, m.n_u), order='F') @
self.var['U'][:, k] +
cvxpy.reshape(self.par['C_bar'][:, k], (m.n_x, m.n_u)) @
cvxpy.reshape(self.par['C_bar'][:, k], (m.n_x, m.n_u), order='F') @
self.var['U'][:, k + 1] +
self.par['S_bar'][:, k] * self.var['sigma'] +
self.par['z_bar'][:, k] +
@@ -536,7 +537,7 @@ class SCProblem:
with warnings.catch_warnings(): # For User warning from solver
warnings.simplefilter('ignore')
self.prob.solve(verbose=verbose_solver,
solver=solver)
solver=solver)
except cvxpy.SolverError:
error = True

View File

@@ -91,7 +91,7 @@ def mpc_control(x0):
prob = cvxpy.Problem(cvxpy.Minimize(cost), constr)
start = time.time()
prob.solve(verbose=False)
prob.solve(verbose=False, solver=cvxpy.CLARABEL)
elapsed_time = time.time() - start
print(f"calc time:{elapsed_time:.6f} [sec]")

View File

@@ -1,7 +1,8 @@
numpy == 2.2.4
scipy == 1.15.2
matplotlib == 3.10.1
cvxpy == 1.5.3
cvxpy == 1.6.5
ecos == 2.0.14
pytest == 8.3.5 # For unit test
pytest-xdist == 3.6.1 # For unit test
mypy == 1.15.0 # For unit test

View File

@@ -10,4 +10,4 @@ sys.path.append(ROOT_DIR)
def run_this_test(file):
pytest.main([os.path.abspath(file)])
pytest.main(args=["-W", "error", "-Werror", "--pythonwarnings=error", os.path.abspath(file)])