Decision Optimization

 View Only
  • 1.  Using sum and forall with a range consisting of a different input parameter

    Posted Thu June 17, 2021 12:09 PM

    Hi,

    I am new to Decision optimization and OPL. I am not able to model two constraints in cplex


    I tried to model like this respectively, but it is not working

    forall(i in B, j in S, c in C)
    (sum(j in S: j in j..(j+l[i]-1)) X[j,c] - Y[i,c]) * z[i,j] >= 0;

    forall(i in B, j in S, k in S: k in j+1..j+l[i])
    t[i,j,k] <= z[i,j];

    where z[i,j] is a binary decision variable
    X[j,c], Y[i,c] and t[i,j,k] are input parameters
    l[i] is also an integer input parameter

    I shall be very thankful for any kind of help.



    ------------------------------
    Adnan Pasha
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Using sum and forall with a range consisting of a different input parameter

    IBM Champion
    Posted Thu June 17, 2021 01:51 PM
    The problem is that the mathematical statement of the constraints is notational nonsense. You have the sum as j goes from j to whatever for all j in J. In other words, "j" means two entirely different things within the same constraint. Try changing the index of summation to something like j1 and see if that resolves the problem.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Using sum and forall with a range consisting of a different input parameter

    Posted Sat June 19, 2021 02:43 AM
    Thanks a lot for responding. I agree that for the first constraint, writing index like that was very naive on my part​. I am sorry for that. I just changed the index and it worked. However, I don't think there is any problem with the indices of the second constraint. Is there any way to model that kind of a constraint in CPLEX.

    Thanks in anticipation.

    ------------------------------
    Adnan Pasha
    ------------------------------



  • 4.  RE: Using sum and forall with a range consisting of a different input parameter

    IBM Champion
    Posted Sat June 19, 2021 02:31 PM
    The phrasing of the second constraint is odd, in that it implies the value of a parameter is conditioned on the value of a variable. Are you trying to say that if any of t[i, j, j+1] ... t[i, j, j + l[i]] takes any value other than 1 then z[i,j] must be 0? If so, what is the domain of t[i, j, k] (binary, nonnegative integer, positive integer, real within specified bounds, ...)?

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------