Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to boud threads number through .NET API

    Posted 02/13/12 06:33 AM

    Originally posted by: AntonRudnev


    hi:
    I need call cplex12.3 in C# to solve a MIP problem. My computer has 2 cores and cplex always uses both of them. I want to manually change the thread number used to 1.
    I have tried

    cplex.SetParam(Cplex.IntParam.Threads, 1);

    but the threads used are still 2.

    Any suggestions are appreciated.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to boud threads number through .NET API

    Posted 02/13/12 06:39 AM

    Originally posted by: SystemAdmin


    What you tried is exactly the thing to do.
    Did you set the parameter before invoking cplex.Solve()? What does the CPLEX log look like? Does it say it still uses 2 threads?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to boud threads number through .NET API

    Posted 02/13/12 06:48 AM

    Originally posted by: AntonRudnev


    Yes, I set the parameter before invoking cplex.Solve(). In the log cplex reports "Parallel mode: none, using 1 thread." But the CPU usage is about 100% when I run the programm. When I run the same model in OPL studio with only one thread CPU usage is about 50%...
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How to boud threads number through .NET API

    Posted 02/13/12 10:53 AM

    Originally posted by: SystemAdmin


    Parallel mode: none, using 1 thread
    

    means that CPLEX indeed uses only one thread. What tool do you use to monitor CPU usage? I guess you use the Windows task manager?
    If you enable View->Select Columns ...->Thread Count, how many threads does it show for the CPLEX process?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: How to boud threads number through .NET API

    Posted 02/13/12 11:02 PM

    Originally posted by: AntonRudnev


    Daniel, thanks. Definitely the parameter works.
    With the task manager I found out the number of threads

    from 5 to 9 with cplex.SetParam(Cplex.IntParam.Threads, 1)
    from 6 to 10 with cplex.SetParam(Cplex.IntParam.Threads, 2)

    When I run both versions in parallel, the difference between threads is always 1.

    I tried this experiment on CPU with 4 cores. Results are the same. If I use Optimization Studio, the parameter "thread count" exactly checks with the number of used cores (by CPU usage). But under the .NET framework with one thread cplex uses 2 cores, with 2 threads - 3 cores, with 3 and 4 threads - all 4 cores.

    Does this parameter mean any bounds on CPU cores used?
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: How to boud threads number through .NET API

    Posted 02/14/12 01:56 AM

    Originally posted by: SystemAdmin


    I am not an expert in .NET but my guess is that the additional threads you see in the .NET framework are started by this framework and have nothing to do with CPLEX. For example, a Java virtual machine will also fire up several other threads no matter what you do in your program.
    Why one of these additional threads consumes 50% of the CPU is a good question I cannot answer. You would have to ask some .NET expert.
    The CPLEX Threads parameter does not control the number of threads that the framework starts. It only controls the number of threads that CPLEX starts. By default it starts as many threads as there are cores, but this can be limited by the Threads parameter.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: How to boud threads number through .NET API

    Posted 02/14/12 03:44 AM

    Originally posted by: AntonRudnev


    Daniel thanks a lot. You are right, the problem was in .NET routine. Sorry for wasting your time.
    #CPLEXOptimizers
    #DecisionOptimization