title: problem with writing if statement using Boolean variable in CPLEX
body: <p>here is a part of my cplex code. i defined the PreReq as boolean variable but in the constraint i get the error for PreReq that "expression must have bool type" what am i doing wrong?</p>
  
  <pre><code>IloBoolVarArray2 PreReq(env), CoRec(env), Offered(env);
  
  //Constraint 6: if course d is taken and course c is its pre-req, then course c must be taken before d 
  IloExpr constraint6a(env);
  IloExpr constraint6b(env);
  IloExpr constraint6c(env);
  IloExpr constraint6d(env);
  for (c = 0; c &lt; NumberOfCourses; c++) {
      for (d = 0; d &lt; NumberOfCourses; d++) {
          if (PreReq[c][d] == 1 ) {
              for (s = 0; s &lt; NumberOfSemesters; s++) {
                  constraint6a += X[d][s];
                  constraint6b += X[c][s];
                  constraint6c += s*X[c][s];
                  constraint6d += s*X[d][s];
              }
          }
      }
      mod.add(constraint6a &lt;= constraint6b); 
      mod.add(constraint6c &lt;= constraint6d + (NumberOfSemesters)*(1 - onstraint6a) );
      constraint6a.end(); 
      constraint6b.end(); 
      constraint6c.end(); 
      constraint6d.end(); 
  }
  </code></pre>