I think Xavier Noria wrote:
> I'm reading Jess' manual to get an idea about how it works and whether 
> it would be of interest in an agent-based simulation we are developing.

You could also do a web search on "JADE and Jess" as many people have
already used Jess with that popular agent framework.

> 
> We are writing a prototype in Java, the idea is that Jess would be used 
> to implement part of the behavior of agents somehow. Everything is new 
> for me and don't see clearly if one can program this way:
> 
>     Market music = new Market();
>     // code that fills market with products, participants, etc.
> 
>     Consumer consumer = new Consumer();
>     consumer.setIncome(1500);
> 
> Now fire a Jess rule on those instances like this
>   
>     if consumer's income is > 1200 then invoke
>     invoke consumer.buyInMarket(music)

You have lots of choices for implementing this, but one version of
this, making liberal assumptions, might look something like

(bind ?consumer (new Consumer))
(?consumer setIncome 1500)
(defclass consumer Consumer)
(definstance consumer ?consumer static)

(defrule rule-1
        (consumer (income ?i&:(> ?i 1200)) (OBJECT ?c))
        (music ?m)
        =>
        (bind ?set (?c buyInMarket ?m)))
> 
> which eventually would change consumer's state after that, and retrieve 
> the value returned by that method, which would be in this hypothetical 
> example a java.util.Set of objects of type Product.
> 
> If that's possible, are there any restrictions on the kind of objects 
> that can be shared between Java and Jess, methods to invoke, or return 
> types?
> 

Objects that can be directly pattern-matched have to look like Java
Beans -- i.e., Jess matches "properties" consisting of getX, setX
method pairs. THe very best kind of object for pattern-matching is a
Java Bean which sends PropertyChangeEvents, because Jess can then
automatically track changes that happen externally. Alternatively,
there's a method you can call to tell Jess when an object changes.

Jess can work with any Java object and call any Java method
(multidimensional array arguments are a problem that requires a
special workaround.) It's easy to pass Java objects between Jess and
Java code.


> Thank you!
> 
> -- fxn

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        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]
--------------------------------------------------------------------

Reply via email to