Originally posted by: SystemAdmin
Thank you for sending in your code, it greatly helps clarify things.
> you said that:"In the if-condition, are you trying to refer to the
> value of the variable and compare that against 0 or 1?",Perhaps it is
> ture. can you help me check the codes in the plus txt file ??
Daniel's comment of how an object can be equal to two things simultaneously, still holds true. I think the confusion is a result of typo, wherein you said that the if condition should be :
if (decide[i][j].Equals(0) && decide[i][j].Equals(1))
when you really meant it to be:
if (decide[i][j].Equals(0) & decide[i][(j + 1)].Equals(1))
I went through your code and have made a few changes. Please find the modified code attached. The if condition looks like the following:
cplex.Add(cplex.IfThen(cplex.And(cplex.Eq(decide[i][j], 0), cplex.Eq(decide[i][j + 1], 1)), cplex.Eq(cplex.Sum(decide[i][j + 2], decide[i][j + 3]), 2)));
You correctly pointed out that the 'ifthen' logical constraint is not available with CPLEX 9.0; CPLEX 10.0 was the first version that supports this type of constraint. Thus, for the attached code to work you will need to upgrade your CPLEX version to CPLEX 10.0 or later versions. You could be entitled to get the latest version of CPLEX (12.3) via the academic initiative program. Details about registering with this program can be found in the following technote:
http://www-01.ibm.com/support/docview.wss?uid=swg21419058 Hope this helps.
#CPLEXOptimizers#DecisionOptimization