Originally posted by: brown_rice
      Thanks for the clear explanation but I still receive the same error.
    
"The method addTerm(double, IloNumVar) in the type IloLinearNumExpr is not applicable for the arguments (double, IloLinearNumExpr)"
    
      I also tried; 
    
expr.addTerm(myArray[i], (IloLinearNumExpr) cplex.diff(1, (IloLinearNumExpr) cplex.sum(firstVar[i],secVar[i])));
    
      but did not work. Just for now, I am going with
    
expr.setConstant(Arrays.stream(myArray).sum());
for(){
    expr.addTerm(-myArray[i],firstVar[i]);
    expr.addTerm(-myArray[i],secVar[i]);
}
    
      and it works.
    
#CPLEXOptimizers#DecisionOptimization