I think you can replace all occurrences of "id" with "parent",
removing the redundant "parent" reference in the first fact.
On Jul 28, 2009, at 1:35 PM, Wolfgang Laun wrote:
Sorry, where I have "name" in depends-on, that was meant to be your
slot "children".
As for the id slot I added: I don't think it can be done without. It
just should be a unique identifier.
It serves the same or similar purpose in Ernest's solution, to
freeze the forall iteration to the children list elements of a
*single* depends-on fact, i.e., the one matched in the initial CE.
-W
On Tue, Jul 28, 2009 at 5:31 PM, levent kent <thelev...@gmail.com>
wrote:
Thanks again, but I didn't get it. I don't have any slot named "id"
or "name".
Idefined my templates as follows.
(deftemplate depends-on (slot parent) (multislot children))
(deftemplate available-part (slot name))
Here, depends-on relation specifies which parent task depends on the
subtaks given in the multislot named "children".
To complete a "parent task", one should first complete the subtasks.
I a task ?x is to be completed, the system adds (available-part
(name ?x)) to the working memory. So, I need to check if all
subtasks of a parent task ?p are "available-part" or not to insert
(availabl-part (name ?p)) to WM.
I hope it is not difficult ot rewrite your query.
Thanks
On Tue, Jul 28, 2009 at 5:16 PM, Ernest Friedman-Hill <ejfr...@sandia.gov
> wrote:
This is the right solution; it could be simplified a little using
the "forall" conditional element, which would make this closer to
the spirit of the Levent's original:
(defrule every-subtask
(depends-on (id ?x)(parent ?a))
(forall (depends-on (id ?x)(name ? ?n ?))
(available-part (name ?n)))
=>
(assert (available-part (name ?a)))
)
On Jul 28, 2009, at 10:53 AM, Wolfgang Laun wrote:
It would be easier to detect a depends-on where the available-part
would be missing for one of its name list elements.
As it stands now, you'll need an identifier for depends-on so that
the binding into the not (via ?x) is possible.
(defrule every-subtask
(depends-on (id ?x)(parent ?a))
(not (and (depends-on (id ?x)(name ? ?n ?))
(not (available-part (name ?n)))))
=>
(assert (available-part (name ?a)))
)
-W
On Tue, Jul 28, 2009 at 2:47 PM, levent kent <thelev...@gmail.com>
wrote:
Hi everybody,
I am doing my masters thesis and have a problem with lists.
It is actually very simple.
I want to create a rule which says:
If all subtasks of a parent task are completed, then the parent task
can be completed too.
I tried the code below, but it seems that I can not use "foreach" at
LHS of a rule.
(defrule BuildPlanForward
(depends-on (parent ?a) (children ?list))
(foreach ?c ?list (available-part (name ?c)))
=>
(assert (available-part (name ?a)))
)
How could I write such a rule in Jess?
Thanks,
--
Levent Kent
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012 ejfr...@sandia.gov
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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
.
--------------------------------------------------------------------
--
Levent Kent
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com
--------------------------------------------------------------------
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.
--------------------------------------------------------------------