Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Circular Dependency

    Posted 07/19/16 01:43 PM

    Originally posted by: SumanL


    As you can see in the image,i was trying to formulate the same equation in CPLEX.However i get a circular dependency error.

    I have  initialized the first column elements through a ternary statement but still encounter this error.Is there any way around this?

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Circular Dependency

    Posted 07/19/16 02:27 PM

    Hi,

    with OPL right ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Circular Dependency

    Posted 07/19/16 06:21 PM

    Originally posted by: SumanL


    Hello Alex,

    Yes, with OPL.

    the equation in math form is as follows:

     

    here, I want to initialize the first column of ar to either 1 or 0 and the subsequent columns are calculated based on the above equation.

    The equation in cplex is as follows:

    dexpr float ar[i in r][j in t] = ((((i mod ftoi(row/bank)) == 1) || (i == 1)) && (j == 1)) ? (1) : ((((ftoi(row/bank) % i) == 0) || (i != 1)) && (j == 1)) ? (0) : (abs(ar[i][j-1]-ub[ftoi(i/bank)][j]) + (ar[i][j-1] - ub[ftoi(i/bank)][j]))/2.0 + xr[i][j];

    the ternary operator is used for initialization

     

    I am not sure how to fix the circular dependency error.

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Circular Dependency

    Posted 07/20/16 03:08 AM

    Hi,

    you should use dvar instead of dexpr.

    Try

    range r=1..4;
    range t=1..3;

    dvar float ar[r][t];
    dvar float xr[r][t];
    int row=4;
    int bank=1;
    int ub[i in 0..1000][j in 0..100]=0;

    subject to
    {

    forall(i in r,j in t:((((i mod ftoi(row/bank)) == 1) || (i == 1)) && (j == 1)))
    ar[i][j]==  0; //(abs(ar[i][j-1]-ub[ftoi(i/bank)][j]) + (ar[i][j-1] - ub[ftoi(i/bank)][j]))/2.0 + xr[i][j];

    forall(i in r,j in t:(j!=1) &&  !(((((i mod ftoi(row/bank)) == 1) || (i == 1)) && (j == 1))))
    ar[i][j]==  (abs(ar[i][j-1]-ub[ftoi(i/bank)][j]) + (ar[i][j-1] - ub[ftoi(i/bank)][j]))/2.0 + xr[i][j];


    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Circular Dependency

    Posted 07/20/16 02:56 PM

    Originally posted by: SumanL


    Hello Alex,

    Thank you for your reply.

    I changed dexpr to dvar.But i have two errors  "Constraint could not be created" and " Exception from IBM ILOG Concert: Bad Conversion between an integer object and a numeric object".

    In the below code, I am initializing the first column of ar to either one or zero depending on the condition given. Then the rest are assigned according to the equation.

    xr is my main decision variable which is of type boolean. 

    ub is another 2 dimensional int expression which is a function of xr.

    ar is a float datatype and a function or ub, xr and previous values of ar

        subject to
    {
        forall(i in r,j in t:((((i mod ftoi(row/bank)) == 1) ) && (j == 1))) ///  initialize some of the elements in the first column of ar to 1
            ar[i][j]==  1;

        forall(i in r,j in t:((((i mod ftoi(row/bank)) != 1) ) && (j == 1))) ///  initialize remaining elements in the first column of ar to 0
            ar[i][j]==  0;

        forall(i in r,j in t:(j!=1)) ///  rest of the columns of ar are calculated using the values of the previous columns of ar
            ar[i][j]==  (abs(ar[i][j-1]-ub[ftoi(i/row)][j]) + (ar[i][j-1] - ub[ftoi(i/row)][j]))/2.0 + xr[i][j];

    }

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Circular Dependency

    Posted 07/20/16 05:48 PM

    Originally posted by: SumanL


    Hi,

     

    By changing to dvar and replacing '/' by 'div',i have no errors currently.

    My main decision variable is xr(Boolean type)) which has 16 rows and 5 columns and similarly, ar (float type) consists of 16 rows and 5 columns.

    These are the only variables which have been defined using dvar.But in the statistics tab(attached below),it shows higher number of variables than the actual one. Is it not supposed to be 80 for binary and 80 for other variables?

    The code takes too long to run for such a small case.What should be done to correct this?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Circular Dependency

    Posted 07/21/16 02:25 AM

    Hi,

    abs may lead to implicit integer decision variables. (Abs is a logical constraint not a linear constraint)

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer