Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Using cloud - setof(..) not working

    Posted Thu August 23, 2018 06:47 PM

    Originally posted by: JaneM


    I'm try to move a model that works on my perpetual license that works on my computer to DOCoud.  I'm having problems with the following statements.  It seems that the coding for setting up sparse models does not work in the cloud version.  Is there other code that works?

    Assign is an Excel file sheet that has only some of the locations.

    AssignAll is the set of all PlGroups and LOC1 pairs.

     

    tuple TPlGroups {

      string PGLevel2ID;

    }

    {TPlGroups} PlGroups = ...;

     

    tuple TLOC1 {

      string LOC1;

    }

    {TLOC1} LOC1 = ...;

     

    tuple Pairs {

      string PGLevel2ID;

      string Loc1Name;

      };

     

    setof(Pairs) Assign = ...;

     

    setof(Pairs) AssignAll = {<g,l> | g in PlGroups, l in LOC1};

     

     

    I get the following errors.

    [8/22/18, 2:09:55 PM, SEVE] 162:1-162:83 TestV_14-SimpleCloud.mod: Cannot use type {<<PGLevel2ID:string>,<LOC1:string>>} for {Pairs}.
    [8/22/18, 2:09:55 PM, SEVE] 162:1-162:83 TestV_14-SimpleCloud.mod: Processing failed.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Using cloud - setof(..) not working

    Posted Fri August 24, 2018 01:28 AM

    Hi

    whether you rely on the cloud or not, you should change

    setof(Pairs) AssignAll = {<g,l> | g in PlGroups, l in LOC1};

    into

    setof(Pairs) AssignAll = {<g.PGLevel2ID,l.LOC1> | g in PlGroups, l in LOC1};

    regards

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


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Using cloud - setof(..) not working

    Posted Fri August 24, 2018 02:07 PM

    Originally posted by: JaneM


    Thanks Alex, this seems to have solved this problem.  

    I have a new problem now and will set up as a separate topic.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Using cloud - setof(..) not working

    Posted Fri August 24, 2018 07:30 PM

    Originally posted by: JaneM


    I was having another challenge with my setof(..) notation.  I think I solved it while writing the question.  I will leave this comment in the forum in case others are having the same problem.

    All of my current challenges transferring my desktop perpetual license model to the cloud have been reflecting the same formatting which I don't understand.  In this situation, you changed

    <g,l> to

    <g.PGLevel2ID,l.LOC1>. 

    In my other question today, the solution was to change 

    {string} LOC1X =LOC1 union SLOC1_GR;

    to

    {string} LOC1X = {i.LOC1 | i in LOC1} union SLOC1_GR;

     

     

     

    So it seems I don't understand how to use this additional location.  

    Here is the next code that worked on my desktop but not in the cloud.

     

     

    setof(string) LOC_PGF[g in PlGroups] =

    {l | <g,l> in AssignT};

     

    It looks like I solved it with the following.  However, I didn't know that one could add multiple requirements separated by comments.

    setof(string) LOC_PGF[g in PlGroups] =

      {l.LOC1 | l in LOC1, <g.PGLevel2ID, l.LOC1> in AssignT};

     

    Is there another better solution? 

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Using cloud - setof(..) not working

    Posted Fri August 24, 2018 08:01 PM

    Originally posted by: JaneM


    More challenges moving to the cloud.  Is this problem similar to those above? 

    My notation in this code, is giving me an error running in the cloud for probably a similar reason.  

     

    dexpr float ZLWS_Occ[l in LOC1][t in TimeE] =

              sum(gl in AssignT:gl.Loc1Name==l) ZPG_WSOcc[gl][t] ;

     

    The error message says that the == is wrong.

     

    Based on reviewing Alex's Cours2.pdf, I tried the following, which also didn't work

     

     

    dexpr float ZLWS_Occ[l in LOC1][t in TimeE] =

              sum(<g,m> in AssignT: l == m) ZPG_WSOcc[<g,m>][t] ;

              

    dexpr float ZLWS_Occ[l in LOC1][t in TimeE] =

              sum(<g,l> in AssignT) ZPG_WSOcc[<g,l>][t] ;

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Using cloud - setof(..) not working

    Posted Sat August 25, 2018 05:25 PM

    Originally posted by: JaneM


    It looks like I solved this one with:

     

    dexpr float ZLWS_Occ[l in LOC1][t in TimeE] =

              sum(gl in AssignT:gl.Loc1Name==l.LOC1) ZPG_WSOcc[gl][t] ;      

     

    seems as though anything in brackets needs to have the l.LOC1 or gl.Loc1Name type of format


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Using cloud - setof(..) not working

    Posted Sat August 25, 2018 05:20 PM

    Originally posted by: JaneM


    Add another likely related problem.  

    Earlier in my code for cloud, the following was accepted.

    setof(string) LOC1F =   

      {l | <g,l> in AssignT};    

     

    However, in the section to set constraints, I had the following problems. 

       ctInitializeWkSpO: forall(l in LOC1F)

                ZLWkSp[l][0] == LWSTotalT0[l] * LCtrlEx[l][0];

     

    led to the error

     

    Cannot use type string for <LOC1:string>

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Using cloud - setof(..) not working

    Posted Sat August 25, 2018 05:51 PM

    Originally posted by: JaneM


    It seems to be a problem that these variables are specified over LOC1 rather than LOC1F, which is a subset of LOC1


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: Using cloud - setof(..) not working

    Posted Sat August 25, 2018 06:19 PM

    Originally posted by: JaneM


    Here's another one that I can't figure out that seems related to the same notation. 

    dexpr float ZLWS_Use[l in LOC1][t in TimeE] =         

              sum(gl in AssignT:gl.Loc1Name==l.LOC1) (ZPG_WSOcc[gl][t] * (1 + BufferG[gl.PGLevel2ID][t])) ;

     

     

    BufferG is defined as 

    BufferG[PlGroups][TimeT]

    I want to use BufferG for the g that is in gl

    The error is: 

    Cannot use type string for <PGLevel2ID:string>

     

    I tried this which worked.  But I don't think I should have to use a sum when I am just trying to find the one g that equals gl.PGLeve2ID.  I'm not even sure if it is doing the right calculation.

     

    dexpr float ZLWS_Use[l in LOC1][t in TimeE] =         

    sum(gl in AssignT:gl.Loc1Name==l.LOC1)

    (ZPG_WSOcc[gl][t] * (1 + sum(g in PlGroups: gl.PGLevel2ID == g.PGLevel2ID) BufferG[g][t])) ;

     

     

     

    Similary this doesn't work

    forall (g in PlGroups, t in TimeE)

       ctAssignAll sum(gl in AssignT:gl.PGLevel2ID==g) ZPGShLoc1[gl][t] == 1;

     

    Based on an example above that worked for an expression

     

    dexpr float ZLWS_Occ[in LOC1][in TimeE] =

              sum(gl in AssignT:gl.Loc1Name==l.LOC1) ZPG_WSOcc[gl][t] ;      

     

    I tried 

    forall (g in PlGroups, t in TimeE)

       ctAssignAll sum(gl in AssignT:gl.PGLevel2ID==g.PlGroups) ZPGShLoc1[gl][t] == 1;

     

    That has the error

    Expecting a component in tuple <PGLevel2ID:string>, found PlGroups.

    So tried this, which worked

    forall (g in PlGroups, t in TimeE)

       ctAssignAll sum(gl in AssignT:gl.PGLevel2ID==g.PGLevel2ID) ZPGShLoc1[gl][t] == 1;

     

    I don't understand why in one case, the index is followed by the name of the set (l.LOC1) and in this case, the name of the set doesn't work (g.PlGroups), it works when followed by the field name in the index gl,  g.PGLevel2ID.

     

    Overall, I don't understand why CPLEX has set up the DOCloud version so that what works on a desktop perpetual license doesn't work in the cloud. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Using cloud - setof(..) not working

    Posted Sat August 25, 2018 08:49 PM

    Originally posted by: JaneM


    So I found the answer to the last question.  In my file the name of the set and the name of the variable were the same, which is why it seemed that the index was followed by the name of the set.  Once I changed the name of the variable in the set, the code is consistent with the name of the variable after the relevant index.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer