Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Preprocessing

Archive User

Archive UserTue March 03, 2020 09:56 AM

ALEX FLEISCHER

ALEX FLEISCHERTue March 03, 2020 10:28 AM

ALEX FLEISCHER

ALEX FLEISCHERWed March 04, 2020 03:49 AM

  • 1.  Preprocessing

    Posted Tue March 03, 2020 05:37 AM

    Originally posted by: Valentin_J


    Hello everyone,

    I would like to know how is it possible to erase some parameters of a decision variable.

    I mean, I have a dvar x which represent travel between nodes, and I know that some are impossible so I want them to not be include in the process so it may be faster.

     

    Thank in advance, have a nice day.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Preprocessing



  • 3.  Re: Preprocessing

    Posted Tue March 03, 2020 06:34 AM

    Originally posted by: Valentin_J


    First of all thank you,

     

    to be honest i didn't get the whole code from your topic, is that it that doing the restriction ?

    
    {connection} CPs[p in Products] = { c | <p,c> in Routes };
    assert forall(p in Products) 
       sum(o in Orig[p]) Supply[<p,o>] == sum(d in Dest[p]) Demand[<p,d>];
    

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Preprocessing

    Posted Tue March 03, 2020 06:44 AM

    Hi,

    so suppose you have 3 nodes A,B,C and you want to know how much to move between A and B and then B to C.

    You could use an array

    dvar int move[nodes][nodes];

    but this array is 3*3 and you will only use 2 decision variables.

    So what is smarter is to use only arcs.

    And then you ll have 2 decision variables, one per arc

    You got the idea ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Preprocessing

    Posted Tue March 03, 2020 07:09 AM

    Originally posted by: Valentin_J


    In fact,

    To know how much to move, I already have a cost matrix, and my x[N][N][K] (where N is the number of nodes and K my et of vehicles) is a boolean. I want to set at 0 some of edge of x 

    like :

    forall (k in K)

         x[i][j][k]=0;

    Where I will be able to decide which couple i,j I want to disable. Unfortenately it's obviously not working like that.

    So in my objective function they won't appear because they are equal to 0.

    minimize
      sum(k in K, i in N, j in N)
        c[k][i][j]*x[i][j][k];

    Sorry if my answer misses the point here.

     

    Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Preprocessing

    Posted Tue March 03, 2020 07:34 AM

    Hi,

    of so you could eitherkeep your x which consumes some memory for x or do something a bit smarter:

    You use a tuple set with i,j,k so that x of i,j,k is not 0

    And then instead of

    x[K][N][N]

    you will use

    x[S]

    which is smaller and does not containe all the 0 you got rid of

     

    regards

     

    https://www.linkedin.com/pulse/low-barrier-entry-optimization-through-cplex-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Preprocessing

    Posted Tue March 03, 2020 08:30 AM

    Originally posted by: Valentin_J


    Ok, so I may first create the global set and then substract what I want to disable ?

    I know how to define a set but not how to substract them 

    tuple S {
      int k;
      int i;
      int j;
    }

    {S} s = {<i,j,k> | i in N, j in N, k in K};

    Then another question all my constraint will work fine just if I update x[S] ?

    from :

        forall (i in P)    sum(k in K)sum(j in N) x[i][j][k]==1;

    to :

        forall (i in P)    sum(k in K)sum(j in N) x[S]==1;

    Best regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Preprocessing

    Posted Tue March 03, 2020 08:57 AM


  • 9.  Re: Preprocessing

    Posted Tue March 03, 2020 09:56 AM

    Originally posted by: Valentin_J


    Thank again !

     

    Ok I manage to do my set without links I wanted to disable.

    Unfortunately as expected, all my constraints are now out of index because I erased some of arcs.

     

    Am I forced to change bounds for all my constraints ?

     

    Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Preprocessing

    Posted Tue March 03, 2020 10:28 AM

    Hi,

    now is the time to move from

    forall (i in P)    sum(k in K)sum(j in N) x[<i,j,k>]==1;

    to

    forall (i in P)    sum(k in K)sum(j in N:<i,j,k> in S) x[<i,j,k>]==1;

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: Preprocessing

    Posted Wed March 04, 2020 02:58 AM

    Originally posted by: Valentin_J


    hi,

    Verry sorry to bother you as much.

    but it says me that the operator is not available :

    Opérateur non disponible pour <int,int,int> IN tuple<k:int,i:int,j:int>

    To be honest I don't really get the point.. 

    You are trying to cut S from sums ? Just include all x that are in S ?

    Moreover, just to be sure, I want the intervale s. Am I right writing ?

    tuple S {
      int k;
      int i;
      int j;
    }

    {S} s0 = {<i,j,k> | i in N, j in N, k in K};

    {S} s1 ={<0,j,k> | j in D, k in K};
    {S} s2 ={<i,0,k> | i in N, k in K};
    {S} s3 ={<i,2*n+1,k> | i in P, k in K};
    {S} s4 ={<i,i,k> | i in N, k in K};

    {S} s = s0 diff s1 diff s2 diff s3 diff s4;

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: Preprocessing

    Posted Wed March 04, 2020 03:49 AM

    Hi

    range N=1..4;
    range K=1..3;
    range D=1..2;
    range P=2..3;
    int n=1;

        tuple S {
          int k;
          int i;
          int j;
        }

        {S} s0 = {<i,j,k> | i in N, j in N, k in K};

        {S} s1 ={<0,j,k> | j in D, k in K};
        {S} s2 ={<i,0,k> | i in N, k in K};
        {S} s3 ={<i,2*n+1,k> | i in P, k in K};
        {S} s4 ={<i,i,k> | i in N, k in K};

        {S} s = s0 diff s1 diff s2 diff s3 diff s4;
        
        execute
        {
          writeln(s);
        }

     

    works fine

    If it s too difficult you may start with a first model that does not exploit sparsity.

    And you may have a look at getting started https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.studio.help/pdf/gsoplide.pdf

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 13.  Re: Preprocessing

    Posted Wed March 04, 2020 05:53 AM

    Originally posted by: Valentin_J


    Hi, 

    I manage to solve my issue and all my constraints thank to you !

    And I better understand tuples and sets now.

     

    have a nice day, best regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 14.  Re: Preprocessing

    Posted Mon March 09, 2020 03:52 AM

    Originally posted by: Valentin_J


    hi again !

    I have got one more question about these tuples, how can i conditioning them ?

    like :

     

    {S} s7 ={<i,j,k> | if (t[i][j]+d[j]+t[j][n+i]>L) i in P,j in N, k in K };

     

    best regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 15.  Re: Preprocessing

    Posted Mon March 09, 2020 07:05 AM

    Hi,

    see https://www.ibm.com/developerworks/community/forums/html/topic?id=91c615e8-af72-44e1-94d1-2b680ca1b3b2&ps=25

    in  https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/

    which in your example could be

    range N=1..4;
    range K=1..3;
    range D=1..2;
    range P=2..3;
    int n=1;
    int L=3;
    int t[i in 1..10][j in 1..10]=i+j;
    int d[i in N]=i;

        tuple S {
          int k;
          int i;
          int j;
        }

        {S} s0 = {<i,j,k> | i in N, j in N, k in K};

        {S} s1 ={<0,j,k> | j in D, k in K};
        {S} s2 ={<i,0,k> | i in N, k in K};
        {S} s3 ={<i,2*n+1,k> | i in P, k in K};
        {S} s4 ={<i,i,k> | i in N, k in K};

        {S} s = s0 diff s1 diff s2 diff s3 diff s4;
        {S} s7 ={<i,j,k> | i in P,j in N, k in K : (t[i][j]+d[j]+t[j][n+i]>L) };
        
        
        execute
        {
          writeln(s);
          writeln(s7);
        }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer