You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to solve two problems, one after the other, by varying a single parameter p. But, according to Convex.jl, the solution to the second problem is the same as the first, which I know should not be the case, so Convex.jl is not detecting the parameter change when it solves the problem the second time. That is, in the two problems below, Convex.jl reports the solution to be 4; but for the second problem the solution should be 5.
lam = Convex.Variable(9,1)
p = 4 # p is a parameter.
convex_problem = minimize( p*sum(lam)+p , [lam >= 0])
Convex.solve!(convex_problem,GurobiSolver())
println("p: $p. Convex Status: $(convex_problem.status). Objective Value of Lagrangian Relaxation: $(convex_problem.optval).")
p += 1 # Increment the parameter p.
Convex.solve!(convex_problem,GurobiSolver(),warmstart=true)
println("p: $p. Convex Status: $(convex_problem.status). Objective Value of Lagrangian Relaxation: $(convex_problem.optval).")
The text was updated successfully, but these errors were encountered:
The problem is that in the call minimize( p*sum(lam)+p , [lam >= 0]), when p = 4 is just a value, internally Convex forgets that name p and simply uses the value 4 in its formulation of the problem. Instead, you can make a variable p, and then fix! it's value. In your case, that would be
using Convex, SCS
lam = Convex.Variable(9,1)
p =Variable()
fix!(p, 4)
convex_problem =minimize( p*sum(lam)+p , [lam >=0])
Convex.solve!(convex_problem,SCSSolver(verbose=0))
println("p: $p. Convex Status: $(convex_problem.status). Objective Value of Lagrangian Relaxation: $(convex_problem.optval).")
fix!(p,5)
Convex.solve!(convex_problem,SCSSolver(verbose=0),warmstart=true)
println("p: $p. Convex Status: $(convex_problem.status). Objective Value of Lagrangian Relaxation: $(convex_problem.optval).")
(I used SCS instead of Gurobi, since I don't have Gurobi installed on this computer, but it should be the same).
instead of lambda = Variable() since the problem is only DCP when lambda > 0, and fix! does not update the sign of the variable (which maybe should be changed).
I am trying to solve two problems, one after the other, by varying a single parameter p. But, according to Convex.jl, the solution to the second problem is the same as the first, which I know should not be the case, so Convex.jl is not detecting the parameter change when it solves the problem the second time. That is, in the two problems below, Convex.jl reports the solution to be 4; but for the second problem the solution should be 5.
lam = Convex.Variable(9,1)$p. Convex Status: $ (convex_problem.status). Objective Value of Lagrangian Relaxation: $(convex_problem.optval).")$p. Convex Status: $ (convex_problem.status). Objective Value of Lagrangian Relaxation: $(convex_problem.optval).")
p = 4 # p is a parameter.
convex_problem = minimize( p*sum(lam)+p , [lam >= 0])
Convex.solve!(convex_problem,GurobiSolver())
println("p:
p += 1 # Increment the parameter p.
Convex.solve!(convex_problem,GurobiSolver(),warmstart=true)
println("p:
The text was updated successfully, but these errors were encountered: