Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  The cover function in OPL

    Posted 12/20/08 12:49 AM

    Originally posted by: SystemAdmin


    [Carina said:]

    Hello.

    I have to solve a restricted master problem, but I cannot get the solution printed.
    It has been recommended that I use the OPL cover function to this, but it won´t work.
    I have tried to include this cover function, but I don't know how it is done correct.

    When I try to run the code below I get following message:
    -------------------------------
    Solution to master problem:
    -------------------------------
    Objective value: 428.0000
    1. Dual costs: (0) : runtime error: uninitialized Constraint

    //
    // OPL Model: restrictet master problem
    //
    import int+ n;
    import int+ ncols;
    range rows 1..n;
    range cols 1..ncols;
    var int+ y[cols] in 0..1;
    import int+ A;
    import float cost;
    constraint cover[rows];
    constraint numveh;
    minimize sum(j in cols)cost[j]*y[j]
    subject to{
      forall(i in rows){
      sum(j in cols) A[i,j]*y[j]>=1;
      numveh: sum(j in cols)y[j]<=3;<br />  }
      };
     


    /*----------------------------------------------------------
    OPL script for solving the master problem of Exercise 3
    -----------------------------------------------------------*/
    float infty:=1000;
    /*-----------------------------------------------------------/
    Declaration of variables
    -------------------------------------------------------------*/
    int+ n:=10;
    int+ ncols:=16;
    range rows 1..n;
    range cols 1..ncols;

    int+ A[rows,cols]:=[[1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1],
                        [0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1],
                        [0,0,1,0,0,0,0,0,0,0,0,0,1,1,0,0],
                        [0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0],
                        [0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0],
                        [0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0],
                        [0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0],
                        [0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0],
                        [0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1],
                        [0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1]];
                     
    float+ cost[cols]:=[82,44,100,84,44,102,102,64,72,122,137,143,104,130,148,150];

    /*-----------------------------------------------------------
    Begin of the main procedure
    -------------------------------------------------------------*/
    int i;
    int j;
    float obj;
    Model master("master.mod") editMode;
    obj:=0;
    /* Solve master problem */
    master.solve();
    cout << "-------------------------------" << endl;<br />cout << "Solution to master problem:" << endl;<br />cout << "-------------------------------" << endl;<br />
    forall ( j in cols )
    obj := obj + cost[j]*master.y[j];
    cout << "Objective value: "<< obj <<endl;<br />forall (i in rows){
    cout << i << ". Dual costs: " << master.cover&#91;i&#93;.dual<<endl;<br />
    }

    Can you help me?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: The cover function in OPL

    Posted 12/29/08 05:57 PM

    Originally posted by: SystemAdmin


    [jfk said:]

    Hello,
    may I know which version of OPL are you using? Looking at your code and finding "import" in it may indicate that it is 4.x...

    as to your problem, I can see only the declaration of "constraint cover[rows];" but no "initialization" of it like you do with "numveh". Isn't that the source of the problem?

    cheers
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: The cover function in OPL

    Posted 12/31/08 05:35 AM

    Originally posted by: SystemAdmin


    [vblanchard said:]

    Hi,

    You have declared the constraint array "cover" but not initialized it.
    You can do it as follows:
    ...
      forall(i in rows){
      cover[i]: sum(j in cols) A[i,j]*y[j]>=1;
    ...

    From the code you have posted, it seems that you are working with OPL 3.7. I can only encourage you to migrate to a newer version of OPL (latest release available for download is currently OPL 6.1)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer