efficiently reusing/updating julia convex constraints

68 views Asked by At

I'm using Julia (with Convex) to solve a convex problem many times with the same constraint structure. Right now, I have something like the following simplified structure:

using Convex
N = Int16(1e4)
x = Variable(N)
t = Variable()
obj = square(x)
for sim_number = 1:100
    z = rand(N)
    p = minimize(obj)
    for j = 1:N
        p.constraints += [x[j] >= z[j] + t]
    end
    solve!(p)
end

Is there a way to initialize the structure of the N constraints x >= random_val[j] + t outside of the sim_number loop so that I can reuse / update the RHS of the constraints only? For the real problem I have, setting up the N constraints (I have N = 100,000) takes a long time, but solving is quick, so I'm seeking a way to reuse the constraint structure.

0

There are 0 answers