Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestSCIPY.test_scipy_mi_time_limit_reached failed: Solver 'SCIPY' failed. Try another solver ... #2174

Closed
yurivict opened this issue Jul 8, 2023 · 2 comments

Comments

@yurivict
Copy link

yurivict commented Jul 8, 2023

Describe the bug

――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― TestSCIPY.test_scipy_mi_time_limit_reached ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

self = <cvxpy.tests.test_conic_solvers.TestSCIPY testMethod=test_scipy_mi_time_limit_reached>

    @unittest.skipUnless('SCIPY' in INSTALLED_MI_SOLVERS, 'SCIPY version cannot solve MILPs')
    def test_scipy_mi_time_limit_reached(self) -> None:
        sth = sths.mi_lp_7()
    
        # run without enough time to find optimum
>       sth.solve(solver='SCIPY', scipy_options={"time_limit": 0.01})

cvxpy/tests/test_conic_solvers.py:2091: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cvxpy/tests/solver_test_helpers.py:38: in solve
    self.prob.solve(solver=solver, **kwargs)
cvxpy/problems/problem.py:495: in solve
    return solve_func(self, *args, **kwargs)
cvxpy/problems/problem.py:1070: in _solve
    self.unpack_results(solution, solving_chain, inverse_data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = Problem(Maximize(Expression(AFFINE, UNKNOWN, ())), [Inequality(Variable((192,), pos=True)), Inequality(Variable((192,)...(Expression(AFFINE, UNKNOWN, (192,))), Inequality(Variable((192,), pos=True)), Inequality(Variable((192,), pos=True))])
solution = Solution(solver_error, {}, {}, {})
chain = Chain(reductions=[<cvxpy.reductions.flip_objective.FlipObjective object at 0x9ef334d30>, <cvxpy.reductions.dcp2cone.dc...trixStuffing object at 0x9ef34acd0>, <cvxpy.reductions.solvers.conic_solvers.scipy_conif.SCIPY object at 0x959717ee0>])
inverse_data = [[], <cvxpy.reductions.inverse_data.InverseData object at 0x9ef34ae50>, ({20424: Variable((192,)), 20425: Variable((19...,))), Zero(Expression(AFFINE, UNKNOWN, ()))], 'is_mip': [384, 385, 386, 387, 388, 389, ...], 'offset': array(0.), ...}]

    def unpack_results(self, solution, chain: SolvingChain, 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 'SCIPY' failed. Try another solver, or solve with verbose=True for more information.

cvxpy/problems/problem.py:1395: SolverError

To Reproduce
Regular tests.

Version

  • OS: FreeBSD 13.2
  • CVXPY Version: 1.3.2
  • Python: 3.9
@rileyjmurray
Copy link
Collaborator

rileyjmurray commented Jul 11, 2023

This test passes or fails nondeterministically, since it's a matter of how fast the machine runs. I think this has been reported elsewhere. In any case, we need a fix. Setting the time limit to something much smaller (1e-6 instead of 1e-2) might be a practical solution.

@rileyjmurray
Copy link
Collaborator

Resolved in #2249.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants