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 found that we can already use a Parameter mechanism by doing as follows:
# Parameter# I'm jerous of Parameter in cvxpy# https://www.cvxpy.org/api_reference/cvxpy.expressions.html#parameter# we don't need to recreate prob object and we can reuse it by using Constant as Parameter# solve problem for various q valueusing Convex
using SCS; solver =SCSSolver(verbose=0)
P = [10; 02]
qs = [[3.0,4.0], [5.0,6.0], [7.0,8.0]] # Should be Array{Float64}
x =Variable(2)
q_param =Constant(qs[1]) # Parameter (use Constant)@show q_param.id_hash
prob =minimize(0.5*quadform(x,P)+dot(q_param,x), [0<= x])
for q in qs
# @show q_param.value# @show qcopyto!(q_param.value, q) # q_param.value is immutable but we can copy value to it
Convex.solve!(prob, solver)
@show x.value
end
The functions fix! and free! can be used for this as well. You can fix! a variable to a value (fix!(x, v)), then solve the problem. Then you can fix! it again to a new variable and solve again (this was broken until #299 so it may not have worked if you tried before). You can also free!(x) to make it a variable again etc.
Does that cover your use case? (If so, maybe it's then a matter of updating the documentation to make it clear how do to this).
I'm a heavy user of Convex.jl, but I often feel that I want some additional feature of it in comparison with CVXPY.
(1) Parameters
CVXPY has a "Parameters" feature that only change non-variable value and solve the same problem frequently.
http://www.cvxpy.org/en/latest/tutorial/intro/index.html#parameters
As you know, this kind of use often appears in Model Predictive Control, Moving Horizon Estimation, etc.
I feel Parameters feature is very useful.
(2) Variable / Solver extension
CVXPY can be easily extended default ability of "convex problem" solving algorithm and can solve some non-convex problems
e.g. Convex-Concave procedure, non-convex QP, etc.
DCCP
https://github.com/cvxgrp/dccp
QCQP
https://github.com/cvxgrp/qcqp
NCVX
https://github.com/cvxgrp/ncvx
--
I think these kinds of features are very useful.
I tried to extend Convex.jl by using traits etc, but I don't understand elegant way.
What do you think?
The text was updated successfully, but these errors were encountered: