Decision Optimization

Decision Optimization

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

 View Only
  • 1.  how to retrieve cplex decision variables using doopl

    Posted Wed November 09, 2022 03:17 PM
    Hello, 

    I have a scheduling model and i have no way to export the decision variables (I cannot select all and copy paste in excel). My version 12.10.0.0 so I am not able to export the results in excel. In this connection, I am trying to use doopl for the purpose of extracting the results. But I am not sure how to convert the interval variables to a table, so that i can use get_table() in the doopl. Could anybody help me with several lines of code ? 

    The extraction of my mod file is the following: 
    using CP;
    tuple Workcenter {string name; int cap;}
    tuple Alt {string po; string wc;}

    {Workcenter} WCs = ...;
    {string} PONames = ...;
    {Alt} Alts = ...;

    int Duration [t in PONames] = ...;

    tuple Precedence {
    string pre;
    string post;
    };

    {Precedence} Precedences = ...;

    int ReleaseDate[t in PONames] = ...;
    int DueDate [t in PONames] = ...;
    float Weight [t in PONames] = ...;

    //Create the production order interval variables
    dvar interval itvs[t in PONames] size Duration[t];
    //Create the alternative resource, i.e., workcenter interval variables
    dvar interval alt[a in Alts] optional;

    ////Create the sequence variables
    //dvar sequence wcs[w in WCs] in
    //all(t in PONames: WCs[t]==w) itvs[t] ;

    execute {
    cp.param.FailLimit = 10000;
    }

    minimize max(t in PONames)
    (Weight[t] * maxl(0, endOf(itvs[t])-DueDate[t]) + lengthOf(itvs[t]) );

    subject to {
    //Add the precendence constraints
    forall(p in Precedences)
    endBeforeStart(itvs[p.pre], itvs[p.post]);

    //start after the release date
    forall(t in PONames)
    ReleaseDate[t] <= startOf(itvs[t]);

    //Add the capacity constraints
    forall(w in WCs)
    sum(a in Alts: a.wc == w.name) pulse(alt[a],1) <= w.cap;

    //alternative constraints
    forall(t in PONames)
    alternative(itvs[t], all(a in Alts: a.po==t) alt[a]);

    }



    ------------------------------
    Quan Long
    ------------------------------

    #DecisionOptimization


  • 2.  RE: how to retrieve cplex decision variables using doopl

    Posted Wed November 16, 2022 10:23 AM

    You have to create a tupleSet from the values of the decision variables. This tupleSet will be available via the get_table.

    for example with:
    {string} PONames = ...;
    dvar interval itvs[t in PONames]

    you can for example have something like the following to query the start/end of the activity
    tuple Report{
    string name;
    int start;
    int end;
    }
    {Report} report = {<j, startOf(itvs[j]), endOf(itvs[j])> | j in PONames};

    ------------------------------
    Vincent Beraudier
    ------------------------------



  • 3.  RE: how to retrieve cplex decision variables using doopl

    Posted Wed November 16, 2022 02:10 PM
    Thanks a lot! It works!