After defining my variables names and data in arrays, I wish to use them to set the objective function, constraints, and coefficients for the CPLEX problem object.
This can obviously be accomplished in a procedural or sequential fashion.
Has anyone attempted to simultaneuously perform these tasks in a prallel or multi-thread fashion?
Re: Multi-Threading in .NET2013-02-09T08:49:26ZThis is the accepted answer. This is the accepted answer.When doing this, you need to be careful for two reasons:
1. The Cplex class itself is not designed for concurrently adding constraints. You need to apply some locking mechanism yourself so that no two threads add constraints or objective functions at the same time. Same for creating of variables.
2. Creating the model in parallel will result in "random" order of variables and constraints (the order depends on how the OS scheduler schedules the threads). Since the order of variables/constraints may heavily influence the performance of the solver (this is known as "performance variability") it may get hard to reproduce results or debug problems. To avoid this you could create the variables sequentially, then create the constraints in parallel but instead of adding them to CPLEX directly first store them in an array, then sort them according to some criterion (name?) and finally add the sorted array to CPLEX.