Re: counting the number of backtracs

From: Bart Demoen (bmd_at_cs.kuleuven.ac.be)
Date: 03/29/04

  • Next message: Matthew Huntbach: "Re: Mainstreaming Prolog a Pragmatic Approach?"
    Date: Mon, 29 Mar 2004 08:44:50 +0200
    
    

    zeus wrote:
    > bart demoen <bmd@cs.kuleuven.ac.be> wrote in message news:<1080422530.509215@seven.kulnet.kuleuven.ac.be>...
    >
    >>zeus wrote:
    >>
    >>>How can I use assert/retract to count the number of backtracks made in
    >>>execution of a predicate?
    >>>
    >>>Thanks,
    >>>Zeus
    >>
    >>Your question is very difficult to answer - it resembles the question:
    >>"how can I use a hammer to put a nail in a piece of wood".
    >>The question suggests that you are so close to actually doing it, that
    >>you need no more help.
    >>Unless you don't know what "the number of backtracks" means - and then
    >>your question should have been different ...
    >>
    >>???
    >>
    >>Cheers
    >>
    >>Bart Demoen
    >
    >
    >
    > Actually to be precise, what I wanna count is the number of
    > constraints checked by a predicate.

    Maybe you should decide first what you want to make with the aid of
    you hammer - a chair or a table ?

    BTW, which constraint solver were you referring to in "number of constraints" ?
    What is your definition of a "constraint checked by a predicate" ?

    Since you asked specifically where the assert and retract go, here is
    where:

            init_counter :-
                    retract(counter(_)),
                    fail.
            init_counter :-
                    assert(counter(0)).

            increase_counter_by_one :-
                    retract(counter(C)),
                    NewC is C + 1,
                    assert(counter(NewC)).

    Oh, and in case you don't know: reading the manual helps.

    Cheers

    Bart Demoen


  • Next message: Matthew Huntbach: "Re: Mainstreaming Prolog a Pragmatic Approach?"

    Relevant Pages

    • Re: counting the number of backtracs
      ... In message, zeus ... >constraints checked by a predicate. ... hint as to what you are actually trying to do. ... Nick ...
      (comp.lang.prolog)
    • Re: Sublists question
      ... In message, zeus ... you might start by writing a sublist predicate. ... >that L1,L2,L3 are its sublists. ... >sequence with n variables? ...
      (comp.lang.prolog)
    • Re: counting the number of backtracs
      ... > zeus wrote: ... >> execution of a predicate? ... what I wanna count is the number of ... constraints checked by a predicate. ...
      (comp.lang.prolog)
    • Re: counting the number of backtracs
      ... > zeus wrote: ... >> execution of a predicate? ... the semantics of assert and retract, so I lack the understanding of ...
      (comp.lang.prolog)
    • Re: multiset ordering
      ... I thought that every predicate I wrote was invertible in ... I'm reading the book "Programming in Prolog" by ... Clocksin and Mellish, ... and I hope that at the end of my reading I will have more clear ideas. ...
      (comp.lang.prolog)