Decision Optimization

Decision Optimization

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


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

extracting set

  • 1.  extracting set

    Posted 05/27/16 05:59 AM

    Originally posted by: sandeepsinghchauhan


    I have C = { CANDY1 CANDY2 CANDY3 CANDY4}

              PRO = [{1 2 3} {4 5} {6 7 8 9} {10 11 12 13}]

    Xtotal is an expression

    forall (p in C) {
      sum(s in PRO[p])Xtotal[s] == one expression;
    }

    ERROR


    Cannot use type int for <!pr:int,sa:float>.  

    please help

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: extracting set

    Posted 05/27/16 06:16 AM

    Hi,

    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;
     
     
    dvar int x;
    dexpr int Xtotal[i in 1..13]=x;

    subject to
    {
    forall (p in C) {
      sum(s in PRO[p])Xtotal[s] >= 1;
    }
    }

    works fine

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: extracting set

    Posted 05/27/16 06:22 AM

    Originally posted by: sandeepsinghchauhan


    Xtotal is a tuple set of <!pr:int,sa:float>


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: extracting set

    Posted 05/27/16 06:38 AM

    Ok so instead of

    s in PRO[p])Xtotal[s]

    you should write

    s in PRO[p])Xtotal[s].pr

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: extracting set

    Posted 05/27/16 06:45 AM

    Originally posted by: sandeepsinghchauhan


    Thanks for reply but getting same error

    forall (p in C) {

    sum(s in PRO[p]) Xtotal[s].pr  >= sum(o in O)S[<t,o>];

    }

    same ERROR
    Cannot use type int for <!pr:int,sa:float>.  

    please help

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: extracting set

    Posted 05/27/16 06:55 AM

    Ok so then you should try

    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;
     
     tuple t
     {
      key int pr;
      float sa;
     }
     
     {t} Xtotal={<i,i/2> | i in 1..20};
     
    dvar int x;


    subject to
    {
    forall (p in C) {
      sum(s in PRO[p])item(Xtotal,s).sa >= 1;
    }
    }

    regards

     

    PS: have you had a look at the support channel https://www.youtube.com/user/OptimizationSupport ?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: extracting set

    Posted 05/27/16 07:02 AM

    Originally posted by: sandeepsinghchauhan



    The function item(dexpr float[Pr],int) does not exist.   

    please help :(


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: extracting set

    Posted 05/27/16 07:09 AM

    Hi,

    the example I gave you works fine.

    I cannot guess what you wrote.

    So in order to get some help, my suggestion is to post your model. And then somebody could help you.

    Regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: extracting set

    Posted 05/27/16 07:17 AM

    Originally posted by: sandeepsinghchauhan


    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;
     
     tuple t
     {
      key int pr;
      float sa;
     }

    {t} PR= ...;

    dvar float x[D];

    dexpr float Xtotal[p in Process] = sum(some expression)X[D] ;

    subject to
    {
    forall (p in C) {
      sum(s in PRO[p])item(Xtotal,s).sa >= 1;
    }
    }

    ERROR


    The function item(dexpr float[Pr],int) does not exist. 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: extracting set

    Posted 05/27/16 07:32 AM

    Hi

    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;
       
     {int} D=asSet(1..20);
     {int} Process=asSet(1..20);

    dvar float x[D];

    dexpr float Xtotal[p in Process] = sum(i in D)x[i]+p ;

    subject to
     {
     forall (p in C) {
       sum(s in PRO[p])(Xtotal[s]) >= 1;
     }
     }

    works fine.

    Are you a commercial user or a researcher ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: extracting set

    Posted 05/27/16 07:36 AM

    Originally posted by: sandeepsinghchauhan


    Thanks for your valuable reply

    I am researcher Smile


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: extracting set

    Posted 05/27/16 08:01 AM

    Originally posted by: sandeepsinghchauhan


    sorry it p in Pr instead of p in Process

    dexpr float Xtotal[p in Pr] = sum(i in D)x[i]+p ;

    -----------------------------------------------------------------------------------------------------

    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;
     
     tuple t
     {
      key int pr;
      float sa;
     }

    {t} PR= ...;

    dvar float x[D];

    dexpr float Xtotal[p in Pr] = sum(some expression)X[D] ;

    subject to
    {
    forall (p in C) {
      sum(s in PRO[p])item(Xtotal,s).sa >= 1;
    }
    }

    ERROR


    The function item(dexpr float[Pr],int) does not exist. 

    please help


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 13.  Re: extracting set

    Posted 05/27/16 08:12 AM

    In the example I gave you, no item was used:

    sum(s in PRO[p])(Xtotal[s]) >= 1;

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 14.  Re: extracting set

    Posted 05/27/16 08:16 AM

    Originally posted by: sandeepsinghchauhan


    yes but Xtotal is an dexpr used  by Process (asSet(1..20)) which is a set and in my actual problem Xtotal used by PR which is a tuple

     

    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;

    dvar float x[D];

    tuple t
     {
      key int pr;
      float sa;
     }

    {t} PR= ...;

     

    dexpr float Xtotal[p in PR] = sum(some expression)X[D] ;

    subject to
    {
    forall (p in C) {
      sum(s in PRO[p])item(Xtotal,s).sa >= 1;
    }
    }

    ERROR


    The function item(dexpr float[Pr],int) does not exist. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 15.  Re: extracting set

    Posted 05/27/16 08:19 AM

    Originally posted by: sandeepsinghchauhan


    I can't change my Xtotal because it affect my other variables also


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 16.  Re: extracting set

    Posted 05/27/16 08:26 AM

    Hi,

    {string} C = { "CANDY1"," CANDY2","CANDY3","CANDY4"};

     {int} PRO[C] = [{1,2 ,3} ,{4, 5} ,{6, 7, 8, 9}, {10, 11, 12, 13}] ;

     

    tuple t
      {
       key int pr;
       float sa;
      }

    {t} PR={<i,i/2> | i in 1..20};

    dexpr float Xtotal[p in PR] = p.sa ;

    subject to
     {
     forall (p in C) {
       sum(s in PRO[p]) sum(p2 in PR:p2.pr==s)Xtotal[p2] >= 1;
     }
     }

    works fine and it can help you with the syntax

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 17.  Re: extracting set

    Posted 05/27/16 09:56 AM

    Originally posted by: sandeepsinghchauhan


    Thanks Smile


    #DecisionOptimization
    #OPLusingCPLEXOptimizer