Skip to content

Commit

Permalink
Added fields for activation scheme and fixed issue with navigation ev…
Browse files Browse the repository at this point in the history
…aluation code being hard-coded to acyclic networks.
  • Loading branch information
jbrant committed Jan 24, 2019
1 parent b6a96f0 commit 3e30dcf
Show file tree
Hide file tree
Showing 18 changed files with 8,896 additions and 30 deletions.

Large diffs are not rendered by default.

Binary file not shown.
3 changes: 3 additions & 0 deletions ExperimentEntities/ExperimentDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ public ExperimentDictionary()
public Nullable<double> Primary_Maze_VerticalWallBias { get; set; }
public Nullable<int> Primary_Maze_QuadrantHeight { get; set; }
public Nullable<int> Primary_Maze_QuadrantWidth { get; set; }
public string Primary_ActivationScheme { get; set; }
public Nullable<int> Primary_ActivationIters { get; set; }
public Nullable<double> Primary_ActivationDeltaThreshold { get; set; }

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<NoveltyExperimentOrganismStateData> NoveltyExperimentOrganismStateDatas { get; set; }
Expand Down
33 changes: 32 additions & 1 deletion ExperimentEntities/ExperimentModel.edmx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<Property Name="MinWidth" Type="int" />
<Property Name="MaxWidth" Type="int" />
<Property Name="MeanWidth" Type="float" />
<Property Name="MinJunctures" Type="int" />
<Property Name="MaxJunctures" Type="int" />
<Property Name="MeanJunctures" Type="float" />
<Property Name="MinTrajectoryFacingOpenings" Type="int" />
<Property Name="MaxTrajectoryFacingOpenings" Type="int" />
<Property Name="MeanTrajectoryFacingOpenings" Type="float" />
<Property Name="TotalEvaluations" Type="int" Nullable="false" />
<Property Name="EvaluationsPerSecond" Type="int" />
</EntityType>
Expand Down Expand Up @@ -283,6 +289,7 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n






