In this section, we are going to explain in detail the protocols followed in the communication between the server and the libraries. You need to know them when integrating your own library in the toolbox. The evaluation protocol can not be changed. To apply an operator we have implemented two different protocols depending on the library. If neither of them suits your library, you can implement your own.
First, the library sends a byte identifying the type of operation to be performed (1 to
evaluate a solution and 2 to apply an operator). In the ﬁrst case, the server calls the
attendEvaluation() method, in the second one it calls the applyOperator() method. These
methods carry out the request.
The protocol followed for the evaluation does not depend on the library but on the solutions encoding. Binary solutions follow a different protocol: To reduce the exchange of data between the libraries and the server, these solutions are sent compressed. The compression and decompression of the solutions in the server is carried out by the Compactation class of the util package by means of the compact() and decompact() class methods.
The compact() method receives a vector of bytes in which each one of them stores a bit of the binary string. It returns a vector of integers in which each one of them stores 32 bits of the binary solution. This way, the amount of data that must go from the libraries to the server is decreased by a factor of 32. The decompact() method performs the reverse process.
Figure 1: Generic protocol to evaluate solutions.
Figure 2: Protocol to evaluate binary encoded solutions.
First, the library sends the name of the objective function that must be applied, preceded by an integer with the number of characters of that name, so that the server knows how many bytes to read. Then, it sends the length of the solution to be evaluated and a byte identifying the solutions encoding (1 for binary encoding, 2 for integer encoding, 3 for real encoding and 4 for double-precision real encoding). For binary solutions, the next thing to be sent is the number of integers of the compressed solution. Finally, the solution is sent. If it is a binary solution, the server will call the decompact() method to decompress it. After calling the native method MATLABEvaluate(), its result is sent to the library.
The protocol followed in the application of an operator does depends on the library. Figure 3 shows the protocol followed by the jEA library, and Figure 4 shows the protocol followed by the MALLBA library. There are several reasons why the protocols are different. In the jEA library the user is given the possibility of sending MATLAB all the population solutions, the ﬁtness values of all the population solutions, or the solutions received by the operator in the library. However, in MALLBA there is no direct access from the operator to either the population or the ﬁtness values of the solutions; that is why you can only send MATLAB the solutions recived by the operator. Besides, the jEA library sends the operation parameters to the server by means of Java properties. In MALLBA, however, this properties must be sent by means of strings of characters.
Figure 3: Protocol followed in jEA to apply an operator.
Figure 4: Protocol followed in MALLBA to apply an operator.
First, both libraries send a byte with a value 2 to indicate they want to apply an operator. Next, they send the name of the MATLAB function implementing the operator, preceded by an integer with the length of that name. Then, they send a byte indentifying the libray (1 for jEA and 2 for MALLBA). From that moment, each library follows a different protocol.
The jEA library next sends a byte identifying the solutions encoding (1 for binary encoding, 2 for integer encoding and 3 for double-precision real encoding). The next thing it sends is the length of the solutions (for binary solutions it also sends the length of the compressed solution). Then, it sends three bytes indicating the server the data to be sent. If the ﬁrst takes value 1, all the population solutions will be sent; if the second byte takes value 1, the ﬁtness values of all the population solutions will be sent; if the third byte takes value 1, the solutions received by the operator in the library will be sent.
The server will progresively receive the corresponding data, depending on the value of these three bytes. In the ﬁrst case, the library will send the size of the population followed by all the solutions accompanied by their ﬁtness. In the second case, it will send the size of the population followed by the ﬁtness of all the solutions. In the last case, ﬁrst it will send an integer with the number of solutions and then all the solutions accompanied by their ﬁtness value. If the operator has parameters, the ﬁrst time it is applied, the library will send a Properties object containing them.
The MALLBA library also sends in the ﬁrst place a byte identifying the type of solution encoding (1 for binary encoding, 2 for integer encoding and 3 for real encoding) and then it sends an integer with the length of the solutions (if they have a binary encoding, it also sends the length of the compressed solutions). Next, it sends all the solutions. If the operator has parameters, the library ﬁrst sends the number of them, and for each one of them it sends its name and value, preceded by an integer indicating their length, so the server knows how many bytes to read.
Once the server has all the data, he calls the native method MATLABOperate(). This method sends back a vector of Object with a length of ﬁve, as a result of the operator application. The ﬁrst position of that vector contains the number of returned solutions, the second one is a vector of Object containing the evaluable part of all the returned solutions. The following two positions will only have some content when you are working with evolutionary strategies and, in that case, they will contain the strategic parameters (standard deviations and angles) of the returned solutions. The vector last position contains a vector of double with the ﬁtness values of all the returned solutions.
The way in which the result of the operator application is returned also varies from one library to the other. The jEA library is sent the whole vector returned by MATLABOperate() after compressing the solutions, in case a binary encoding is being used. In the MALLBA library, all the solutions are sent in succession (if binary encoding is being used, they are sent compressed). It is not necessary to indicate the library the number of solutions to be sent because in MALLBA the operators return the same number of solutions they receive.