Upgrade structure of code base
This commit is contained in:
@@ -1,23 +1,26 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.Utils.RandomEngines;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Nullary;
|
||||
|
||||
public partial class NormalDistributionModule : NullaryComputationalModule, IParameterizedModule
|
||||
public partial class NormalDistributionModule : NullaryComputationalModule,
|
||||
IParameterizedModule,
|
||||
IDuplicateOutputModule
|
||||
{
|
||||
private HashSet<DataOutPort> OutputGroup { get; set; } = new();
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
public override IEnumerable<IBasePort> Ports => base.Ports.Union(DataOutPorts);
|
||||
private IDoubleParameter? Mu { get; set; }
|
||||
private IDoubleParameter? Sigma { get; set; }
|
||||
|
||||
@@ -25,27 +28,24 @@ public partial class NormalDistributionModule : NullaryComputationalModule, IPar
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
|
||||
OutputGroup = new HashSet<DataOutPort>(new[] { Output1, Output2, Output3, Output4 });
|
||||
foreach (DataOutPort port in OutputGroup)
|
||||
port.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.DataOutInit("Output", 4);
|
||||
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
||||
Mu = GlobalProvider.DataStructureProvider!.NewDoubleParameter("mu", -1, 1, 0);
|
||||
Sigma = GlobalProvider.DataStructureProvider.NewDoubleParameter("sigma", 0, 2, 1);
|
||||
ConfigurableParameters = new HashSet<IConfigurableParameter> { Mu, Sigma };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IRootModule root)
|
||||
public override void Define()
|
||||
{
|
||||
foreach (DataOutPort port in OutputGroup)
|
||||
foreach (IDataOutPort op in DataOutPorts)
|
||||
{
|
||||
port.ResultData.Real = Normal.Get() * Sigma.ParameterValue - Mu.ParameterValue;
|
||||
op.OutData.UpdateCalculation(x =>
|
||||
(Normal.Get() * Sigma!.ParameterValue - Mu!.ParameterValue, EnigmosConstant.DataPortTypes.Real)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user