Hi,

I was trying to figure out a way of checking the "status" of some system.
To make things simpler, I have two kinds of facts, start and end, which
are added along time:
    (deftemplate start)
    (deftemplate end)

Then I want to say that I have an "active" system if it has started and
not ended yet. However, I want to avoid doing like
    (start) (not (end))
in every rule where I need to check if the system is active.

My first approach was to try backward chaining. In Prolog I would do
something like:
    active :- start, not(end).

However in Jess this gets more complicated, since doing something like:
    (deftemplate active
        (declare (backchain-reactive TRUE)) )
    (defrule do-active
        (need-active)
        (start)
        (not (end))
        =>
        (assert (active)) )

will assert the active fact, but then I need another rule to retract
active when end occurs...

I then turned to using the logical conditional element, which seems to
work fine:
    (defrule active-ctx
        (logical (not (end)))
        (start)
        =>
        (assert (active)) )

Is this the best way of doing it?

Thanks.

Henrique



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to