The GAF Evaluation Server
The GAF Evaluation Server is a simple network server that can perform GA evaluations. The product can be installed on any number of machines and allows the evaluation of a GA to be distributed across the network. The server can also be used with container orchestration such as Docker Swarm.
In order to use the GAF Evaluation Server the GAF.Network NuGet package should be added to an existing GAF project.
PM> Install-Package GAF.Network
This section is currently being updated to include examples of using Docker and Docker Swarm mode (16 November 2017).
GAF.Network NuGet Package
The GAF.Network package is used to provide basic TCP/IP networking functionality. The package provides a network wrapper for the GeneticAlgorithm class allowing a network client to be created using only a couple of lines of code. The package can be installed using the Package Manager console.
PM> Install-Package GAF.Network
For example, where the standard code for running a non-networked GA is as follows;
The networked version of the code, would be something like the following where endpoints was a List<IPEndpoint> containing IP:Port addresses of the GAF Evaluation server(s) and concurrency represents the number of concurrent connections to each endpoint.
var endpoints = new List<IPEndpoint>(); var concurrency = 1; endpoints.Add (NetworkWrapper.CreateEndpoint ("192.168.1.91:11000")); endpoints.Add (NetworkWrapper.CreateEndpoint ("192.168.1.92:11000")); var networkWrapper = new NetworkWrapper (ga, endpoints, "Example.IRemoteFitness.dll", concurrency); networkWrapper.GeneticAlgorithm.Run (TerminateAlgorithm);
For the GAF Evaluation Servers to perform an evaluation, the fitness function needs to exist on each server. To accomplish this, the Fitness Function is placed in a separate assembly within a class that implements the IFitness interface. Typically this assembly would be deployed to the servers using standard configuration and deployment tools.
Please see the article Implementing IRemoteFitness for details of how to create an assembly for the fitness function.
Configuring the GAF Evaluation Server
In the Docker based examples shown in the article Evaluating on a Network of Computers, the GAF Evaluation was pre-configured using the GAF.Evaluation.exe.config file. An example of the file is shown below.
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="server" type="GAF.EvaluationServer.Configuration.ServerSection, GAF.EvaluationServer, Version=188.8.131.52, Culture=neutral" /> </configSections> <server> <fitness assemblyName="Fitness.dll" /> </server> <system.diagnostics> <trace autoflush="true" indentsize="4"> <listeners> <add name="consoleListener" type="System.Diagnostics.ConsoleTraceListener" /> <remove name="Default" /> </listeners> </trace> <switches> <add name="TraceLevelSwitch" value="3" /> </switches> </system.diagnostics> </configuration>
The configuration file includes a single custom section called <server/>. Within this section the example shows the <fitness> setting. In the above example this is pointing to a fitness assembly called Fitness.dll, this can point to any assembly that contains a class that implements the IRemoteFitness interface. This assembly should be in the same folder as the server and would typically be deployed using standard configuration and deployment tools such as Ansible. See #Remote Fitness.
Specifying the Listening Endpoint
When the GAF Evaluation Server is launched, it will automatically listen on the primary IP address of the server machine (port 11000). If this is unsuitable, the endpoint can be set explicitly with the _-endpoint_ option, for example, using Mono on OSX or Linux
# mono GAF.EvaluationServer.exe -endpoint:192.168.90:11000
> GAF.EvaluationServer.exe -endpoint:192.168.90:11000
A Complete Example
The article Evaluating on a Network of Computers, shows a full example with code.