Re: JESS: change facts in a loop or something simmilar
I think Bogdan Werth wrote: > > what I want is somehow to call all the facts from the template above and > substract the amount in ?amount2eat from the slot amount. You just write a single rule that matches one fact that needs changing, plus any other facts that supply needed data, and do the modification on the RHS. The rule would fire once for each eligible fact. This may cause an infinite loop -- that can happen when you match a fact on the LHS and modify it on the RHS. If you're using Jess 7 (and you should be!) then use the "no-loop" declaration on this rule to avoid the problem. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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]
JESS: change facts in a loop or something simmilar
Hello everybody, I am making an agent based model with RePast and Jess and I am a bit stuck with the following (maybe for just trivial) problem. I have 12 facts defined with (deftemplate stored (slot householdID) (slot amount) (slot age)) --> householdIDis the id of the household --> amount is the amount of crop stored in the storage container (household has 12 containers) --> ageis the age of the crop (i delete all crops which are older than 12) and one fact (feedStrategy ?householdID ?amount2eat ?resthunger) --> ?householdIDis the id of the household --> ?amount2eat is the amount of food a household will eat per cycle --> ?resthunger hunger for the next cycle (not relevant now) what I want is somehow to call all the facts from the template above and substract the amount in ?amount2eat from the slot amount. Don't think i described it well so here is an example fact 1: stored (householdID 1) (amount 4) (age 1) fact 2: stored (householdID 1) (amount 23) (age 2) ... ......... ... ... fact 11: stored (householdID 1) (amount 0) (age 11) fact 12: stored (householdID 1) (amount 8) (age 12) (feedStrategy 1 32 0) the total amount of the food the agents have to eat is 32. This should be substracted from the storage beginning with the oldest storage. I make sure before this point of time that the amount2eat is smaller than the amount stored facts all together. Cann i somehow change these 12 facts in a loop? -- Bogdan Werth Doctoral Researcher Centre for Policy Modelling The Graduate School of Business Aytoun Building Aytoun Street Manchester M1 3GH UK Tel: +44 161 247 6481 Fax: +44 161 247 6802 Email: [EMAIL PROTECTED] Web: http://cfpm.org/~bogdan ** Before acting on this email or opening any attachments you should read the Manchester Metropolitan University's email disclaimer available on its website http://www.mmu.ac.uk/emaildisclaimer *** 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]