-
Notifications
You must be signed in to change notification settings - Fork 121
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
add more tests, in particular for dual variables, cf. #290 #332
Conversation
These look great! I'll review them more carefully in the next couple days and then merge if it all seems ok. Thanks very much. (Same goes for the other PR). One question: why the minimal norm tests? Just to test something more, or is it related to duality? |
I added the minimal norm tests because I was interested in some similar problems. Then I wanted to test additionally the dual variables for these problems but got different results for different solvers (SCS, ECOS). Strangely, cvx in matlab gave consistent results for different solvers (gurobi, mosek, sedumi and the other free one I don't remember now). Since I didn't have enough time to work out the dual variables by hand, I pushed them without tests of dual variables. But I calculated the optimal values and solutions by hand. |
Ok, interesting. My understanding is that in general they are not unique, but the optimal primal and dual variables should together satisfy the KTT conditions (see e.g. Section 5.5.3 of Boyd and Vandenberghe's book https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf). The KTT conditions require a differentiable problem, but I think Convex is rewriting these norms into a formulation that is differentiable anyway. So maybe for these problems the dual solutions are not unique? It looks like Slater's condition holds, since there is a feasible point, namely |
How can I get the dual objective function in Convex.jl? |
I was thinking we'd have to do so analytically; Convex itself does not provide such a method. However, there was a GsoC project this summer to do so at the level of MOI: https://github.com/JuliaOpt/Dualization.jl. So maybe with #330 this could be incorporated into Convex somehow. |
(Adding dual tests to those minimal norm problems could be a separate PR though) |
I've added the tests of the dual objective function value. Indeed, the dual variable is not unique. In that case, it is a bit strange that all solvers of cvx in matlab I've tested return the same dual variable... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! Thanks very much for contributing these tests. I did not check all the dual values (though I checked a couple), so I'll trust you on those :).
I think this is good to merge once line 26 of test_lp.jl
is fixed or removed.
test/test_lp.jl
Outdated
@test p.constraints[2].dual ≈ 1 atol=TOL | ||
@test p.constraints[3].dual[1,1] ≈ 0 atol=TOL | ||
@test p.constraints[3].dual[2,2] ≈ 0 atol=TOL | ||
@test p.constraints[3].dual[1,2] ≈ p.constraints[3].dual[1,2] atol=TOL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line doesn't seem to test anything; was it supposed to test something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I've fixed the typo.
Thanks very much! |
I've checked the dual variables either analytically or via cvx (and different solvers) in matlab.