Originally posted by: zab.a
Thank you Alex for your reply,
it is very helpful since I now know about count function in cplex, btw, I am using CPLEX Studio IDE 12.9.0 .
however, I would like to count any value in the array of variable x regardless of the value of index j in x.
e.g. x[i] = [15 20 20 20 14] , here i=1..5 . so that this line of code you proposed: forall(i in r,j in r) xx[i][j]==(x[i]==j); unfortunately , will not work with this case .
May be my explanation was not that clear, but now I want to count and constrain the number of times a variable x[i] has the same value. in other words:
scenario 1 (simpler): if variable x[i] will have similar values in its array, I want to constrain the number of those equal values. e,.g limiting the number of having equal values in array x[i] to be only two times.
scenario 2 (more detailed level): to constrain how many times a certain value ex. 20 shall be obtained in array x[i] . e.g. the value of 20 obtained only one time, the value of 3 obtained only 2 times, value x if 7 obtained only 2 times and so on.
Thank you for your support,
#DecisionOptimization#MathematicalProgramming-General