</Key>
Expand Down Expand Up @@ -327,6 +334,9 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n
<Property Name="Primary_ConnectionProportion" Type="float" Nullable="false" />
<Property Name="Primary_ConnectionWeightRange" Type="int" Nullable="false" />
<Property Name="Primary_SpecieSizeFixed" Type="bit" Nullable="false" />
<Property Name="Primary_ActivationScheme" Type="varchar" MaxLength="50" Nullable="false" />
<Property Name="Primary_ActivationIters" Type="int" />
<Property Name="Primary_ActivationDeltaThreshold" Type="float" />
<Property Name="Primary_Maze_PopulationSize" Type="int" Nullable="false" />
<Property Name="Primary_Maze_NumSpecies" Type="int" Nullable="false" />
<Property Name="Primary_Maze_MutateWallLocationProbability" Type="float" />
Expand Down Expand Up @@ -550,6 +560,9 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n
[ExperimentDictionary_vw].[Primary_ConnectionProportion] AS [Primary_ConnectionProportion],
[ExperimentDictionary_vw].[Primary_ConnectionWeightRange] AS [Primary_ConnectionWeightRange],
[ExperimentDictionary_vw].[Primary_SpecieSizeFixed] AS [Primary_SpecieSizeFixed],
[ExperimentDictionary_vw].[Primary_ActivationScheme] AS [Primary_ActivationScheme],
[ExperimentDictionary_vw].[Primary_ActivationIters] AS [Primary_ActivationIters],
[ExperimentDictionary_vw].[Primary_ActivationDeltaThreshold] AS [Primary_ActivationDeltaThreshold],
[ExperimentDictionary_vw].[Primary_Maze_PopulationSize] AS [Primary_Maze_PopulationSize],
[ExperimentDictionary_vw].[Primary_Maze_NumSpecies] AS [Primary_Maze_NumSpecies],
[ExperimentDictionary_vw].[Primary_Maze_MutateWallLocationProbability] AS [Primary_Maze_MutateWallLocationProbability],
Expand Down Expand Up @@ -916,6 +929,9 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n
<NavigationProperty Name="MCCExperimentExtantNavigatorPopulations" Relationship="ExperimentDataModel.MCCExperimentExtantNavigatorPopulationExperimentDictionary" FromRole="ExperimentDictionary" ToRole="MCCExperimentExtantNavigatorPopulation" />
<Property Name="Primary_Maze_QuadrantHeight" Type="Int32" />
<Property Name="Primary_Maze_QuadrantWidth" Type="Int32" />
<Property Name="Primary_ActivationScheme" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="Primary_ActivationIters" Type="Int32" />
<Property Name="Primary_ActivationDeltaThreshold" Type="Double" />
</EntityType>
<EntityType Name="NoveltyExperimentOrganismStateData">
<Key>
Expand Down Expand Up @@ -1178,6 +1194,12 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n
<Property Name="TotalEvaluations" Type="Int32" Nullable="false" />
<Property Name="EvaluationsPerSecond" Type="Int32" />
<NavigationProperty Name="ExperimentDictionary" Relationship="ExperimentDataModel.MCCExperimentMazeEvaluationDataExperimentDictionary" FromRole="MCCExperimentMazeEvaluationData" ToRole="ExperimentDictionary" />
<Property Name="MinJunctures" Type="Int32" />
<Property Name="MaxJunctures" Type="Int32" />
<Property Name="MeanJunctures" Type="Double" />
<Property Name="MinTrajectoryFacingOpenings" Type="Int32" />
<Property Name="MaxTrajectoryFacingOpenings" Type="Int32" />
<Property Name="MeanTrajectoryFacingOpenings" Type="Double" />
</EntityType>
<Association Name="MCCExperimentMazeEvaluationDataExperimentDictionary">
<End Type="ExperimentDataModel.MCCExperimentMazeEvaluationData" Role="MCCExperimentMazeEvaluationData" Multiplicity="*" />
Expand Down Expand Up @@ -1431,7 +1453,10 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n
<EntitySetMapping Name="ExperimentDictionaries">
<EntityTypeMapping TypeName="ExperimentDataModel.ExperimentDictionary">
<MappingFragment StoreEntitySet="ExperimentDictionary_vw">
<ScalarProperty Name="Primary_MazeQuadrant_Width" ColumnName="Primary_Maze_QuadrantWidth" />
<ScalarProperty Name="Primary_ActivationDeltaThreshold" ColumnName="Primary_ActivationDeltaThreshold" />
<ScalarProperty Name="Primary_ActivationIters" ColumnName="Primary_ActivationIters" />
<ScalarProperty Name="Primary_ActivationScheme" ColumnName="Primary_ActivationScheme" />
<ScalarProperty Name="Primary_Maze_QuadrantWidth" ColumnName="Primary_Maze_QuadrantWidth" />
<ScalarProperty Name="Primary_Maze_QuadrantHeight" ColumnName="Primary_Maze_QuadrantHeight" />
<ScalarProperty Name="Primary_Maze_VerticalWallBias" ColumnName="Primary_Maze_VerticalWallBias" />
<ScalarProperty Name="Primary_Maze_MutateExpandMazeProbability" ColumnName="Primary_Maze_MutateExpandMazeProbability" />
Expand Down Expand Up @@ -1693,6 +1718,12 @@ warning 6002: The table/view 'ExperimentData.dbo.ExperimentDictionary_vw' does n
<EntitySetMapping Name="MCCExperimentMazeEvaluationDatas">
<EntityTypeMapping TypeName="ExperimentDataModel.MCCExperimentMazeEvaluationData">
<MappingFragment StoreEntitySet="MCCExperimentMazeEvaluationData">
<ScalarProperty Name="MeanTrajectoryFacingOpenings" ColumnName="MeanTrajectoryFacingOpenings" />
<ScalarProperty Name="MaxTrajectoryFacingOpenings" ColumnName="MaxTrajectoryFacingOpenings" />
<ScalarProperty Name="MinTrajectoryFacingOpenings" ColumnName="MinTrajectoryFacingOpenings" />
<ScalarProperty Name="MeanJunctures" ColumnName="MeanJunctures" />
<ScalarProperty Name="MaxJunctures" ColumnName="MaxJunctures" />
<ScalarProperty Name="MinJunctures" ColumnName="MinJunctures" />
<ScalarProperty Name="EvaluationsPerSecond" ColumnName="EvaluationsPerSecond" />
<ScalarProperty Name="TotalEvaluations" ColumnName="TotalEvaluations" />
<ScalarProperty Name="MeanWidth" ColumnName="MeanWidth" />
Expand Down
3 changes: 3 additions & 0 deletions ExperimentEntities/ExperimentModel.edmx.diagram
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<EntityTypeShape EntityType="ExperimentDataModel.RunPhase" Width="1.5" PointX="0.75" PointY="11.875" />
<AssociationConnector Association="ExperimentDataModel.FK_MCSExperimentEvaluationData_RunPhase" />
<AssociationConnector Association="ExperimentDataModel.FK_MCSExperimentOrganismStateData_RunPhase" />
<EntityTypeShape EntityType="ExperimentDataModel.MCCExperimentExtantNavigatorPopulation" Width="1.5" PointX="3" PointY="11.875" />
<AssociationConnector Association="ExperimentDataModel.FK_MCCExperimentExtantNavigatorPopulation_RunPhase" />
<AssociationConnector Association="ExperimentDataModel.MCCExperimentExtantNavigatorPopulationExperimentDictionary" />
</Diagram>
<Diagram DiagramId="f3bab535c2fa4fa6ba0a74e76d67658f" Name="Coevolution MCS Experiment Model" ZoomLevel="83" >
<EntityTypeShape EntityType="ExperimentDataModel.ExperimentDictionary" Width="4.375" PointX="6.75" PointY="8.5" IsExpanded="true" />
Expand Down
6 changes: 6 additions & 0 deletions ExperimentEntities/MCCExperimentMazeEvaluationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public partial class MCCExperimentMazeEvaluationData
public Nullable<double> MeanWidth { get; set; }
public int TotalEvaluations { get; set; }
public Nullable<int> EvaluationsPerSecond { get; set; }
public Nullable<int> MinJunctures { get; set; }
public Nullable<int> MaxJunctures { get; set; }
public Nullable<double> MeanJunctures { get; set; }
public Nullable<int> MinTrajectoryFacingOpenings { get; set; }
public Nullable<int> MaxTrajectoryFacingOpenings { get; set; }
public Nullable<double> MeanTrajectoryFacingOpenings { get; set; }

public virtual ExperimentDictionary ExperimentDictionary { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions MCC_Domains/MazeNavigation/BaseMCCMazeNavigationExperiment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ public virtual void Initialize(string name, XmlElement xmlConfig,

// Setup initialization algorithm
_mazeNavigationInitializer.SetAlgorithmParameters(
xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement, AnnInputCount,
AnnOutputCount, NumAgentSuccessCriteria, 0);
xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement,
ActivationScheme.AcyclicNetwork, NumAgentSuccessCriteria, 0);

// Pass in maze experiment specific parameters
// (note that a new maze structure is created here for the sole purpose of extracting the maze dimensions and calculating max distance to target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ public void SetDataLoggers(IDataLogger navigatorEvolutionDataLogger,
/// <summary>
/// Constructs and initializes the maze navigator initialization algorithm (fitness using generational selection).
/// </summary>
/// <param name="xmlConfig">The XML configuration for the initialization algorithm.</param>
/// <param name="inputCount">The number of input neurons.</param>
/// <param name="outputCount">The number of output neurons.</param>
/// <param name="xmlConfig">The XML configuration for the initialization algorithm.</param>
/// <param name="isAcyclic">Flag indicating whether the network is acyclic (i.e. does not have recurrent connections).</param>
/// <param name="numSuccessfulAgents">The minimum number of successful maze navigators that must be produced.</param>
/// <param name="numUnsuccessfulAgents">The minimum number of unsuccessful maze navigators that must be produced.</param>
/// <returns>The constructed initialization algorithm.</returns>
public virtual void SetAlgorithmParameters(XmlElement xmlConfig, int inputCount, int outputCount,
int numSuccessfulAgents, int numUnsuccessfulAgents)
public virtual void SetAlgorithmParameters(XmlElement xmlConfig, bool isAcyclic, int numSuccessfulAgents,
int numUnsuccessfulAgents)
{
// Set the boiler plate parameters
base.SetAlgorithmParameters(xmlConfig, inputCount, outputCount);
base.SetAlgorithmParameters(xmlConfig, isAcyclic);

// Set the static population size
PopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ protected MazeNavigationInitializer()
/// Constructs and initializes the initialization algorithm.
/// </summary>
/// <param name="xmlConfig">The XML configuration for the initialization algorithm.</param>
/// <param name="inputCount">The number of input neurons.</param>
/// <param name="outputCount">The number of output neurons.</param>
/// <param name="isAcyclic">Flag indicating whether the network is acyclic (i.e. does not have recurrent connections).</param>
/// <returns>The constructed initialization algorithm.</returns>
public virtual void SetAlgorithmParameters(XmlElement xmlConfig, int inputCount, int outputCount)
public virtual void SetAlgorithmParameters(XmlElement xmlConfig, bool isAcyclic)
{
// Read NEAT genome parameters
// Save off genome parameters specifically for the initialization algorithm
// (this is primarily because the initialization algorithm will quite likely have different NEAT parameters)
NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);
NeatGenomeParameters.FeedforwardOnly = NetworkActivationScheme.CreateAcyclicScheme().AcyclicNetwork;
NeatGenomeParameters.FeedforwardOnly = isAcyclic;

// Read NEAT evolution parameters
EvolutionAlgorithmParameters = ExperimentUtils.ReadNeatEvolutionAlgorithmParameters(xmlConfig);
Expand Down Expand Up @@ -156,7 +155,7 @@ protected void InitializeAlgorithm(ParallelOptions parallelOptions, List<NeatGen
/// The maximum distance to the target possible.
/// </summary>
protected int MaxDistanceToTarget;

/// <summary>
/// The minimum distance to the target permitted for the navigator to have successfully solved the maze.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ public class NoveltySearchMCCMazeNavigationInitializer : MCCMazeNavigationInitia
/// particular, this sets additional novelty search configuration parameters.
/// </summary>
/// <param name="xmlConfig">The XML configuration for the initialization algorithm.</param>
/// <param name="inputCount">The number of input neurons.</param>
/// <param name="outputCount">The number of output neurons.</param>
/// <param name="isAcyclic">Flag indicating whether the network is acyclic (i.e. does not have recurrent connections).</param>
/// <param name="numSuccessfulAgents">The minimum number of successful maze navigators that must be produced.</param>
/// <param name="numUnsuccessfulAgents">The minimum number of unsuccessful maze navigators that must be produced.</param>
/// <returns>The constructed initialization algorithm.</returns>
public override void SetAlgorithmParameters(XmlElement xmlConfig, int inputCount, int outputCount,
int numSuccessfulAgents, int numUnsuccessfulAgents)
public override void SetAlgorithmParameters(XmlElement xmlConfig, bool isAcyclic, int numSuccessfulAgents,
int numUnsuccessfulAgents)
{
// Set the boiler plate MCC parameters and minimal criterions
base.SetAlgorithmParameters(xmlConfig, inputCount, outputCount, numSuccessfulAgents, numUnsuccessfulAgents);
base.SetAlgorithmParameters(xmlConfig, isAcyclic, numSuccessfulAgents, numUnsuccessfulAgents);

// Read in the behavior characterization
_behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig,
Expand Down Expand Up @@ -109,7 +108,8 @@ public override void InitializeAlgorithm(ParallelOptions parallelOptions, List<N

// Create the genome evaluator
IGenomeEvaluator<NeatGenome> fitnessEvaluator =
new ParallelGenomeBehaviorEvaluator<NeatGenome, IBlackBox>(genomeDecoder, mazeNavigatorEvaluator, SearchType.NoveltySearch, _nearestNeighbors);
new ParallelGenomeBehaviorEvaluator<NeatGenome, IBlackBox>(genomeDecoder, mazeNavigatorEvaluator,
SearchType.NoveltySearch, _nearestNeighbors);

// Only pull the number of genomes from the list equivalent to the initialization algorithm population size
// (this is to handle the case where the list was created in accordance with the primary algorithm
Expand Down Expand Up @@ -182,9 +182,9 @@ public override List<NeatGenome> RunEvolution(out ulong totalEvaluations, uint?
// Add all of the genomes that have solved the maze
viableGenomes.AddRange(
InitializationEa.GenomeList.Where(
genome =>
genome.EvaluationInfo != null &&
genome.EvaluationInfo.ObjectiveDistance < MinSuccessDistance)
genome =>
genome.EvaluationInfo != null &&
genome.EvaluationInfo.ObjectiveDistance < MinSuccessDistance)
.Take(MinSuccessfulAgentCount));

Console.Out.WriteLine("Extracted [{0}] of [{1}] viable genomes in [{2}] evaluations",
Expand All @@ -195,8 +195,9 @@ public override List<NeatGenome> RunEvolution(out ulong totalEvaluations, uint?
// (note that the intuition for doing this after the loop is that most will not have solved)
viableGenomes.AddRange(
InitializationEa.GenomeList.Where(
genome =>
genome.EvaluationInfo != null && genome.EvaluationInfo.ObjectiveDistance > MinSuccessDistance)
genome =>
genome.EvaluationInfo != null &&
genome.EvaluationInfo.ObjectiveDistance > MinSuccessDistance)
.Take(MinUnsuccessfulAgentCount));

// Ensure that the above statement was able to get the required number of unsuccessful agent genomes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<AgentSpecieSizeFixed>True</AgentSpecieSizeFixed>
<MazeSpecieSizeFixed>True</MazeSpecieSizeFixed>
<Activation>
<Scheme>Acyclic</Scheme>
<Scheme>CyclicFixedIters</Scheme>
<Iters>5</Iters>
</Activation>
<GenomeConfig>
<InitialConnectionProportion>1</InitialConnectionProportion>
Expand Down
Loading

0 comments on commit 3e30dcf

Please sign in to comment.