Giter Club home page Giter Club logo

Comments (4)

rienq avatar rienq commented on June 4, 2024

Update: I just tried the latest version (v0.7.1) in Python and I got a similar answer [0.9999668636034095, 3.313639612649994e-05]

P = sparse.csc_matrix([[2., 0.], [0., 4.]])
P = sparse.triu(P).tocsc()

q = np.array([-2., 0.])

A = sparse.csc_matrix(
    [[1., 1.],        # <-- LHS of equality constraint (lower bound)
     [-1.,  0.],       # <-- LHS of inequality constraint (lower bound)
     [0., -1.]])       # <-- LHS of inequality constraint (lower bound)

b = np.array([1., 0., 0.])

cones = [clarabel.ZeroConeT(1), clarabel.NonnegativeConeT(2)]
settings = clarabel.DefaultSettings()

solver = clarabel.DefaultSolver(P, q, A, b, cones, settings)
solution = solver.solve()
print(
    f"Solver terminated with solution"
    f"{dict(s=solution.s, x=solution.x, z=solution.z)}"
)

from clarabel.cpp.

goulart-paul avatar goulart-paul commented on June 4, 2024

I think that the issue is only in the interpretation of the error tolerances.

The primal and dual feasibility tolerances are checked against the residuals of the KKT conditions. In this case when I manually compute the dual residual $||Px + q + A^Tz||$ I get an error with very small inf-norm as expected. Likewise for the primal residual $||Ax + s - b||$. These residuals are what is reported in the solver output dres and pres columns.

The primal objective function at the solution produced by the solver is also really close, i.e. $-1 + (3\times 10^{-9})$, with similar accuracy for the dual objective value (true value is $-1$). The difference between them is reported in the gap column and shows high accuracy.

The error you are computing is the distance between the (approximate) optimizer produced by the solver and the true optimizer. This is not one of the stopping criteria, and indeed really can't be because there is no obvious way to compute this distance when the true optimizer is not known.

Normally you would not expect to get a substantial inaccuracy in the optimizer like that anyway. The reason it happens in this case is because the unconstrained minimizer for the problem happens to be at the boundary of the feasible set. The solution is therefore quite insensitive to small variations around that point, and the solver has produced a solution that is at a nearby point on the boundary with very similar objective value.

Part of the issue is perhaps also one of method. A simplex based solver would be more likely to produce a very high accuracy optimizer for this problem because the true solution is right on a vertex.

A possible fix for this would be for us to implement a "polishing" post-processing step as we did in OSQP. That would only be directly applicable to LP / QP problems, although I am aware that there is at least some work out there on similar polishing methods for problems with other constraint types.

from clarabel.cpp.

rienq avatar rienq commented on June 4, 2024

Thank you so much for the quick response, @goulart-paul !
I agree with everything you said, and I had a suspicion it was related to the fact that the constraint for the second variable is only weakly active. The product of the slack variable and the multiplier is less than 1e-8, but that means that both the slack variable and the Lagrange multiplier are around 1e-4 even though they should both be zero in the optimal solution.
The solution becomes more accurate if I reduce the tolerance value for the duality gap, for example, I get [0.999999968991507, 3.1e-08] for an absolute and relative gap tolerance of 1e-14.
But I guess this could lead to numerical difficulties for other problems.

from clarabel.cpp.

rienq avatar rienq commented on June 4, 2024

Feel free to close this issue. Or you can leave it open if you think that such a "polishing" post-processing step could be implemented also for Clarabel.

from clarabel.cpp.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.