The decision between using a "hard" (fact) reference and a key has
arguments for either
side. I'm not going to try to list them all ;-)

- Hard references are readily available, but building structures is
more complicated.
- If you don't have a primary key, you'll have to invent an artificial
one. (Your x-y-pair
*might* be a possibility.)
- Obtaining a referenced fact from the one containing the hard
reference is efficient
  and you don't need another clause matching the key in the rule to obtain the
  soft referenced fact.
- Key values are readable when printed; references need additional
work for making
the goal fact "readable" (Something like "<Fact-5>" isn't "readable" enough.)

-W

2008/9/30 levent kent <[EMAIL PROTECTED]>:
> Hmm, thanks.It was very explanatory that Jess does not work like prolog.
> So, now I would ask what do Jess-people do, when they have to define
> nodes with 2 coordinates or an employee with id,name,surname,wage?
>
> It would be very confusing to flatten all the data. I guess there should be
> a way to do it.
> Should we use java classes for that purpose or are there different ways to
> do it?
>
> Thanks for all replies, all were very understandable for me :)
>
> On Mon, Sep 29, 2008 at 9:14 PM, Gary Hallmark <[EMAIL PROTECTED]>
> wrote:
>>
>> Jess and most other production rule languages do not have Herbrand terms
>> that prolog-like languages use to model tree-structured facts.  In your case
>> you can simply flatten your data model to a single fact with 2 x and 2 y
>> coordinates, as Hal suggests.
>> In more complex cases you may want to assert several linked facts -- but
>> your rules may need several patterns and tests to put th pieces back
>> together again.
>>
>> Levent Kent wrote:
>>>
>>> Hi,
>>>
>>> I  am a new user fo Jess and try to get some understanding for the
>>> engine.
>>> I cant understand why the code below does not work.
>>>
>>> (deffacts graph-links3
>>>    (link3 (gnode3 0 0) (gnode3 2 1))
>>>    )
>>>
>>> Here, I am trying to describe links of nodes with 2 coordinates.
>>> How should I do that?
>>>
>>> I also tried this version:
>>> (deftemplate gnode (slot x) (slot y))
>>> (deftemplate link (slot start) (slot end))
>>>
>>> (deffacts graph-links
>>>    (link (start (gnode (x 0) (y 0))) (end (gnode (x 2) (y 1))))
>>>    (link (start (gnode (x 2) (y 1))) (end (gnode (x 1) (y 2))))
>>>   (link (start (gnode (x 2) (y 1))) (end (gnode (x 2) (y 0))))
>>>    (link (start (gnode (x 2) (y 0))) (end (gnode (x 1) (y 1))))
>>>    (link (start (gnode (x 1) (y 1))) (end (gnode (x 0) (y 2))))
>>>   (link (start (gnode (x 0) (y 2))) (end (gnode (x 2) (y 3))))
>>>   (link (start (gnode (x 1) (y 2))) (end (gnode (x 1) (y 3))))
>>>    )
>>>
>>> I am always geetıng the error message:
>>> Jess reported an error in routine Funcall.execute
>>>    while executing (gnode3 0 0)
>>>    while executing assert from deffacts MAIN::graph-links3
>>>    while executing (reset).
>>>  Message: Undefined function gnode3.
>>>
>>> or
>>>
>>> Jess reported an error in routine Funcall.execute
>>>    while executing (gnode (x 0) (y 0))
>>>    while executing assert from deffacts MAIN::graph-links
>>>    while executing (reset).
>>>  Message: Undefined function gnode.
>>>
>>> Some little help would save me from confusion.
>>>
>>> I hope this message will be accepted by the mailing list, because I am
>>> not
>>> sure if my messages are delivered successfully.
>>>
>>> Thanks,
>>>
>>> Levent
>>>
>>
>>
>> --------------------------------------------------------------------
>> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
>> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
>> (use your own address!) List problems? Notify [EMAIL PROTECTED]
>> --------------------------------------------------------------------
>>
>
>
>
> --
> Levent Kent
>

Reply via email to