|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
JESS: multislot usageHi again,
I have another problem. I want to state that, if some "part" (task) needs to be completed and is not available, then all sub "part"s or tasks of that "parent" part/task need to be completed too and they should be specified as "needed-part"s. For that, I tried two different things. -- First unsuccesfull attempt: (defrule BuildPlanBackward (needed-part (name ?a)) (not (available-part (name ?a))) (depends-on (parent ?a) (children ?list)) => (foreach ?c ?list (assert (needed-part (name ?c))) ) ) Result: No subtask ?c in form of "(needed-part (name ?c))" is added. -- Second unsuccesfull attempt: (defrule BuildPlanBackward (needed-part (name ?a)) (not (available-part (name ?a))) (depends-on (parent ?a) (children ? ?c ?)) => (assert (needed-part (name ?c))) ) Result: Only one of the children ?c is added in form of (needed-part (name ?c)). -- I do not understand both of the solutions. To insert new facts, I use the two lines ---------------------- executeCommand(...); runEngine(); where the function definitions are: public void executeCommand(String fact) { try { engine.executeCommand(fact); } catch (JessException re) { re.printStackTrace(System.err); } } and public void runEngine(){ try { engine.run(); } catch (JessException re) { re.printStackTrace(System.err); } } --------------- I really did not understand what is going on in this simple code. Thanks for advance, -- Levent Kent |
|
|
Re: JESS: multislot usage(defrule BuildBackwardPlan
(depends-on (children $? ?n $?)) ; match any child, anywhere (not (available-part (name ?n))) ; doesn't have available-part (not (needed-part (name ?n))) ; and not (yet) needed-part => (assert (needed-part (name ?n))) ) The third CE could be omitted if the existing facts are never changed; if so the rule won't ever fire a 2nd time anyway. (Even then, the duplicate assert wouldn't add another needed-part with the same name.) Notice the correct form of multislot patterns ($?) for arbitrary lists before and after ?n. I think that was incorrect in my previous reply. (I'm inclined to think that multislots aren't the best way for expressing this sort of fact relationship. The DB normalization concepts has its merits for facts, too.) -W On Wed, Jul 29, 2009 at 4:13 PM, levent kent <thelevent@...> wrote: Hi again, |
|
|
Re: JESS: multislot usage(defrule BuildBackwardPlan
(depends-on (children $? ?n $?)) ; match any child, anywhere (not (available-part (name ?n))) ; doesn't have available-part (not (needed-part (name ?n))) ; and not (yet) needed-part => (assert (needed-part (name ?n))) ) The third CE could be omitted if the existing facts are never changed; if so the rule won't ever fire a 2nd time anyway. (Even then, the duplicate assert wouldn't add another needed-part with the same name.) Notice the correct form of multislot patterns ($?) for arbitrary lists before and after ?n. I think that was incorrect in my previous reply. (I'm inclined to think that multislots aren't the best way for expressing this sort of fact relationship. The DB normalization concepts has its merits for facts, too.) -W On Wed, Jul 29, 2009 at 4:13 PM, levent kent <thelevent@...> wrote: Hi again, |
| Free embeddable forum powered by Nabble | Forum Help |