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

Default value of max_iter_eig setting for convexify too low #2973

Closed
victorfors opened this issue Nov 7, 2022 · 1 comment · May be fixed by #3177
Closed

Default value of max_iter_eig setting for convexify too low #2973

victorfors opened this issue Nov 7, 2022 · 1 comment · May be fixed by #3177

Comments

@victorfors
Copy link
Contributor

Been trying out the sqpmethod solver and had problems with it crashing. Assumed it to be just because it is not very stable. In implementing my own sqp type method I experienced the same problem after making use of the casadi function convexify and tracked it down to there not being enough iterations when computing eigenvalues in casadi_cvx_symm_schur, solving the problem by setting max_iter_eig to a very large number (100000).

I don't see a good reason why the default value for max_iter_eig is 200, it seems more desirable that the method takes a bit longer rather than it failing. Most of the time it converges in much fever iterations but when running an MPC problem I find that there are a few outliers.

terminate called after throwing an instance of 'casadi::CasadiException'
what(): .../casadi/core/convexify.cpp:67: Assertion "!ret" failed:
Failure in convexification.

@victorfors
Copy link
Contributor Author

victorfors commented May 9, 2023

Here is an example where a lot of iterations are required.

  def test_convexify_hard(self):
    A = DM([
      [ 0.092217,  0.001860, -0.003761, -0.003143, -0.002274,  0.000225, -0.000098,  0.000173],
      [ 0.001860,  0.000269, -0.000110, -0.000100, -0.000069,  0.000003, -0.000001,  0.000002],
      [-0.003761, -0.000110,  0.000123,  0.000037,  0.002089, -0.000011,  0.000005, -0.000008],
      [-0.003143, -0.000100,  0.000037,  0.000093, -0.000138,  0.000053,  0.000007, -0.000016],
      [-0.002274, -0.000069,  0.002089, -0.000138, -0.000252, -0.016051,  0.000459, -0.001413],
      [ 0.000225,  0.000003, -0.000011,  0.000053, -0.016051,  0.001170,  0.000105, -0.000325],
      [-0.000098, -0.000001,  0.000005,  0.000007,  0.000459,  0.000105, -0.000068,  0.000417],
      [ 0.000173,  0.000002, -0.000008, -0.000016, -0.001413, -0.000325,  0.000417, -0.000035]
    ])
    [D,V] = np.linalg.eig(np.array(A))
    Dr= fmax(abs(D),1e-7)
    Ar_ref = mtimes(mtimes(V,diag(Dr)),V.T)


    Ar = evalf(convexify(A,{"strategy":"eigen-reflect","max_iter_eig":1e4})) # Fail
    Ar = evalf(convexify(A,{"strategy":"eigen-reflect","max_iter_eig":1e5})) # Success

    self.checkarray(Ar,Ar_ref,digits=8)

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

Successfully merging a pull request may close this issue.

1 participant