C# Class SharpNeat.Network.NetworkXmlIO

Static class for reading and writing Network Definitions(s) to and from XML.
Mostra file Open project: colgreen/sharpneat

Public Methods

Method Description
GetActivationFunction ( string name ) : IActivationFunction

Gets an IActivationFunction from its short name.

GetNodeType ( string type ) : NodeType

Gets the NodeType for the specified node type string. Note. we use our own type strings in place of Enum.ToString() to provide more compact XML.

GetNodeTypeString ( NodeType nodeType ) : string

Gets the node type string for the specified NodeType. Note. we use our own type strings in place of Enum.ToString() to provide more compact XML.

LoadCompleteGenomeList ( XmlNode xmlNode, bool nodeFnIds ) : List

Reads a list of NetworkDefinition(s) from XML that has a containing 'Root' element. The root element also contains the activation function library that the network definitions are associated with.

ReadActivationFunctionLibrary ( XmlReader xr ) : IActivationFunctionLibrary

Reads an IActivationFunctionLibrary from the provided XmlReader.

ReadAttributeAsNodeType ( XmlReader xr, string attrName ) : NodeType

Read the named attribute and parse its string value as a NodeType.

ReadCompleteNetworkDefinitionList ( XmlReader xr, bool nodeFnIds ) : List

Reads a list of NetworkDefinition(s) from XML that has a containing 'Root' element. The root element also contains the activation function library that the genomes are associated with.

ReadGenome ( XmlNode xmlNode, IActivationFunctionLibrary activationFnLib, bool nodeFnIds ) : NetworkDefinition

Reads a NetworkDefinition from XML.

ReadNetworkDefinition ( XmlReader xr, IActivationFunctionLibrary activationFnLib, bool nodeFnIds ) : NetworkDefinition

Reads a network definition from XML. An activation function library is required to decode the function ID at each node, typically the library is stored alongside the network definition XML and will have already been read elsewhere and passed in here.

Save ( NetworkDefinition networkDef, bool nodeFnIds ) : XmlDocument

Writes a single NetworkDefinition to XML. The XML is returned as a newly created XmlDocument.

SaveComplete ( IList networkDefList, bool nodeFnIds ) : XmlDocument

Writes a list of NetworkDefinition(s) to XML within a containing 'Root' element and the activation function library that the genomes are associated with. The XML is returned as a newly created XmlDocument.

SaveComplete ( NetworkDefinition networkDef, bool nodeFnIds ) : XmlDocument

Writes a single NetworkDefinition to XML within a containing 'Root' element and the activation function library that the genome is associated with. The XML is returned as a newly created XmlDocument.

Write ( XmlWriter xw, IActivationFunctionLibrary activationFnLib ) : void

Writes an activation function library to XML. This links activation function names to the integer IDs used by network nodes, which allows us emit just the ID for each node thus resulting in XML that is more compact compared to emitting the activation function name for each node.

Write ( XmlWriter xw, INetworkDefinition networkDef, bool nodeFnIds ) : void

Writes an INetworkDefinition to XML.

WriteComplete ( XmlWriter xw, IList networkDefList, bool nodeFnIds ) : void

Writes a list of INetworkDefinition(s) to XML within a containing 'Root' element and the activation function library that the genomes are associated with.

WriteComplete ( XmlWriter xw, IList networkDefList, bool nodeFnIds ) : void

Writes a list of INetworkDefinition(s) to XML within a containing 'Root' element and the activation function library that the genomes are associated with.

WriteComplete ( XmlWriter xw, INetworkDefinition networkDef, bool nodeFnIds ) : void

Writes a single INetworkDefinition to XML within a containing 'Root' element and the activation function library that the genome is associated with.

Private Methods

Method Description
NormalizeSelectionProbabilities ( IList fnList ) : void

Normalize the selection probabilities of the provided ActivationFunctionInfo items.

Method Details

GetActivationFunction() public static method

Gets an IActivationFunction from its short name.
public static GetActivationFunction ( string name ) : IActivationFunction
name string
return IActivationFunction

GetNodeType() public static method

Gets the NodeType for the specified node type string. Note. we use our own type strings in place of Enum.ToString() to provide more compact XML.
public static GetNodeType ( string type ) : NodeType
type string
return NodeType

GetNodeTypeString() public static method

Gets the node type string for the specified NodeType. Note. we use our own type strings in place of Enum.ToString() to provide more compact XML.
public static GetNodeTypeString ( NodeType nodeType ) : string
nodeType NodeType
return string

LoadCompleteGenomeList() public static method

Reads a list of NetworkDefinition(s) from XML that has a containing 'Root' element. The root element also contains the activation function library that the network definitions are associated with.
public static LoadCompleteGenomeList ( XmlNode xmlNode, bool nodeFnIds ) : List
xmlNode System.Xml.XmlNode The XmlNode to read from. This can be an XmlDocument or XmlElement.
nodeFnIds bool Indicates if node activation function IDs should be read. If false then /// all node activation function IDs default to 0.
return List

ReadActivationFunctionLibrary() public static method

