5.2 Floating Point Constraints

JaCoP implements a number of floating point constraints specified in appendix A.3.

Constraints PeqC, PeqQ, PgtC, PgtQ, PgteqC, PgteqQ, PltC, PltQ, PlteqC, PlteqQ, PneqC, PneqQ, PplusCeqR,PplusQeqR, PminusCeqR, PminusQeqR and LinearFloat are primitive constraints and can be reified and used in other constraints, such conditional and logical. Other constraints are treated as ordinary JaCoP constraints.

Consider the following code that uses division constraint.

FloatDomain.setPrecision(1E-4); 
 
FloatVar a = new FloatVar(store, "a", 0.1, 3.0); 
FloatVar b = new FloatVar(store, "b", -0.2, 6.0); 
FloatVar c = new FloatVar(store, "c", -1000, 1000); 
 
store.impose(new PdivQeqR(a, b, c));

It performs operation {0.100..3.000} / {-0.200..6.000} and produces a pruned domain for c::{-1000.0000..-0.5000, 0.0167..1000.0000}, assuming precision 10-4.