How to find the best matching fact

My first choice would be to use constraints, in particular CLP(FD).

My second choice would be s(CASP). The reason it is second is that at present (10/22/2021) the code is so new it is not even in the devel release much less the stable release.

See:

HTH