Thanks for the reply.
Firstly, I tried the first advice, but with no success. I guess I didnt understand you properly. I have DemandPool object with demands[] as property with get and set. I am doing defInstance of demand pool in java program, which already has demands.
These lines

(demandPool (demands $? ?demand $?))(OBJECT ?demandPool)

(demand (cusPriority 1|2) )(OBJECT ?demand)

are in rule.
But some how rules doesnt get fired although I have demands with cusPriority 1 and 2.
 
Secondly, I liked your suggestion. I am definitely going to implement it. But now, I am just kind of prototyping the problem and want to see whether I can do this simple way in JESS. 
I guess you are suggesting to put the demands in loop for one priority and process. But the thing is I can have more than three properties which needs to be prioritized like customerPriority, customerRating, costFactor so on. I want to match demand with best of all these priorities. If I write loops for all three its going to be complicated. And there is no fixed costFactor, it can be any value >0. Basically I want to get demand with maximum of costFactor. This looks to me like more like procedural programming. I can write loops in java better.
 
Does rule engine solve these kind of problems in simpe way?
 
Thanks
Bhaskar
 
 


[EMAIL PROTECTED] wrote:
I think bhaskar yallala wrote:

> But I want to write a rule such that for the given demands only cusPriority highest should be matched first and cusFactor highest should be matched. If cusPriority highest is not matched , then it should go for next priority level. Similarly, for cusFactor.
>
> I was thinking of writing with and , or but it can't prioritize.
> (or (eq (call ?demand getCustomerPriority) 1) (eq (call ?demand getCustomerPriority) 2)) )
> This one just selects customer priority 1 or 2. I want to first go through all demands and see whether there is customerPriority 1 is present at all in the list.
>

I can't write the rule for you exactly, but I can give you two pieces
of good advice:

First, it seems to me that having the Demand objects themselves
definstanced, as well as the DemandPool objects, would ma! ke everything
vastly easier; if instead of writing the above long function, you
could simply match

(DemandPool (demands $? ?demand $?))
(Demand (customerPriority 1 | 2) (OBJECT ?demand))

you can see how much simpler everything would be.

Second, remember that rules are cheap. You're trying to do something
in one rule which sounds to me like a whole group of rules: first do
this, then do this, then do this. You need to take a step back and
look at the problem, trying to break it down into smaller pieces, and
write each piece as a separate rule.

This last one isn't advice so much as a guess at a good way to
approach your problem. Imagine if you had a fact like

(priority 1)

And a rule which matched the priority fact with a pattern like

(priority ?x)

and did something with demands with that priority. Then you could have
a loop which asserted a priority value and then ran the system to
process all ! the demands with that priority; then retracted the
priority fact and asserted a new one. The loop could itself take the
form of a low-salience rule: low-salience so that it would do the
retraction until all the processing had been done for that priority
level. Make sense? This, together with definstancing the demand
objects, could vastly simplify your whole approach to the problem.



---------------------------------------------------------
Ernest Friedman-Hill
Science and Engineering PSEs Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------



Thanks and regards,
Bhaskar

[EMAIL PROTECTED]
[EMAIL PROTECTED]


Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!

Reply via email to