No problem.  I was more concerned for my sanity than I was requiring
the functionality.  Appreciate the look-see.

On Oct 17, 2008, at 7:25 AM, Ernest Friedman-Hill wrote:


Unfortunately accumulate handles only single patterns right now, not
groups like the "and" you've used below. Using a group will not give
an error message in most cases -- you'll just get a broken rule,
which is what's happening here.


On Oct 16, 2008, at 2:01 PM, Hal Hildebrand wrote:

(defrule allocate-resource
   (declare (auto-focus TRUE))
   (DOMAIN::group (id ?group) (unit-cpu ?unit-cpu) (unit-memory ?
unit-memory))
   ?deployment-state <- (DOMAIN::deployment-state
       (placement-strategy ?strategy) (placmeent-type ?type) (id ?
state)
       (plan ?plan) (current-cpu ?current-cpu) (current-memory ?
current-memory))
   (DOMAIN::host-association (host ?host) (state ?state))
   (DOMAIN::deployment-plan (id ?plan) (group ?group)
       (maximum-memory ?maximum-memory&:(<= (+ ?current-memory ?
unit-memory) ?maximum-memory))
       (maximum-cpu ?maximum-cpu&:(<= (+ ?current-cpu ?unit-cpu) ?
maximum-cpu))
       {minimum-memory <= maximum-memory && minimum-cpu <= maximum-
cpu}
       {(minimum-memory > ?current-memory) || (minimum-cpu > ?
current-cpu)})
   ?candidate <- (DOMAIN::host-resources (id ?candidate) (host ?host)
       (available-memory ?available-memory&:(>= ?available-memory ?
unit-memory))
       (available-cpu ?available-cpu&:(>= ?available-cpu ?unit-cpu)))
   ?host-resources <- (accumulate
       (bind ?resources new jess.ValueVector)
       (?resources add ?r)
       ?resources
       (and
           (DOMAIN::host-association (host ?h) (state ?state))
           (DOMAIN::host-resources (id ?r)  (host ?h))
           )
       )
   =>
   (bind ?resource (select-resource ?candidate ?unit-cpu ?unit-
memory (accumulate-resources ?host-resources) ?strategy ?type))
   (modify ?resource
       (available-memory (- (fact-slot-value ?resource available-
memory) ?unit-memory))
       (available-cpu (- (fact-slot-value ?resource available-cpu) ?
unit-cpu)))
   (assert (DOMAIN::resource (host ?host) (plan ?plan) (memory ?
unit-memory) (cpu ?unit-cpu)))
   (modify ?deployment-state
       (current-cpu (+ ?current-cpu ?unit-cpu)) (current-memory (+ ?
current-memory ?unit-memory)))
   )

The variable ?host-resources is the one which is remains
undefined.  Note that if ?candidate is set, the accumulated set
should have at least 1 member...

On Oct 16, 2008, at 10:54 AM, Ernest Friedman-Hill wrote:

Well, off the top of my head, this should only happen if the
accumulate is in an "or", and the rule is firing on a branch not
containing the accumulate.

Can I see the rule?



Under what circumstances with the accumulate CE not set the
variable?
For example:

?var <- (accumulate ....)

When will ?var not be set?

What I'm seeing is that I'm using accumulate as the last pattern on
the LHS of a rule.  The rule is evaluated and I'm using the
variable
assigned to the result of the accumulate CE and Jess is throwing
the
exception "No such variable var".  As you can imagine, this is
driving
me rather batty trying to figure out what I'm doing wrong...


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

---------------------------------------------------------
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 [EMAIL PROTECTED]
'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
.
--------------------------------------------------------------------



---------------------------------------------------------
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
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
.
--------------------------------------------------------------------




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

Reply via email to