PROLOG problems


Title of project:
Implicit coordination in distributed systems

Partners: Pierre Dillenbourg (TECFA), Ion Dumitrache (POLITEHNICA), Catalin Buiu (POLITEHNICA),
Cristian Ceconvciuc (POLITEHNICA)


Contents:

1. Read from socket.
2. Design problems.
3. Extract function.
4. Memory problems.


1. Read from socket

    There is in PROLOG the socket functions which connect, write and read with. The steps from agents are:
 
No
Function Observation
1
connect(host,port,ClientSocket) Connect to the MOO: host is 'tecfamoo.unige.ch', port is 7777 and ClientSocket is a variable
2
write_sock(ClientSocket, string_to_write) Write via socket something to MOO
3
read_sock(ClientSocket, read_string) Read something from the MOO via socket
    The problem was that: if there is nothing to read  from socket the program wait until there is something. That was bad, because the program was stopped in the main cycle!
    The solution proposed for that inconvenient was the following (in qloopread(Q) from fchain_h.txt, for example): after the agent read the agent write to the socket a command which say to the agent STOP reading. The code is something like that:
- send the command STOP read i.e. use the 'page' command to page himself that;
- repeat reading until the STOP read command is asserted;
(see fchain_h.txt for example, function qloopread(Q)).



 

2. Design problems

    In sock_writeln(ClinetSocket,Message) and sock_readln(ClientSocket,Answer) PROLOG functions Message and Answer variable are string ASCII code type. Facts who are asserted by agents are atom type. When I want to give some advice to the other agent I assert one fact like this: fact(advice('page sherlock something')). After that I call fact(advice(Q)) and transform Q in ASCII code with name(Q,QQ) function and send QQ to the MOO.
    All that is because I can't write Message or Answer called write(Message) function (the result is an ASCII list of contents of Message), but I can write 'page sherlock something' (QQ is like this: "page sherlock something"). Now you can see normally what the agents facts are exchanged... (in the agents log files).
    Another design problem was the communication between agents and between agent and MOO, because was necessary to make a difference between MOO facts and Agent facts. The agent send facts who contain the name of the agent who send them (see example communication between Hercule and Sherlock)



 

3. Extract function

    From one string received from the MOO I made the extraction function which extract different facts or goals who are sending by the MOO or by the other agent. I made the difference between MOO and the other agent facts and goals, because it's important for inference part to know which one send something: the MOO or the other agent. The example for that is in qextract1.txt and qextract2.txt (which are included support.txt file).



 
 
4. Memory problems

    I had also some problem with Prolog memory, because there are many facts asserted who keep memory space occupied, but I found a solution for that:
- I allocated more memory for both agents (16M as heap memory for each agents);
- I used some Prolog instructions who minimized the memory space like 'garbage_collect' which is called one time per main cycle;
- I allocated more less goals for the agents - it seems that they keep a lot of memory and there is some kind of restrictions for goals.



Cristian Ceconvciuc  

Last updated: Dec. 16, 1997