Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Ask help for using cplex parallel mode

  • 1.  Ask help for using cplex parallel mode

    Posted 08/07/10 06:29 PM

    Originally posted by: SystemAdmin


    Hi all, I have a question about using cplex parallel mode, may I have some help?

    Since I am running a network design MIP problem in a large instance, I want to try to turn on the cplex parallel mode to let it run faster. I read the manual and wrote the following code to let cplex can use maximum number of threads (opportunistic). (My computer has 4 cores) But from the output, it shows that cplex still use only one threads. Can anyone give me some help about this? Thank you very much!
    model.add(IloMinimize(env, obj));
    IloCplex cplex(env);
    cplex.extract(model);
    cout<<"The original parallel mode parameter is: "<<cplex.getParam(IloCplex::ParallelMode)<<endl;
    cout<<"The original thread parameter is: "<<cplex.getParam(IloCplex::Threads)<<endl;
    cplex.setParam(IloCplex::ParallelMode, -1);
    cplex.setParam(IloCplex::Threads, 0);
    cout<<"The updated parallel mode parameter is: "<<cplex.getParam(IloCplex::ParallelMode)<<endl;
    cout<<"The updated thread parameter is: "<<cplex.getParam(IloCplex::Threads)<<endl;
    


    The output is:

    The original parallel mode parameter is: 0
    The original thread parameter is: 0
    The updated parallel mode parameter is: -1
    The updated thread parameter is: 0
    Tried aggregator 3 times.
    MIP Presolve eliminated 47810 rows and 20159 columns.
    MIP Presolve modified 1810 coefficients.
    Aggregator did 1929 substitutions.
    Reduced MIP has 77949 rows, 42984 columns, and 282597 nonzeros.
    Presolve time =    2.03 sec.
    Clique table members: 67524.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: dynamic search.
    Parallel mode: none, using 1 thread.
    Root relaxation solution time =    6.74 sec.
    


    From the last second line of output, we can see that cplex still use one threads.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Ask help for using cplex parallel mode

    Posted 08/07/10 06:33 PM

    Originally posted by: SystemAdmin


    sorry, I forgot to say I am using Cplex 11 and visual studio 2008.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Ask help for using cplex parallel mode

    Posted 08/07/10 07:40 PM

    Originally posted by: SystemAdmin


    Do you attach any callbacks to the IloCplex instance before solving it? Callbacks change how the Threads parameter is interpreted.

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 02:09 AM

    Originally posted by: SystemAdmin


    A thread-count of 0 instructs CPLEX to use (a little obscure) default behavior (please refer to the manual for further details). This seems to result in using only a single thread in your case.
    Instead of
    cplex.setParam(IloCplex::Threads, 0);
    

    try
    cplex.setParam(IloCplex::Threads, cplex.getMax(IloCplex::Threads));
    

    This will use the maximum number of threads CPLEX allows.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 05:17 PM

    Originally posted by: SystemAdmin


    Paul, thank you, I did not use callback in that code.

    Daniel, thank you. I changed to the command you mentioned, but cplex still only used one thread, do you know is there any other place I should do some change? or to check?

    cplex.extract(model);
    cout<<"The original parallel mode parameter is: "<<cplex.getParam(IloCplex::ParallelMode)<<endl;
    cout<<"The original thread parameter is: "<<cplex.getParam(IloCplex::Threads)<<endl;
    cplex.setParam(IloCplex::ParallelMode, -1);
    cplex.setParam(IloCplex::Threads, cplex.getMax(IloCplex::Threads)); //let cplex to use maximum number of threads
    cout<<"The updated parallel mode parameter is: "<<cplex.getParam(IloCplex::ParallelMode)<<endl;
    cout<<"The updated thread parameter is: "<<cplex.getParam(IloCplex::Threads)<<endl;
    

    the output is:
    The original parallel mode parameter is: 0
    The original thread parameter is: 0
    The updated parallel mode parameter is: -1
    The updated thread parameter is: 1
    Tried aggregator 3 times.
    MIP Presolve eliminated 47810 rows and 20159 columns.
    MIP Presolve modified 1807 coefficients.
    Aggregator did 1929 substitutions.
    Reduced MIP has 77948 rows, 42984 columns, and 282590 nonzeros.
    Presolve time =    2.04 sec.
    Clique table members: 67524.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: dynamic search.
    Parallel mode: none, using 1 thread.
    Root relaxation solution time =    4.73 sec.
    

    we can see that the parallel mode is still none, and use 1 thread.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 05:23 PM

    Originally posted by: SystemAdmin


    It looks like cplex.getMax(Param::Threads) returns 1? Can you please verify that?
    What version of CPLEX are you using? And what kind of license do you have? Maybe you are using an older version and don't have a multi-threaded license? I take it you are sure that you have indeed a 4 core machine?

    By the way, what happens if you leave parallel mode and thread count at their default values (that is, never change them at all). By default CPLEX uses as many threads as there are CPUs.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 05:42 PM

    Originally posted by: SystemAdmin


    Daniel,

    I checked my computer, it has 4 cores, and I used cplex 11. I am not sure about the license, how can I know what type of license I am using? I am using the cplex in computer lab of my university, I guess it is the educational version. Also, 1 is actually returned by

    cplex.getParam(IloCplex::Threads)
    


    I tried
    cout<<"The maximum thread parameter is: "<<cplex.getMax(Param::Threads)<<endl;
    
    you mentioned, but there are two errors about this command. The errors are:
    error C2653: 'Param' : is not a class or namespace name
    error C2065: 'Threads' : undeclared identifier
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 05:52 PM

    Originally posted by: SystemAdmin


    Sorry, that was my mistake. It should have been cplex.getMax(IloCplex::Threads).
    I guess you only have a single-threaded license. Any chance to switch to CPLEX 12.2? It is free of charge for academic use.
    Usually environment variable ILOG_LICENSE_FILE points to the license file. In this file there is a statement like "options: e m b q p=2". What is important are the different characters and numbers after "options:". What does your license file have there?
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 06:28 PM

    Originally posted by: SystemAdmin


    May I know the details about where to find the license file? I am not very clear about this sentence "Usually environment variable ILOG_LICENSE_FILE points to the license file."

    I tried
    cplex.getMax(IloCplex::Threads)
    

    it returns 1.
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 08:00 PM

    Originally posted by: SystemAdmin


    On Linux/Unix, the command
    echo $ILOG_LICENSE_FILE
    
    will display the value of the environment variable ILOG_LICENSE_FILE.

    On Windows XP, environment variables are managed in the "Advanced" tab of the "Properties" window of "My Computer". A web search should give you any additional details you might need.

    In either case, the ILOG_LICENSE_FILE variable is the location on your system of the license file for ILOG products. If you look at this file you will see the specific options for your CPLEX license.

    Philip Starhill
    CPLEX Research Engineer
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 09:29 PM

    Originally posted by: SystemAdmin


    Philip, thank you, I got the license file.
    We have cplex 11 and cplex 12.1 installed. The statements in license file are:

    TOKEN   CPLEX     11.000 NEVER       8C62517CMK4D 20 any , options: e m b q use=20 , server: CANNIBAL , license: 134122
    TOKEN   CPLEX     12.100 NEVER       VM7JY1GGMSBD 50 any , options: e m b q use=50 MaintenanceEnd=20120831 , server: CANNIBAL , license: 134122
    


    From these, may I know what kind of license I am using? and how many threads can I use? Thanks.
    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Ask help for using cplex parallel mode

    Posted 08/10/10 01:37 PM

    Originally posted by: SystemAdmin


    The lack of a "p" among the options indicates that the license you have does not allow parallel execution.

    Can you get access to IBM's Academic Initiative? If so, you will be able to use the latest version of CPLEX with parallel execution enabled. More information is in this forum post: http://www.ibm.com/developerworks/forums/thread.jspa?threadID=335577&tstart=0

    Philip Starhill
    CPLEX Research Engineer
    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: Ask help for using cplex parallel mode

    Posted 08/10/10 03:00 PM

    Originally posted by: SystemAdmin


    Philip, thank you. Since I use the computer of university, I can not install software to the computer. Is there any other method that I can enable the parallel function for cplex 11 or cplex 12.1?
    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: Ask help for using cplex parallel mode

    Posted 08/11/10 01:08 PM

    Originally posted by: SystemAdmin


    In your note you mainly referred to CPLEX 11 behavior. Did you try the same thing with CPLEX 12.1? With CPLEX 12.1 the license key no longer specifies a limit on threads. If your program can access only 1 thread using CPLEX 12.1, then it's not a licensing issue, and somehow the computer is only offering 1 thread when CPLEX queries it.
    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: Ask help for using cplex parallel mode

    Posted 08/16/10 11:26 PM

    Originally posted by: SystemAdmin


    John, Thank you. Now I can use 4 threads when I am using cplex 12.1. Thanks.
    #CPLEXOptimizers
    #DecisionOptimization


  • 16.  Re: Ask help for using cplex parallel mode

    Posted 08/09/10 05:45 PM

    Originally posted by: SystemAdmin


    I used these commands to check the default values for parallel mode (before I did change)
    cout<<"The original parallel mode parameter is: "<<cplex.getParam(IloCplex::ParallelMode)<<endl;
    cout<<"The original thread parameter is: "<<cplex.getParam(IloCplex::Threads)<<endl;
    


    they returned the values 0 and 0.
    #CPLEXOptimizers
    #DecisionOptimization