Decision Optimization

 View Only
  • 1.  using script to define variables

    Posted Mon July 06, 2020 09:33 AM
    Hi all,

    I want to reduce the size of decision variables, so it comes to me to use the script.

    now I use : dvar boolean x[k in K][e in E];

    but I know x[k][e] should be zero if e not in E[k], so how can I define x[k][e]?

    I also try like below but failed.
    dvar boolean x[k in K][e in E[k]]  ;

    and 

    execute {
    for (var k in K)
      for( var e in E)
      { if (e not in E[k])
         x[k][e]=0; }  }

    Thanks in advance!

    ------------------------------
    Dario Pisinger
    ------------------------------

    #DecisionOptimization


  • 2.  RE: using script to define variables

    Posted Mon July 06, 2020 09:38 AM
    You can use a tuple (see the section about sparse modeling in the manual).
    For example (untested code)
    tuple KE {
      int k;
      int e;
    }
    {KE} ke = { <k,e> | k in K, e in E : e in E[k] };
    dvar x[ke];

    ------------------------------
    Daniel Junglas
    ------------------------------