Hi Javed,
I see a number of problems with your example code that you might want to check.
1) In the AgentReceiver agent you define an attribute with supposedly an initial value:
public boolean docsPrepared=false;
This is not allowed in Brahms. You should be getting a parser and compiler error for this. Didn't you? What editor are you using?
An agent is NOT an object. An agent has a belief-set to hold its beliefs, whereas an object has members that have only one value.
To set an "initial value for an attribute" you have to give the agent an initial belief. Here is how you do that:
initial_beliefs:
(current.docsPrepared = false);
This creates a belief for the AgentReceiver agent at initialization. The belief will be:
(AgentReceiver.docsPrepared = false);
Note that the initial_beliefs section comes AFTER the definition of attributes and relations and before the activities section.
Note that the agent AgentReceiver is substituted for current in the initial belief. The symbol current is like the symbol this in Java, it is the agent itself.
Also note that this is NOT the same as the belief (AgentSender.docsPrepared = false). This is important for the next point.
2) About the error you are getting about the variable stf not having any binding.
You are getting this error because you are using the stf variable in a conclude statement, but this variable has NO binding during runtime. Variables need to be bound to concepts before you can use them as a parameter. Most of the time you bind a variable in a precondition of a workframe (or thoughtframe). Here is an example workframe:
group Test memberof SystemGroup {
attributes:
public boolean docsPrepared;
initial_beliefs:
(current.docsPrepared = true);
}
agent MyTestAgent memberof Test {
workframes:
workframe example {
variables:
foreach(Test) stf;
when ((stf.docsPrepared = true))
do {
SubmitDocuments(stf);
}
}
}
2a) I think you are having trouble with the notion of beliefs of an agent. It seems that you want to have the AgentSender agent communicate his belief that it has prepared the documents. Note that an agent can ONLY communicate a belief if it actual has this belief in its belief set (i.e. this is similar to you cannot tell me something you don't know). Therefore, you first need to make sure that the AgentSender agent has the belief that you want to communicate.
Let's say the belief you want to communicate is (AgentSender.docsPrepared = true). Then you first need to make sure that AgentSender has this belief. Your workframe DocumentSubmission tests on your agent having this belief in its precondition:
when(knownval(current.documentsPrepared = true))
That is good. By the way, you can leave out the "knownval" and simply write:
when((current.documentsPrepared = true))
That is a little simpler. However, the problem is that your AgentSender will never get the belief (AgentSender.documentsPrepared = true) and thus this workframe will never fire. This is a problem. The best way to do this is to give this agent also an initial belief, but then with the value true. So, you should add the following to the AgentSender agent:
initial_beliefs:
(current.docsPrepared = true);
This will make sure the agent gets the belief (AgentSender.documentsPrepared = true) at initialization. This allows the agent to match this belief to the precondition in the workframe DocumentSubmission, and then execute the workframe.
2b) Not binding the variable stf. You are defining the variable in the workframe, but you are not using it in a precondition. Therefore, the variable doesn't get a binding. As a matter of fact, that is why you get the error. Also, you define the variable of the type SystemGroup. However, none of your agents seem to be members of SystemGroup. Thus, even if you would use it in a precondition, the variable would not be bound (unless you make the agents members of SystemGroup).
I think you can simply delete the variable from the workframe and also delete the conclude statement. Then you simply pass "current" to the communication activity. So, your workframe should look something like this:
workframe DocumentSubmission{
when((current.documentsPrepared = true))
do {
SubmitDocuments(current);
}
}
2c) Communicating the belief. Now that you have the AgentSender agent communicate its belief to the AgentReceiver agent, the AgentReceiver needs to act on this belief. I assume that you want the AgentReceiver to execute the workframe test and the test() activity. However, this will not happen in the way you wrote the workframe. Here is why.
Remember that the precondition of the workframe test is:
when(knownval(current.documentsPrepared = true))
This precondition matches on the belief (AgentReceiver.documentsPrepared = true), but it should be matching on the belief that is communicated by the AgentSender, which is (AgentSender.documentsPrepared = true).
Therefore, you should change the workframe test as follows:
workframe test {
when(knownval(AgentSender.docsPrepared=true))
do {
test();
}
}
This means that you don't need to the initial belief for the AgentReceiver.
3) Notice that I deleted the "repeat = true" from the workframes. Be careful with repeat = true. This creates an endless loop really easily, especially with workframes that are at the "top level" (meaning that they are not within a composite activity). Your workframes are at the "top level."
So, this is a long winded answer to your seemingly simple question. However, your model seems to have multiple issues. I don't believe your model every executed and I wonder how you got the error, because your model has syntax errors in it. I think it would be good for you to look at the tutorial examples. Have you done that? You can look at
https://www.ejenta.com/docs/documentation/tutorial/tt_intro
I hope it helps.
Maarten.