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

Warm Start example does not work as expected #229

Closed
rakeshvar opened this issue Jun 2, 2018 · 1 comment · Fixed by #478
Closed

Warm Start example does not work as expected #229

rakeshvar opened this issue Jun 2, 2018 · 1 comment · Fixed by #478

Comments

@rakeshvar
Copy link

rakeshvar commented Jun 2, 2018

I am running the example given in the docs.
As I change the value of lambda the doc seems to imply that we get different results; but we do not.
What is the best way to solve this problem for different values of lambda?
using lambda=Variable(); fix!(lambda, 9)?

n = 9
y = 1:n
x = Variable(n)

lambda = 1
problem = minimize(sumsquares(y - x) + lambda * sumsquares(x - 10))
@time solve!(problem)
@show x.value  # Expected = 5.5:.5:9.5

lambda = 9
@time solve!(problem, warmstart=true)
@show x.value # Expected = 9.1:.1:9.9
@ericphanson
Copy link
Collaborator

Yes, I believe you should use fix!, and I made a pull request to change the docs to this effect; changing lambda as the docs suggest after the problem is constructed does not change the problem at all (in fact, since minimize is not a macro, I think it would be impossible for that to happen).

Note to use fix! you would need lambda = Variable(Positive()) because Convex does not update the sign automatically when using fix! (maybe this should be added?). You could also do

n = 9
y = 1:n
x = Variable(n)

lambda = 1
obj1 = sumsquares(y - x)
obj2 = sumsquares(x - 10)
problem = minimize( obj1 + lambda * obj2 )
@time solve!(problem, SCSSolver())
@show x.value  # Expected = 5.5:.5:9.5

lambda = 9
problem.objective =  obj1 + lambda * obj2 
@time solve!(problem, SCSSolver(),  warmstart=true)
@show x.value # Expected = 9.1:.1:9.9

which avoids fix!. Reusing obj1 and obj2, Convex doesn't have to recompute the conic forms, which might be helpful for large problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants