Optimization : Optimization Namespace

Solution Class

Optimization solution class.

public class Solution : ICloneable

Remarks

The optimziation solution class represents a single solution, (or individual in GA terms) in the population of solutions in the optimizer. It consists of an id (Solution.Id), a set of parameters (Solution.Parameters), a fitness (Solution.Fitness) and a set of additional user defined data (Solution.Data).

If needed, you can subclass the solution class to define your own kind of solution class, which can be convenient if you would like to put some of the logic of your optimization algorithm in the solution class. The optimizer will automatically find any subclass of the solution class and use it automatically to create new solutions. If you however need explicit control over which solution class to use, you should override Optimizer.CreateSolution. The solution class implements the ICloneable interface which makes a deep copy of the solution. If you subclass the solution class, make sure you to override the Solution.Clone method to create a new solution of your subclass. Furthermore, make sure to call Solution.Copy on the new object to ensure the solution correctly copies over its data from the original solution. If you need your class to be able to be subclassed, you should implement this copy mechanism too.

Requirements

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

Members

See Also: Inherited members from object.

Public Constructors

Create new solution.
Create new solution.

Public Properties

[read-only]
Data Dictionary<string, object> . User defined data.
[read-only]
Fitness Fitness . The fitness.
Id uint . The id.
Parameters List<Parameter> . List of solution parameters.
[read-only]
State State . Get solution optimization state.

Public Methods

Add (Parameter)
Add a new parameter to the solution.
Add (string, double, double) : Parameter
Add a new parameter to the solution.
Clone () : object
Clone (deep copy) the current solution.
Copy (Solution)
Copy data from another solution.
FromStorage (Optimization.Storage.Storage, Optimization.Storage.Records.Optimizer, Optimization.Storage.Records.Solution)
Restore solution from storage.
Remove (string)
Remove parameter specified by name.
Reset ()
Reset all parameters to random initial values.
override
ToString () : string
Solution in string representation.
Update (Dictionary<string, double>)
Update the fitness of the solution.

Member Details

Solution Constructor

Create new solution.

public Solution ()

Remarks

Create a new stub solution. Generally you don't use this function, but the Solution(uint, Fitness, State) constructor instead.

Requirements

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

Solution Constructor

Create new solution.

public Solution (uint id, Fitness fitness, State state)

Parameters

id
The solution id.
fitness
The fitness template.
state
The optimization state.

Remarks

Create a new solution. This is usually called from the optimizer to create a new solution. The supplied fitness object should be used to update and evaluate the solution fitness. The state contains state information for the optimization of which the solution is a part.

Requirements

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

Add Method

Add a new parameter to the solution.

public virtual void Add (Parameter parameter)

Parameters

parameter
Parameter.

Remarks

Add a new parameter to the solution.

Requirements

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

Add Method

Add a new parameter to the solution.

public Parameter Add (string name, double min, double max)

Parameters

name
Parameter name.
min
Parameter minimum value.
max
Parameter maximum value.

Returns

The new parameter object.

Remarks

Add a new parameter to the solution given a name and parameter value boundaries. This creates a new parameter object and adds it to the current list of parameters for this solution.

Requirements

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

Clone Method

Clone (deep copy) the current solution.

public virtual object Clone ()

Returns

The new, cloned solution.

Remarks

Create a deep copy of the solution. Subclasses must override this and create a new solution object based on the subclass. They should then call Solution.Copy and return the new object. If the subclass has reference type data of its own it should also override Solution.Copy and in it copy its own data. Make sure to call Solution.Copy on the base class if you do.

Requirements

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

Copy Method

Copy data from another solution.

public virtual void Copy (Solution other)

Parameters

other
The solution to copy from.

Remarks

Copy the data from another solution. This copy should be a deep copy of all reference data. This method is called from the Solution.Clone method and should be overriden in subclasses if they have their own data to copy (see Solution.Clone for more information)

Requirements

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

Data Property

User defined data.

public Dictionary<string, object> Data { get; }

Value

User defined data dictionary.

Remarks

Get or set user defined data in the solution. User defined data will normally be saved along with the results, and it is the preferred way of saving extra data. Additionally, any data that is send in a Optimization.Messages.Response from the master will also be stored in this dictionary.

Requirements

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

Fitness Property

The fitness.

public Fitness Fitness { get; }

Value

The fitness object.

Remarks

The solution fitness.

Requirements

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

FromStorage Method

Restore solution from storage.

Parameters

storage
The storage.
optimizer
The optimizer storage record.
solution
The solution storage record.

Remarks

Restore the solution state from storage.

Requirements

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

Id Property

The id.

public uint Id { set; get; }

Value

The solution id.

Remarks

The solution id.

Requirements

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

Parameters Property

List of solution parameters.

public List<Parameter> Parameters { set; get; }

Value

List of parameters.

Remarks

List of solution parameters.

Requirements

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

Remove Method

Remove parameter specified by name.

public virtual void Remove (string name)

Parameters

name
Parameter name.

Remarks

Removes a parameter specified by name.

Requirements

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

Reset Method

Reset all parameters to random initial values.

public virtual void Reset ()

Remarks

Reset all the parameters to random initial values within their respecitive boundaries.

Requirements

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

State Property

Get solution optimization state.

public State State { get; }

Value

Optimization state.

Remarks

Get solution optimization state.

Requirements

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

ToString Method

Solution in string representation.

public override string ToString ()

Returns

String representation of the solution.

Remarks

Convenient human readable string representation of a solution.

Requirements

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

Update Method

Update the fitness of the solution.

public virtual void Update (Dictionary<string, double> fitness)

Parameters

fitness
New solution fitness values.

Remarks

This updates the fitness of the solution and is usually called by the optimization application when a solution has been evaluated successfully and its fitness has been received.

Requirements

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