Fixing some regions of a Variable array in convex.jl

The fix! function in the Convex.jl packages allows to fix the value of a variable to a constant during the optimization.
I was wondering how I can get the same result with a multi-dimensional variable for which I want to fix only certain regions of the variable.

To illustrate my question, imagine I have a (n, k) Variable array over which I am running an optimization procedure in several steps. After each step I want to fix some of the rows of this array so that they cannot change during the next optimization step. Ideally I could do something like:
fix!(var[idx,:])
… solving problem …
free!(var[idx,:])
But this doesn’t seem to work.
Any idea on how to tackle this problem ?
Thanks for your help.

You could add a new variable representing this row of your matrix, e.g. col = Variable(n), then add an equality constraint, var[idx, :] == col, and then fix! and free! the variable col. I’m not sure if it will be the most efficient but it should work.

1 Like

Thanks, I’ll try that !
Actually in my case I never need to free the row again so I can just add an equality constraint, it was a stupid question, sorry.

1 Like