I am trying to implement multiprocessing to run 9 scenarios in parallel. I have a single model for which constraints are changed based on each scenario. I am trying to run these scenarios in parallel in every iterations. I found the following code from Silke Horn. However, I need to run these scenarios iteratively and this code requires defining model for each iterations. Is there another way where I can define a model once before iteration starts and use this for multiprocessing?
import multiprocessing as mp
import gurobipy as gp
with gp.Env() as env, gp.Model(env=env) as model:
# define model
# retrieve data from model
if __name__ == '__main__':
with mp.Pool() as pool:
pool.map(solve_model, [input_data1, input_data2, input_data3]
Please sign in to leave a comment.