'Will SCIP handle divided by 0 automatically?

I'm using SCIP in C++ to solve a minlp problem. In my model, I try to implement an expression to compare two variables. If they are equal, the output is 0, and otherwise it outputs 1.

Let them be varA and varB and both are integers.

Is it safe to write a SCIP expression like (varA - varB) / (varA - varB)? If not, is there a build-in expression in SCIP for comparison of two variables?



Solution 1:[1]

You could use indicator constraints for that. E.g.:

? = ?1+?2
? = 0 => x=y
?1 = 1 => x?y+1
?2 = 1 => y?x+1
?,?1,?2 ? {0,1}

 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Erwin Kalvelagen