I want to program a custom version of the predicate cumulative/2
(or at least a similar predicate in terms of functionality). I looked for the sources of CLP(FD) library and I was now wondering whether it could be a good idea to modify that library (only by adding new things) in order to incorporate the new my_cumulative/2
but with the library's private predicates available to do so.
I want to add the following features:
[limit(3)]
I could have, for instance, [limit(2),limit(3),limit(1)]
; where each limit corresponds to a different resource)This idea came to me when I was trying to add a custom operator /\
to calculate intersections (like-wise \/
denotes unions) and I saw that there actually is one already defined in clpfd.pl but not made part of the module.
For a start, you should try to express your constraints in terms of exported library predicates. If you need to use a private predicate of the library, you can call it with its module prefix (like clpfd:some_predicate(...)
). Private predicates may change without notice, but they can be useful if you want to experiment with some things, and you can ask for more public predicates etc. on the SWI mailing list when you have found out which ones are useful to you. To calculate intersections with public predicates, you can use for example: X in 0..5 #/\ X in 0..2, fd_dom(X, Dom)
. You can use (#\/)
for unions.