Optimization : Optimization Namespace

Connection Class

Master connection class.

public class Connection

Remarks

This class manages the connection from the optimizer to the master. It implements some convenient methods for sending and receiving protobuf messages. Receiving messages is done asynchronously and when new messages have been received, the Connection.OnCommunicationReceived will be fired. Note that event handlers will run in the receive thread and not the main thread and care should be taken to prevent problems with accessing data from multiple threads. This class has a convenient method to send all the solutions of the current iteration of a job at once (Connection.Send``1(Job<``0>)).

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Members

See Also: Inherited members from object.

Public Constructors

Create new connection.

Public Methods

Connect (string, int) : bool
Connect to the master process.
Disconnect ()
Disconnect connection.
FitnessType (Fitness.Mode) : Optimization.Messages.Identify.Fitness.Type
Get a fitness type from a fitness mode.
Identify (Job) : bool
Identify a job to the optimaster.
Progress (Job) : bool
Sends a progress report to the master.
Send (Job) : bool
Send all solutions in a job as a batch to the master.
Send (Optimization.Messages.Communication) : bool
Send communication message to the master.

Public Events

OnClosed Fired when connection is closed.
OnCommunicationReceived Fired when new communication is received.

Member Details

Connection Constructor

Create new connection.

public Connection ()

Remarks

Create new connection.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Connect Method

Connect to the master process.

public bool Connect (string host, int port)

Parameters

host
The master host.
port
The master port.

Returns

true if a connection is established, false otherwise.

Remarks

Create a new connection to the master process.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Disconnect Method

Disconnect connection.

public void Disconnect ()

Remarks

Disconnect connection.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

FitnessType Method

Get a fitness type from a fitness mode.

Parameters

mode
The fitness mode.

Returns

The fitness type.

Remarks

Get a fitness type from a fitness mode.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Identify Method

Identify a job to the optimaster.

public bool Identify (Job job)

Parameters

job
The job.

Returns

Whether the job could be successfully identified.

Remarks

Identifies the given job to the master.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

OnClosed Event

Fired when connection is closed.

public event EventHandler OnClosed

Remarks

Fired when the connection to the master process is closed.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

OnCommunicationReceived Event

Fired when new communication is received.

public event Connection.CommunicationReceivedHandler OnCommunicationReceived

Remarks

Fired when new communication messages have been received. Note that event handlers will run in a separate thread and not on the main thread. Care should be taken in accessing data from multiple threads.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Progress Method

Sends a progress report to the master.

public bool Progress (Job job)

Parameters

job
The job.

Returns

Whether the progress report was successfully sent.

Remarks

Sends a progress report to the master.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Send Method

Send all solutions in a job as a batch to the master.

public bool Send (Job job)

Parameters

job
The job.

Returns

true if the batch was send successfully, false otherwise.

Remarks

Send all the solutions in the current population of the optimizer of the supplied job as a batch message to the master.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)

Send Method

Send communication message to the master.

public bool Send (Optimization.Messages.Communication communication)

Parameters

communication
Communication message to send.

Returns

true if the message was send successfully.

Remarks

Send a communication message to the master process.

Requirements

Namespace: Optimization
Assembly: Optimization (in Optimization.dll)