For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2004 > counting the number of backtracs









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author counting the number of backtracs
zeus

2004-03-27, 11:59 pm

How can I use assert/retract to count the number of backtracks made in
execution of a predicate?

Thanks,
Zeus
bart demoen

2004-03-27, 11:59 pm

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

zeus

2004-03-28, 10:29 pm

bart demoen <bmd@cs.kuleuven.ac.be> wrote in message news:<1080422530.509215@seven.kulnet.kuleuven.ac.be>...
> zeus wrote:
>
> 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


No Bart, its like I know that a hammer is used to put a nail in a
piece of wood, but I don't know the action of "nailing". I don't know
the semantics of assert and retract, so I lack the understanding of
how to use them in place. For example in my previous thread (sublists
langford), suppose I want to count the number of backtracks, where
should I put the asserts? what does it do?

Thanks,
Zeus
zeus

2004-03-28, 10:29 pm

bart demoen <bmd@cs.kuleuven.ac.be> wrote in message news:<1080422530.509215@seven.kulnet.kuleuven.ac.be>...
> zeus wrote:
>
> 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.
Bart Demoen

2004-03-29, 2:33 am

zeus wrote:
> bart demoen <bmd@cs.kuleuven.ac.be> wrote in message news:<1080422530.509215@seven.kulnet.kuleuven.ac.be>...
>
>
>
>
> 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
Nick Wedd

2004-04-17, 11:32 am

In message <f238fff9.0403272349.5c5d2eb1@posting.google.com>, zeus
<zohar@sheernetworks.com> writes
>bart demoen <bmd@cs.kuleuven.ac.be> wrote in message
>news:<1080422530.509215@seven.kulnet.kuleuven.ac.be>...
>
>
>Actually to be precise, what I wanna count is the number of
>constraints checked by a predicate.


That is not "precise", it is an entirely different question.

You are unlikely to get a helpful answer unless you give us some slight
hint as to what you are actually trying to do. If you show us your
predicate, and say what you mean by a constraint, maybe someone can
help.

Nick
--
Nick Wedd nick@maproom.co.uk
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com