dynamicslab / pysindy

A package for the sparse identification of nonlinear dynamical systems from data
https://pysindy.readthedocs.io/en/latest/
Other
1.42k stars 315 forks source link

[BUG] SCS solver failures on Ubuntu Linux 20.04 #176

Closed Jacob-Stevens-Haas closed 1 year ago

Jacob-Stevens-Haas commented 2 years ago

:wave: Cloned the repo, installed all requirements and dev requirements, and had 12 failures: all 4 parameter sets in test_optimizers.test_trapping_inequality_constraints and all 8 parameter sets with trapping_sr3_params2 in test_trapping_sr3_quadratic_library.

Reproducing code example:

pytest test --cov=pysindy

Error message:

results, redundant tests removed to fit gh comment limit ``` =========================================================================================== test session starts =========================================================================================== platform linux -- Python 3.8.10, pytest-5.4.3, py-1.11.0, pluggy-0.13.1 rootdir: /home/xenophon/github/pysindy plugins: lazy-fixture-0.6.3, cov-3.0.0, hypothesis-6.46.3 collected 556 items test/test_pysindy.py ................................................................................... [ 14%] test/test_sindyc.py .............................................. [ 23%] test/deeptime/test_scikit_time.py ....... [ 24%] test/differentiation/test_differentiation_methods.py ................................................ [ 33%] test/feature_library/test_feature_library.py ............................................................................................................................... [ 55%] test/optimizers/test_optimizers.py ................................................................................................F..F..F..F..F..F..F..F.......................................... [ 84%] ........................FFFF............................. [ 94%] test/property_tests/test_optimizers_complexity.py ..... [ 95%] test/utils/test_odes.py ..................... [ 99%] test/utils/test_utils.py .. [100%] ================================================================================================ FAILURES ================================================================================================= ____________________________________________________________________ test_trapping_sr3_quadratic_library[params7-trapping_sr3_params2] ____________________________________________________________________ params = {'accel': True, 'constraint_lhs': array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., ...., 0., 0., 0., 0., 0.]]), 'constraint_rhs': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'relax_optim': False, ...} trapping_sr3_params = {'relax_optim': False}, data_quadratic_library = @pytest.mark.parametrize( "trapping_sr3_params", [ dict(), dict(accel=True), dict(relax_optim=False), ], ) @pytest.mark.parametrize( "params", [ dict(thresholder="l1", threshold=0), dict(thresholder="l1", threshold=1e-5), dict( thresholder="weighted_l1", thresholds=np.zeros((3, 9)), eta=1e5, alpha_m=1e4, alpha_A=1e5, ), dict(thresholder="weighted_l1", thresholds=1e-5 * np.ones((3, 9))), dict(thresholder="l2", threshold=0), dict(thresholder="l2", threshold=1e-5), dict(thresholder="weighted_l2", thresholds=np.zeros((3, 9))), dict(thresholder="weighted_l2", thresholds=1e-5 * np.ones((3, 9))), ], ) def test_trapping_sr3_quadratic_library( params, trapping_sr3_params, data_quadratic_library ): np.random.seed(100) x = np.random.standard_normal((100, 3)) sindy_library = data_quadratic_library params.update(trapping_sr3_params) opt = TrappingSR3(**params) model = SINDy(optimizer=opt, feature_library=sindy_library) > model.fit(x) test/optimizers/test_optimizers.py:448: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pysindy/pysindy.py:563: in fit self.model.fit(x, x_dot) env/lib/python3.8/site-packages/sklearn/pipeline.py:394: in fit self._final_estimator.fit(Xt, y, **fit_params_last_step) pysindy/optimizers/sindy_optimizer.py:58: in fit self.optimizer.fit(x, y) pysindy/optimizers/base.py:170: in fit self._reduce(x_normed, y, **reduce_kws) pysindy/optimizers/trapping_sr3.py:775: in _reduce m, coef_sparse = self._solve_direct_cvxpy( pysindy/optimizers/trapping_sr3.py:675: in _solve_direct_cvxpy prob_m.solve(eps=self.eps_solver, verbose=self.verbose_cvxpy) env/lib/python3.8/site-packages/cvxpy/problems/problem.py:481: in solve return solve_func(self, *args, **kwargs) env/lib/python3.8/site-packages/cvxpy/problems/problem.py:1016: in _solve self.unpack_results(solution, solving_chain, inverse_data) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Problem(Minimize(Expression(CONVEX, UNKNOWN, ())), []) solution = Solution(solver_error, {}, {}, {'solve_time': nan, 'setup_time': 0.034622, 'num_iters': -1, 'solver_specific_stats': {...ap': nan, 'resInfeas': 0.0, 'resUnbdd': 4.669434e-317, 'solveTime': nan, 'setupTime': 0.034622, 'status': 'Failure'}}}) chain = Chain(reductions=[, , ]) inverse_data = [, (), None: """Updates the problem state given the solver results. Updates problem.status, problem.value and value of primal and dual variables. Arguments _________ solution : object The solution returned by applying the chain to the problem and invoking the solver on the resulting data. chain : SolvingChain A solving chain that was used to solve the problem. inverse_data : list The inverse data returned by applying the chain to the problem. Raises ------ cvxpy.error.SolverError If the solver failed """ solution = chain.invert(solution, inverse_data) if solution.status in s.INACCURATE: warnings.warn( "Solution may be inaccurate. Try another solver, " "adjusting the solver settings, or solve with " "verbose=True for more information." ) if solution.status == s.INFEASIBLE_OR_UNBOUNDED: warnings.warn(INF_OR_UNB_MESSAGE) if solution.status in s.ERROR: > raise error.SolverError( "Solver '%s' failed. " % chain.solver.name() + "Try another solver, or solve with verbose=True for more " "information.") E cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=True for more information. env/lib/python3.8/site-packages/cvxpy/problems/problem.py:1341: SolverError ------------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------------- FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries Install blas+lapack and re-compile SCS with blas+lapack library locations ERROR: init_cone failure Failure:could not initialize work Solver failed, setting coefs to zeros WARN: A->p (column pointers) not strictly increasing, column 1 empty WARN: A->p (column pointers) not strictly increasing, column 2 empty WARN: A->p (column pointers) not strictly increasing, column 3 empty FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries Install blas+lapack and re-compile SCS with blas+lapack library locations ERROR: init_cone failure Failure:could not initialize work ______________________________________________________________________________ test_trapping_inequality_constraints[params0] ______________________________________________________________________________ data_lorenz = (array([[ 8.00000000e+00, 2.70000000e+01, -7.00000000e+00], [ 9.94129602e+00, 2.97388584e+01, -4.29829028e+00...4, 4.91983968, 4.92985972, 4.93987976, 4.9498998 , 4.95991984, 4.96993988, 4.97995992, 4.98997996, 5. ])) params = {'threshold': 0.0005, 'thresholder': 'l1'} @pytest.mark.parametrize( "params", [ dict(thresholder="l1", threshold=0.0005), dict(thresholder="weighted_l1", thresholds=0.0005 * np.ones((3, 10))), dict(thresholder="l2", threshold=0.0005), dict(thresholder="weighted_l2", thresholds=0.0005 * np.ones((3, 10))), ], ) def test_trapping_inequality_constraints(data_lorenz, params): x, t = data_lorenz constraint_rhs = np.array([-10.0, 28.0]) constraint_matrix = np.zeros((2, 30)) constraint_matrix[0, 1] = 1.0 constraint_matrix[1, 11] = 1.0 feature_names = ["x", "y", "z"] # Run Trapping SR3 without CVXPY for the m solve opt = TrappingSR3( constraint_lhs=constraint_matrix, constraint_rhs=constraint_rhs, constraint_order="feature", inequality_constraints=True, relax_optim=True, **params, ) poly_lib = PolynomialLibrary(degree=2) model = SINDy( optimizer=opt, feature_library=poly_lib, feature_names=feature_names, ) model.fit(x, t=t[1] - t[0]) # This sometimes fails with L2 norm so just check the model is fitted check_is_fitted(model) # Run Trapping SR3 with CVXPY for the m solve opt = TrappingSR3( constraint_lhs=constraint_matrix, constraint_rhs=constraint_rhs, constraint_order="feature", inequality_constraints=True, relax_optim=False, **params, ) model = SINDy( optimizer=opt, feature_library=poly_lib, differentiation_method=FiniteDifference(drop_endpoints=True), feature_names=feature_names, ) model.fit(x, t=t[1] - t[0]) > assert np.all( np.dot(constraint_matrix, (model.coefficients()).flatten()) <= constraint_rhs ) or np.allclose( np.dot(constraint_matrix, (model.coefficients()).flatten()), constraint_rhs, atol=1e-3, ) E assert (False or False) E + where False = (array([0., 0.]) <= array([-10., 28.])) E + where = np.all E + and array([0., 0.]) = (array([[0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0...., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])) E + where = np.dot E + and array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) = () E + where = array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]).flatten E + where array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]) = () E + where = SINDy(differentiation_method=FiniteDifference(drop_endpoints=True),\n feature_library=PolynomialLibrary(), feature... 8560333.65160063],\n relax_optim=False, threshold=0.0005)).coefficients E + and False = (array([0., 0.]), array([-10., 28.]), atol=0.001) E + where = np.allclose E + and array([0., 0.]) = (array([[0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0...., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])) E + where = np.dot E + and array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) = () E + where = array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]).flatten E + where array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]) = () E + where = SINDy(differentiation_method=FiniteDifference(drop_endpoints=True),\n feature_library=PolynomialLibrary(), feature... 8560333.65160063],\n relax_optim=False, threshold=0.0005)).coefficients test/optimizers/test_optimizers.py:869: AssertionError ------------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------------- The feature library is the wrong shape or not quadratic, so please correct this if you are attempting to use the trapping algorithm with the stability term included. Setting PL and PQ tensors to zeros for now. The feature library is the wrong shape or not quadratic, so please correct this if you are attempting to use the trapping algorithm with the stability term included. Setting PL and PQ tensors to zeros for now. FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries Install blas+lapack and re-compile SCS with blas+lapack library locations ERROR: init_cone failure Failure:could not initialize work Solver failed, setting coefs to zeros FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries Install blas+lapack and re-compile SCS with blas+lapack library locations ERROR: init_cone failure Failure:could not initialize work Solver failed, setting coefs to zeros ============================================================================================ warnings summary ============================================================================================= pysindy/optimizers/trapping_sr3.py:262: 1 test with warning test/optimizers/test_optimizers.py: 67 tests with warnings /home/xenophon/github/pysindy/pysindy/optimizers/trapping_sr3.py:262: UserWarning: eta was not set, so defaulting to eta = 1e20 with alpha_m = 1e-2 * eta, alpha_A = eta. Here eta is so large that the stability term in the optimization will be ignored. warnings.warn( test/test_pysindy.py: 33 tests with warnings test/test_sindyc.py: 3 tests with warnings test/deeptime/test_scikit_time.py: 1 test with warning test/optimizers/test_optimizers.py: 3 tests with warnings /home/xenophon/github/pysindy/pysindy/optimizers/stlsq.py:183: UserWarning: Sparsity parameter is too big (0.1) and eliminated all coefficients warnings.warn( test/test_pysindy.py::test_mixed_inputs[data_lorenz] test/test_pysindy.py::test_mixed_inputs[data_lorenz] test/test_pysindy.py::test_fit_multiple_trajectores test/test_sindyc.py::test_mixed_inputs[data_lorenz_c_1d] test/test_sindyc.py::test_mixed_inputs[data_lorenz_c_1d] test/test_sindyc.py::test_mixed_inputs[data_lorenz_c_2d] test/test_sindyc.py::test_mixed_inputs[data_lorenz_c_2d] /home/xenophon/github/pysindy/pysindy/optimizers/stlsq.py:193: UserWarning: Sparsity parameter is too big (0.1) and eliminated all coefficients warnings.warn( test/test_pysindy.py::test_integration_derivative_methods[derivative_kws3] /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/sklearn/linear_model/_coordinate_descent.py:647: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations, check the scale of the features or consider increasing regularisation. Duality gap: 3.933e+03, tolerance: 4.306e+00 model = cd_fast.enet_coordinate_descent( test/test_pysindy.py::test_integration_derivative_methods[derivative_kws3] /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/sklearn/linear_model/_coordinate_descent.py:647: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations, check the scale of the features or consider increasing regularisation. Duality gap: 7.507e+03, tolerance: 1.563e+01 model = cd_fast.enet_coordinate_descent( test/test_pysindy.py::test_integration_derivative_methods[derivative_kws3] /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/sklearn/linear_model/_coordinate_descent.py:647: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations, check the scale of the features or consider increasing regularisation. Duality gap: 1.197e+04, tolerance: 1.920e+01 model = cd_fast.enet_coordinate_descent( test/test_pysindy.py::test_predict_multiple_trajectories test/test_pysindy.py::test_score_multiple_trajectories /home/xenophon/github/pysindy/pysindy/pysindy.py:642: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. x_shape = np.array(np.array(x).shape) test/test_sindyc.py::test_simulate_with_vector_control_input[data_lorenz_c_1d] test/test_sindyc.py::test_simulate_with_vector_control_input[data_lorenz_c_2d] /home/xenophon/github/pysindy/pysindy/pysindy.py:1194: UserWarning: Last time point dropped in simulation because interpolation of control input was used. To avoid this, pass in a callable for u. warnings.warn( test/test_sindyc.py::test_predict_multiple_trajectories test/test_sindyc.py::test_score_multiple_trajectories /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/numpy/core/fromnumeric.py:2007: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. result = asarray(a).shape test/differentiation/test_differentiation_methods.py::test_wrapper_equivalence_with_dxdt[data_derivative_1d-derivative_kws8] test/differentiation/test_differentiation_methods.py::test_wrapper_equivalence_with_dxdt[data_derivative_1d-derivative_kws8] test/differentiation/test_differentiation_methods.py::test_wrapper_equivalence_with_dxdt[data_derivative_2d-derivative_kws9] test/differentiation/test_differentiation_methods.py::test_wrapper_equivalence_with_dxdt[data_derivative_2d-derivative_kws9] test/differentiation/test_differentiation_methods.py::test_derivative_output_shape[data_derivative_1d-derivative_kws8] test/differentiation/test_differentiation_methods.py::test_derivative_output_shape[data_derivative_1d-derivative_kws8] test/differentiation/test_differentiation_methods.py::test_derivative_output_shape[data_derivative_2d-derivative_kws9] test/differentiation/test_differentiation_methods.py::test_derivative_output_shape[data_derivative_2d-derivative_kws9] /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/numpy/polynomial/polynomial.py:1362: RankWarning: The fit may be poorly conditioned return pu._fit(polyvander, x, y, deg, rcond, full, w) test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/sklearn/linear_model/_ridge.py:157: LinAlgWarning: Ill-conditioned matrix (rcond=1.48221e-55): result may not be accurate. return linalg.solve(A, Xy, sym_pos=True, overwrite_a=True).T test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library_pde /home/xenophon/github/pysindy/pysindy/optimizers/stlsq.py:183: UserWarning: Sparsity parameter is too big (0.25) and eliminated all coefficients warnings.warn( test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library test/feature_library/test_feature_library.py::test_generalized_library /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/sklearn/linear_model/_ridge.py:157: LinAlgWarning: Ill-conditioned matrix (rcond=4.12949e-31): result may not be accurate. return linalg.solve(A, Xy, sym_pos=True, overwrite_a=True).T test/feature_library/test_feature_library.py::test_sindypi_library test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params5-trapping_sr3_params0] test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params5-trapping_sr3_params0] test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params5-trapping_sr3_params1] test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params5-trapping_sr3_params1] test/optimizers/test_optimizers.py::test_constrained_inequality_constraints[params2] test/optimizers/test_optimizers.py::test_trapping_inequality_constraints[params2] /home/xenophon/github/pysindy/env/lib/python3.8/site-packages/cvxpy/problems/problem.py:1333: UserWarning: Solution may be inaccurate. Try another solver, adjusting the solver settings, or solve with verbose=True for more information. warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 17, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 18, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 19, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 20, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 21, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 24, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 25, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 26, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 27, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 28, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 29, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 30, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 34, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 35, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 36, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 37, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 38, try changing your library warnings.warn( test/feature_library/test_feature_library.py::test_sindypi_library /home/xenophon/github/pysindy/pysindy/optimizers/sindy_pi.py:201: ConvergenceWarning: Infeasible solve on iteration 39, try changing your library warnings.warn( test/optimizers/test_optimizers.py: 32 tests with warnings /home/xenophon/github/pysindy/pysindy/optimizers/trapping_sr3.py:813: ConvergenceWarning: TrappingSR3._reduce did not converge after 30 iters. warnings.warn( test/optimizers/test_optimizers.py::test_initial_guess_sr3[SR3] test/optimizers/test_optimizers.py::test_initial_guess_sr3[SR3] /home/xenophon/github/pysindy/pysindy/optimizers/sr3.py:388: ConvergenceWarning: SR3._reduce did not converge after 1 iterations. warnings.warn( test/optimizers/test_optimizers.py::test_initial_guess_sr3[ConstrainedSR3] test/optimizers/test_optimizers.py::test_initial_guess_sr3[ConstrainedSR3] /home/xenophon/github/pysindy/pysindy/optimizers/constrained_sr3.py:428: ConvergenceWarning: SR3._reduce did not converge after 1 iterations. warnings.warn( test/optimizers/test_optimizers.py: 18 tests with warnings /home/xenophon/github/pysindy/pysindy/optimizers/sr3.py:388: ConvergenceWarning: SR3._reduce did not converge after 30 iterations. warnings.warn( test/optimizers/test_optimizers.py: 13 tests with warnings /home/xenophon/github/pysindy/pysindy/optimizers/constrained_sr3.py:428: ConvergenceWarning: SR3._reduce did not converge after 30 iterations. warnings.warn( -- Docs: https://docs.pytest.org/en/latest/warnings.html ---------- coverage: platform linux, python 3.8.10-final-0 ----------- Coverage XML written to file coverage.xml ========================================================================================= short test summary info ========================================================================================= FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params0-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params1-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params2-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params3-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params4-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params5-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params6-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_sr3_quadratic_library[params7-trapping_sr3_params2] - cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=T... FAILED test/optimizers/test_optimizers.py::test_trapping_inequality_constraints[params0] - assert (False or False) FAILED test/optimizers/test_optimizers.py::test_trapping_inequality_constraints[params1] - assert (False or False) FAILED test/optimizers/test_optimizers.py::test_trapping_inequality_constraints[params2] - AssertionError: assert (False or False) FAILED test/optimizers/test_optimizers.py::test_trapping_inequality_constraints[params3] - assert (False or False) ======================================================================== 12 failed, 544 passed, 239 warnings in 198.74s (0:03:18) ========================================================================= ```

