Thanks by the help.
But, it gives me the impression of the fact that the active modules are not active, but "passive", since:
- Therefore I have proven, an active module can't have a predicate "main/0" or "main/1" (and if it has, not serves to him as nothing because upon starting the active module, the the "main" predicate is not executed).
- All the agents (active modules) on started are listening on its port to the arrival of some message.
- Because the two previous reasons, I must to have a single agent that make the paper of "initiador", the one which can have defined the predicate "main". This initiator passes a message to the "agentI", later on the "agentI" calls to the "agentJ", and so on.
What mean with this, is that IN ALL MOMENT CAN HAVE 1 COMMUNICATION (AMONG 2 AGENTS); IT'S IMPOSSIBLE THAT, FOR EXAMPLE, THEY HAPPEN THESE 3 COMMUNICATIONS SIMULTANEOUSLY: agent1-------->agent5 agent3<--------agent12 agent9<--------agent7
I am in what is certain?
Something else: Could I use the Module Qualification instead of the Higher Order? That is to say, to use send(I, Message, Receiver) :- Receiver:receive(Message, I). instead of send(I, Message, Receiver) :- Receiver(Message, I).
Finally, you said me that you probed the code that I sent (with you modifications). Could you give me the source code (the ".pl" files) that you have proven?
__________________________________________________ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/
it gives me the impression of the fact that the active modules are not active, but "passive",
In some sense, yes. They were thought primarily as modules, which act as servers of their code: like any other application module, they are only "activated" when their exported predicates are called. The difference with standard modules is that they can be called remotely.
Therefore, you need a main program for the main entry point: the initiator you mention. Thus, you cannot, in principle, have simultaneous calls between agents. For simultaneity, you will have to use concurrency, i.e., threads. The calls from the initiator to the different agents can be done in a separate thread, so that you avoid having to wait for an agent to finish serving its main call in order to make the main call of the next agent.
That is one possibility. If you want the "main" of an agent to simply do some initialization and then start listening, then the initialization directive would be more convenient. If you want those "main" for the agents to "act" then the above solution based on threads will make them start acting simultaneously.
Now, you will have agents acting and calling each other, but they won't be answering to each other calls (since each of them is busy with its own main call). If you want the agents to act and, simultaneously, also answer, then you need separate threads for acting and for answering in each agent.
You can have each active module starting a separate thread for executing its main call, which is initiated by the first message received (from the initiator), and leave the main thread for listening to other messages and serving them. Messages will be served one-at-a-time, by the "answering" thread. But the main call will still proceed independently, in its own "acting" thread.
Moreover, if required, you can also make the two threads of an agent communicate with each other by asserting and retracting the so called "concurrent facts". You can in this way reason in the main thread with respect to what is "deduced" during the processing of the messages received in the other thread.
Something else: Could I use the Module Qualification instead of the Higher Order?
Nop. It won't work with active modules.
Could you give me the source code (the ".pl" files) that you have proven?
Sure. Please, find them in the attached zip file. Remember they need a "webbased_server" running to work properly. You can find one in the library directory actmods/examples in the Ciao distribution. Also, to setup this server (and make the whole thing work) you have to properly change the library file actmods/webbased_common.pl.
Hope this helps.
Paco Bueno