I have got a rather large optimization problem, where creating the model (and writing an .lp file or passing it to a solver) takes a substantial amount of time (a few days), while solving it is (comparatively) quick. Since it is not advised to parallelize the actual creation of the the JuMP model I thought about two approaches:
-
After creating the model, parallelize the .lp file writing (by writing parts to different files and only merging afterwards)
-
Parallelizing the pre-processing to speed up the actual model creation.
(2) is the (in theory) more easy approach, since a considerable amount of model creation is lost not on the actual usage of @variable (or expr / constr) macros, but on deciding which variables to construct, what there bounds are, the exact formulation of constraints and so on. This could easily be done in parallel and before actually trying to create the JuMP model, but relies on one question that I am unsure on how to (efficiently!) solve in Julia:
Consider the simple model structure
if condition
constraint_1 = "x + y <= 7"
else
constraint_1 = "x + 2*y <= 7"
end
(consider the string not as actual string but as some efficient way to describe a symbolic constraint)
I can check all these conditions for each constraint easily in a parallel fashion beforehand and “remember” that the correct constraint to construct for index 1 is “x + 2y <= 7”. How would I go about representing that and using it to generate
@constraint(m, x + 2y <= 7)
afterwards?
(Additional question: is there any resource on approach (1), the parallelization of .lp file writing?)