Decision Optimization

Decision Optimization

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

 View Only
  • 1.  instances in parallel

    Posted Thu March 28, 2019 06:36 PM

    Originally posted by: 88Simon88


    Hi 

    How can I run different instances in parallel?

    Best regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: instances in parallel



  • 3.  Re: instances in parallel

    Posted Tue April 02, 2019 01:55 PM

    Originally posted by: 88Simon88


    Dear Alex,

    I am running the following model:

     

    Parallel_Solving.mod

     

    int n=...;
    int nbthreads=...;
    int Fixed        = 30+n;
    int NbWarehouses = 4;
    int NbStores     = 10+n;

    assert( NbStores > NbWarehouses );

    range Warehouses = 1..NbWarehouses;
    range Stores     = 1..NbStores;
    int Capacity[w in Warehouses] =
      NbStores div NbWarehouses +
      w % ( NbStores div NbWarehouses );
    int SupplyCost[s in Stores][w in Warehouses] =
      1 + ( ( s + 10 * w ) % 100 );
    dvar int Open[Warehouses] in 0..1;
    dvar float Supply[Stores][Warehouses] in 0..1;
    dexpr int TotalFixedCost = sum( w in Warehouses ) Fixed * Open[w];
    dexpr float TotalSupplyCost = sum( w in Warehouses, s in Stores )  SupplyCost[s][w] * Supply[s][w];
    minimize TotalFixedCost + TotalSupplyCost;

    subject to {
      forall( s in Stores )
        ctStoreHasOneWarehouse:
          sum( w in Warehouses )
            Supply[s][w] == 1;
      forall( w in Warehouses )
        ctOpen:
          sum( s in Stores )
            Supply[s][w] <= Open[w] * Capacity[w];
    }

    execute
    {
        var o = new IloOplOutputFile("c:\\res"+n+".txt");
        date = new Date();
        o.writeln(date);
        o.writeln(Open);
        o.close();
    }

     

    and I also have

     

    main.mod

     

    range r = 1..2;

    execute
    {
        d = new Date();
        writeln(d);
        
        for(i in r)
        {
            writeln(i);
            
            IloOplExec("C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio128\\opl\\bin\\x64_win64\\oplrun.exe "+
            " -Dn="+i+" -Dnbthreads=1 C:\\Users\\AN84860\\opl\\Parallel_Solving\\Parallel_Solving.mod",false );
        }
    }

     

    This the result in the scripting log:

    04/02/2019 13:42:03 948
    1
    2

     

    It takes less than a second.

    Why? where are the results of the models? Note that there is no text file for the results.

     

    Regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: instances in parallel

    Posted Tue April 02, 2019 02:37 PM

    Hi,

    in order to debug you could write

    IloOplExec("C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio128\\opl\\bin\\x64_win64\\oplrun.exe "+
            " -Dn="+i+" -Dnbthreads=1 C:\\Users\\AN84860\\opl\\Parallel_Solving\\Parallel_Solving.mod",false );

    in command line and check what happened.

    In command line you would write something like

    oplrun -Dn=1 -Dnbthreads=1 Parallel_Solving.mod

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: instances in parallel

    Posted Tue April 02, 2019 04:14 PM

    Originally posted by: 88Simon88


    I tried it, but there is neither error nor result with this change in the code. I am confused!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer