Topic
2 replies Latest Post - ‏2013-02-12T17:16:29Z by SystemAdmin
SystemAdmin
SystemAdmin
7929 Posts
ACCEPTED ANSWER

Pinned topic Multi-Threading in .NET

‏2013-02-09T00:39:37Z |
Hi,

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?

W
Updated on 2013-02-12T17:16:29Z at 2013-02-12T17:16:29Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7929 Posts
    ACCEPTED ANSWER

    Re: Multi-Threading in .NET

    ‏2013-02-09T08:49:26Z  in response to SystemAdmin
    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.
    • SystemAdmin
      SystemAdmin
      7929 Posts
      ACCEPTED ANSWER

      Re: Multi-Threading in .NET

      ‏2013-02-12T17:16:29Z  in response to SystemAdmin
      Hi Daniel,

      Thank you for sharing your insights.

      I'll give it a try.

      W