PySINDy/Python version information:

pysindy: 1.8.dev1+g288cf6e.d20220511 (current master) python:

3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0]
Jacob-Stevens-Haas commented 2 years ago

It appears that after installing libatlas-base-dev and gfortran and reinstalling numpy and scs, the tests pass.

Jacob-Stevens-Haas commented 1 year ago

This time round, it didn't seem to work. This time it's all cvxpy.error.SolverERror: Solver 'SCS' failed. @akaptano, do you recall any issue with this, since they're trapping SINDy tests?

Error message ```python ./test/optimizers/test_optimizers.py::test_trapping_inequality_constraints[params0] Failed: [undefined]cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=True for more information. data_lorenz = (array([[ 8.00000000e+00, 2.70000000e+01, -7.00000000e+00], [ 9.94129602e+00, 2.97388584e+01, -4.29829028e+00...4, 4.91983968, 4.92985972, 4.93987976, 4.9498998 , 4.95991984, 4.96993988, 4.97995992, 4.98997996, 5. ])) params = {'threshold': 0.0005, 'thresholder': 'l1'} @pytest.mark.parametrize( "params", [ dict(thresholder="l1", threshold=0.0005), dict(thresholder="weighted_l1", thresholds=0.0005 * np.ones((3, 9))), dict(thresholder="l2", threshold=0.0005), dict(thresholder="weighted_l2", thresholds=0.0005 * np.ones((3, 9))), ], ) def test_trapping_inequality_constraints(data_lorenz, params): x, t = data_lorenz constraint_rhs = np.array([-10.0, 28.0]) constraint_matrix = np.zeros((2, 27)) constraint_matrix[0, 0] = 1.0 constraint_matrix[1, 10] = 1.0 feature_names = ["x", "y", "z"] # Run Trapping SR3 without CVXPY for the m solve opt = TrappingSR3( constraint_lhs=constraint_matrix, constraint_rhs=constraint_rhs, constraint_order="feature", inequality_constraints=True, relax_optim=True, **params, ) poly_lib = PolynomialLibrary(degree=2, include_bias=False) model = SINDy( optimizer=opt, feature_library=poly_lib, feature_names=feature_names, ) model.fit(x, t=t[1] - t[0]) # This sometimes fails with L2 norm so just check the model is fitted check_is_fitted(model) # Run Trapping SR3 with CVXPY for the m solve opt = TrappingSR3( constraint_lhs=constraint_matrix, constraint_rhs=constraint_rhs, constraint_order="feature", inequality_constraints=True, relax_optim=False, **params, ) model = SINDy( optimizer=opt, feature_library=poly_lib, differentiation_method=FiniteDifference(drop_endpoints=True), feature_names=feature_names, ) > model.fit(x, t=t[1] - t[0]) test/optimizers/test_optimizers.py:939: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pysindy/pysindy.py:414: in fit self.model.fit(x, x_dot) env/lib/python3.10/site-packages/sklearn/pipeline.py:394: in fit self._final_estimator.fit(Xt, y, **fit_params_last_step) pysindy/optimizers/sindy_optimizer.py:60: in fit self.optimizer.fit(x, y) pysindy/optimizers/base.py:178: in fit self._reduce(x_normed, y, **reduce_kws) pysindy/optimizers/trapping_sr3.py:770: in _reduce m, coef_sparse = self._solve_direct_cvxpy( pysindy/optimizers/trapping_sr3.py:670: in _solve_direct_cvxpy prob_m.solve(eps=self.eps_solver, verbose=self.verbose_cvxpy) env/lib/python3.10/site-packages/cvxpy/problems/problem.py:493: in solve return solve_func(self, *args, **kwargs) env/lib/python3.10/site-packages/cvxpy/problems/problem.py:1068: in _solve self.unpack_results(solution, solving_chain, inverse_data) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Problem(Minimize(Expression(CONVEX, UNKNOWN, ())), []) solution = Solution(solver_error, {}, {}, {'solve_time': nan, 'setup_time': 3.1417e-05, 'num_iters': -1, 'solver_specific_stats':....6450267309294e-310, 'resUnbdd': 4.6450271622226e-310, 'solveTime': nan, 'setupTime': 0.031417, 'status': 'Failure'}}}) chain = Chain(reductions=[, , ]) inverse_data = [, (), None: """Updates the problem state given the solver results. Updates problem.status, problem.value and value of primal and dual variables. Arguments _________ solution : object The solution returned by applying the chain to the problem and invoking the solver on the resulting data. chain : SolvingChain A solving chain that was used to solve the problem. inverse_data : list The inverse data returned by applying the chain to the problem. Raises ------ cvxpy.error.SolverError If the solver failed """ solution = chain.invert(solution, inverse_data) if solution.status in s.INACCURATE: warnings.warn( "Solution may be inaccurate. Try another solver, " "adjusting the solver settings, or solve with " "verbose=True for more information." ) if solution.status == s.INFEASIBLE_OR_UNBOUNDED: warnings.warn(INF_OR_UNB_MESSAGE) if solution.status in s.ERROR: > raise error.SolverError( "Solver '%s' failed. " % chain.solver.name() + "Try another solver, or solve with verbose=True for more " "information.") E cvxpy.error.SolverError: Solver 'SCS' failed. Try another solver, or solve with verbose=True for more information. env/lib/python3.10/site-packages/cvxpy/problems/problem.py:1393: SolverError

In the interim, I'll head back to the cvxpy help.

Jacob-Stevens-Haas commented 1 year ago

Ok so I believe the issue was that 9ca0cc1 limited scs to <=2.1.4 in response to #137, but should have been <2.1.4 since that issue was with 2.1.4 itself (the most recent version at the time). It hasn't really been noticed since, because the requirement is only requirements-dev.txt and not requirements.txt. Verified that tests pass on 2.1.3, 3.0.0, and 3.2.3 (current version). I'll push a PR with updated requirement specifier.

pls lemme know though, @akaptano or @znicolaou, either here or in review, whether there's a reason for this to be a dev requirement but not a regular requirement.

akaptano commented 1 year ago

Yes, cvxpy was moved to a dev requirement a while back, since it is only used for somewhat specialized optimization cases (inequality constraints with ConstrainedSR3 and the trappingSR3 optimizer). scs is used by cvxpy, so it too was but into the dev requirements, and other users were also running into issues (although maybe solved by your fixing the versioning above).