Reads an IActivationFunctionLibrary from the provided XmlReader.
public static ReadActivationFunctionLibrary ( XmlReader xr ) : IActivationFunctionLibrary
xr XmlReader
return IActivationFunctionLibrary

ReadAttributeAsNodeType() public static method

Read the named attribute and parse its string value as a NodeType.
public static ReadAttributeAsNodeType ( XmlReader xr, string attrName ) : NodeType
xr XmlReader
attrName string
return NodeType

ReadCompleteNetworkDefinitionList() public static method

Reads a list of NetworkDefinition(s) from XML that has a containing 'Root' element. The root element also contains the activation function library that the genomes are associated with.
public static ReadCompleteNetworkDefinitionList ( XmlReader xr, bool nodeFnIds ) : List
xr XmlReader The XmlReader to read from.
nodeFnIds bool Indicates if node activation function IDs should be read. They are required /// for HyperNEAT genomes but not NEAT
return List

ReadGenome() public static method

Reads a NetworkDefinition from XML.
public static ReadGenome ( XmlNode xmlNode, IActivationFunctionLibrary activationFnLib, bool nodeFnIds ) : NetworkDefinition
xmlNode System.Xml.XmlNode The XmlNode to read from. This can be an XmlDocument or XmlElement.
activationFnLib IActivationFunctionLibrary The activation function library used to decode node activation function IDs.
nodeFnIds bool Indicates if node activation function IDs should be read. They are required /// for HyperNEAT genomes but not for NEAT. If false then all node activation function IDs default to 0.
return NetworkDefinition

ReadNetworkDefinition() public static method

Reads a network definition from XML. An activation function library is required to decode the function ID at each node, typically the library is stored alongside the network definition XML and will have already been read elsewhere and passed in here.
public static ReadNetworkDefinition ( XmlReader xr, IActivationFunctionLibrary activationFnLib, bool nodeFnIds ) : NetworkDefinition
xr XmlReader The XmlReader to read from.
activationFnLib IActivationFunctionLibrary The activation function library used to decode node activation function IDs.
nodeFnIds bool Indicates if node activation function IDs should be read. They are required /// for HyperNEAT genomes but not NEAT
return NetworkDefinition

Save() public static method

Writes a single NetworkDefinition to XML. The XML is returned as a newly created XmlDocument.
public static Save ( NetworkDefinition networkDef, bool nodeFnIds ) : XmlDocument
networkDef NetworkDefinition The genome to save.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return System.Xml.XmlDocument

SaveComplete() public static method

Writes a list of NetworkDefinition(s) to XML within a containing 'Root' element and the activation function library that the genomes are associated with. The XML is returned as a newly created XmlDocument.
public static SaveComplete ( IList networkDefList, bool nodeFnIds ) : XmlDocument
networkDefList IList List of genomes to write as XML.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return System.Xml.XmlDocument

SaveComplete() public static method

Writes a single NetworkDefinition to XML within a containing 'Root' element and the activation function library that the genome is associated with. The XML is returned as a newly created XmlDocument.
public static SaveComplete ( NetworkDefinition networkDef, bool nodeFnIds ) : XmlDocument
networkDef NetworkDefinition The NetworkDefinition to save.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return System.Xml.XmlDocument

Write() public static method

Writes an activation function library to XML. This links activation function names to the integer IDs used by network nodes, which allows us emit just the ID for each node thus resulting in XML that is more compact compared to emitting the activation function name for each node.
public static Write ( XmlWriter xw, IActivationFunctionLibrary activationFnLib ) : void
xw System.Xml.XmlWriter
activationFnLib IActivationFunctionLibrary
return void

Write() public static method

Writes an INetworkDefinition to XML.
public static Write ( XmlWriter xw, INetworkDefinition networkDef, bool nodeFnIds ) : void
xw System.Xml.XmlWriter XmlWriter to write XML to.
networkDef INetworkDefinition Network definition to write as XML.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return void

WriteComplete() public static method

Writes a list of INetworkDefinition(s) to XML within a containing 'Root' element and the activation function library that the genomes are associated with.
public static WriteComplete ( XmlWriter xw, IList networkDefList, bool nodeFnIds ) : void
xw System.Xml.XmlWriter XmlWriter to write XML to.
networkDefList IList List of network definitions to write as XML.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return void

WriteComplete() public static method

Writes a list of INetworkDefinition(s) to XML within a containing 'Root' element and the activation function library that the genomes are associated with.
public static WriteComplete ( XmlWriter xw, IList networkDefList, bool nodeFnIds ) : void
xw System.Xml.XmlWriter XmlWriter to write XML to.
networkDefList IList List of network definitions to write as XML.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return void

WriteComplete() public static method

Writes a single INetworkDefinition to XML within a containing 'Root' element and the activation function library that the genome is associated with.
public static WriteComplete ( XmlWriter xw, INetworkDefinition networkDef, bool nodeFnIds ) : void
xw System.Xml.XmlWriter XmlWriter to write XML to.
networkDef INetworkDefinition Network definition to write as XML.
nodeFnIds bool Indicates if node activation function IDs should be emitted. They are required /// for HyperNEAT genomes but not for NEAT.
return void