Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Problems about Parallel Computing

    Posted Sat May 26, 2018 10:03 AM

    Originally posted by: skyskyhuanghuang


    Hi,everyone

       I encountered a problem,I currently have 4 servers. I want to make full use of the computing resources of 4 servers. How should my model file be modified? Is CPLEX able to provide parallel computing?My model file is as follows:

    using CP;
    int M=...;
    float P=...;
    float H[1..M][1..M]=...;
    float B0=...;
    float n0=...;
    dvar int Yji[1..M][1..M] in 0..1 ;
    execute
    {
    var p=cp.param;
    p.LogPeriod=80000;
    p.TimeLimit=36000;
    p.Workers=40;//auto(as many works as there are cpus available)
    p.searchType="Restart";
    p.OptimalityTolerance=1;
    }
    maximize
    B0*sum(i in 1..M)(
         log(1+P*sum(j in 1..M:j!=i)(
                 H[j][i]*Yji[j][i]/ 
                   (n0+P*sum(n in 1..M:n!=j)(
                            sum(q in 1..M)H[n][i]*Yji[n][q]
                          )
                   )
               )
             )/log(2)
       );
       
    subject to
    {
    forall(i in 1..M)
    {
    Hangyueshu:
     sum(j in 1..M)
         Yji[i][j]<=1;   
    }
    forall(i in 1..M)
    {
    Lieyueshu:  
        sum(j in 1..M)
         Yji[j][i]<=1;   
    }
    forall(i in 1..M)
       forall(j in 1..M)
    Duichenyueshu:
         Yji[i][j]==Yji[j][i];
    forall(i in 1..M)
    Zishenyueshu:
      Yji[i][i]==0;
      
    }
    execute
    {
    writeln("Yji=",Yji);
    writeln("Objective= ",cp.getObjValue());
     
    }
    main
    {
    var nbsol=0;
    thisOplModel.generate();
    cp.startNewSearch();
    while(cp.next())
    {
    nbsol++;
    writeln("solution ",nbsol);
    thisOplModel.postProcess();
    }
     
    }

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Problems about Parallel Computing

    Posted Sat May 26, 2018 10:24 AM

    Hi

    for MIP we have https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/parallel_optim/distribMIP/01_distributed_mip_title_synopsis.html

    here since you enumerate solutions what you could do is divide the feasible space in 4 subspaces and then run your model for each subspace on a server

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Problems about Parallel Computing

    Posted Mon May 28, 2018 02:05 AM

    Originally posted by: skyskyhuanghuang


    Thank you! But my model uses the cp(constraint programming) engine, how do I calculate the model in parallel?And the version of my solver is 12.6.3


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Problems about Parallel Computing

    Posted Mon May 28, 2018 03:11 AM


  • 5.  Re: Problems about Parallel Computing

    Posted Tue May 29, 2018 09:52 PM

    Originally posted by: skyskyhuanghuang


    Thank you,However, there is only one model in my question, corresponding to a data file, because I have been solving the model for too long, so I mean, can I shorten this time by putting this one model on four machines and solving it in parallel? Similar to Hadoop?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Problems about Parallel Computing

    Posted Thu May 31, 2018 03:59 AM

    Hi,

    let me give you an example.

    Suppose you want to count all solutions for 12 queens.

    You could write

    using CP;

        int Dim=12;
        
       
        dvar int queen[1..Dim] in 1..Dim;
        dvar int d1[1..Dim];
        dvar int d2[1..Dim];

        constraints {
        
           
        
        forall(ind in 1..Dim) {
        d1[ind] == queen[ind]+ind;
        d2[ind] == queen[ind]-ind;
        };

        allDifferent(queen);
        allDifferent(d1);
        allDifferent(d2);
        };

        main {
        thisOplModel.generate();
        cp.startNewSearch();
        cp.param.workers=1;
        cp.param.searchType = "depthFirst";
        var n=0;
        while (cp.next()) {
        n = n+1;
        
        

        }
        cp.endSearch();
        write(n," Solutions ");
        }

     

    and it takes a few seconds to give you 14200 solutions

     

    But if you have 4 machines you could divide the problem into 4 sub problems:

    .mod

     

        using CP;

        int Dim=12;
        
        {int} subDivision=...;
        dvar int queen[1..Dim] in 1..Dim;
        dvar int d1[1..Dim];
        dvar int d2[1..Dim];

        constraints {
        
        queen[1] in subDivision;    
        
        forall(ind in 1..Dim) {
        d1[ind] == queen[ind]+ind;
        d2[ind] == queen[ind]-ind;
        };

        allDifferent(queen);
        allDifferent(d1);
        allDifferent(d2);
        };

        main {
        thisOplModel.generate();
        cp.startNewSearch();
        cp.param.workers=1;
        cp.param.searchType = "depthFirst";
        var n=0;
        while (cp.next()) {
        n = n+1;
        
        

        }
        cp.endSearch();
        write(n," Solutions ");
        }

     

    and then you would use 4 dat files

    and in the 4 machines you run

    oplrun nqueens.mod sub1.dat

    oplrun nqueens.mod sub2.dat

    oplrun nqueens.mod sub3.dat

    oplrun nqueens.mod sub4.dat

    and that way you get your result faster.

    The total is 14200 and the sub results are 2471, 4629, 4629 and 2471

    regards

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer