Re: clpfd constraints not taking effect
James Hogan <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAAG0J9-sPuEoCWwgpSbhmnnDzXr0y9TT=dtd0R76-qjAAi-CSw@mail.gmail.com> |
Hi Markus, On 24 August 2013 19:47, Markus Triska <[email protected]> wrote: > James Hogan <[email protected]> writes: > >> Ah, I think I get it, so in the apply_preargs example, SWI's shallow >> look at apply_preargs sees the latter two functors as taking the same >> argument types, so it has to remember it in case the first fails or >> other solutions required. > > Yes, with your current version, the second argument of both clauses is a > term of the form [_|_] (functor '.', arity 2), so SWI's current, shallow > indexing cannot distinguish them, and choice-points are left behind. > Relatedly, tail call optimization cannot be applied as a consequence. Fixing get_event_time/3 had a massive (positive) effect on performance! > >>> ?- person(enosh). >>> true ; >>> true ; >>> false. >> >> yes, I've been trying to get rid of these cases, especially the final >> false (which now makes much more sense). > > It probably makes sense to precompute the definition of person/1 before > your actual constraint solving: You can use setof/3 to collect > everything you consider a person, using the various rules you defined, > and then use assertz/1 to create a single clause for each person. This > makes further uses of person/1 deterministic when the argument is bound. very cunning, and seems to work well. I've now managed to make process_db/2 fully deterministic :) Thanks again -- James Hogan