public ConnectionWeightSystem(IIntegrator integrator, DynamicalSystem existingSystem) : base(integrator) { this.SourceSystem = existingSystem; // Generate connection weight nodes for all connections in the incoming system. var links = existingSystem .Nodes .SelectMany(n => n.IncomingNodes) .Where(c => c.From is NeuralOscillatorNode && c.To is NeuralOscillatorNode) .Where(c => c.Plasticity > 0 || c.Decay > 0); Debug.Assert(links.Count() == links.Distinct().Count()); List <NeuralOscillatorConnectionNode> weightNodes = new List <NeuralOscillatorConnectionNode>(); foreach (var link in links) { NeuralOscillatorConnectionNode weightNode = new NeuralOscillatorConnectionNode(0, link); weightNodes.Add(weightNode); } _weightNodes = weightNodes; this.Nodes = weightNodes; }
void updateIntegratorSettings(ClassDefinition ast, IIntegrator integrator) { var annot = ast.Elements.FirstOrDefault(e => e is Annotation) as Annotation; if (annot != null) { var experiment = annot.Modification.Modifications.FirstOrDefault(m => m.Reference.ID == "experiment"); if (experiment != null && experiment.Modification != null) { foreach (var mod in experiment.Modification.Modifications) { if (mod.Reference.ID == "StopTime") { integrator.EndTime = mod.Modification.Value.Evaluate(); } if (mod.Reference.ID == "Interval") { integrator.StepSize = mod.Modification.Value.Evaluate(); } if (mod.Reference.ID == "Tolerance") { integrator.Tolerance = mod.Modification.Value.Evaluate(); } if (mod.Reference.ID == "MinInterval") { integrator.MinStepSize = mod.Modification.Value.Evaluate(); } } } } }
/// <summary> /// Creates a new instance of <see cref="DistanceCalculator"/>. /// </summary> /// <param name="normalTakeOffDynamicsCalculator">The <see cref="INormalTakeOffDynamicsCalculator"/> /// to calculate the aircraft dynamics without failure.</param> /// <param name="failureTakeOffDynamicsCalculator">The <see cref="IFailureTakeOffDynamicsCalculator"/> /// to calculate the aircraft dynamics after failure.</param> /// <param name="integrator">The <see cref="IIntegrator"/> to integrate the first order /// dynamic system.</param> /// <param name="calculationSettings">The <see cref="CalculationSettings"/> /// to configure the calculator.</param> /// <exception cref="ArgumentNullException">Thrown when: /// <list type="bullet"> /// <item><paramref name="normalTakeOffDynamicsCalculator"/></item> /// <item><paramref name="failureTakeOffDynamicsCalculator"/></item> /// <item><paramref name="integrator"/></item> /// <item><paramref name="calculationSettings"/></item> /// </list> /// is <c>null</c>.</exception> public DistanceCalculator(INormalTakeOffDynamicsCalculator normalTakeOffDynamicsCalculator, IFailureTakeOffDynamicsCalculator failureTakeOffDynamicsCalculator, IIntegrator integrator, CalculationSettings calculationSettings) { if (normalTakeOffDynamicsCalculator == null) { throw new ArgumentNullException(nameof(normalTakeOffDynamicsCalculator)); } if (failureTakeOffDynamicsCalculator == null) { throw new ArgumentNullException(nameof(failureTakeOffDynamicsCalculator)); } if (integrator == null) { throw new ArgumentNullException(nameof(integrator)); } if (calculationSettings == null) { throw new ArgumentNullException(nameof(calculationSettings)); } this.normalTakeOffDynamicsCalculator = normalTakeOffDynamicsCalculator; this.failureTakeOffDynamicsCalculator = failureTakeOffDynamicsCalculator; this.integrator = integrator; this.calculationSettings = calculationSettings; }
public ToneTestSystem(IIntegrator integrator, double rootFrequency) : base(integrator) { // // Prepare notes // ToneNode.Note note440 = new ToneNode.Note( rootFrequency, 1.0, 1, 3, 5, 8, 12); ToneNode.Note noteMajorThird = new ToneNode.Note( rootFrequency * 5.0 / 4.0, 1.0, 1, 3, 5, 8, 12); // // Prepare source node. // ToneNode source = new ToneNode(); source.Name = "audio_src"; source.Notes.Add(note440); source.Notes.Add(noteMajorThird); // // Add nodes to system. // this.Nodes = new[] { source }; }
public IntegratorMain() { m_directLightIntegrator = new IntegratorDirectLight(); m_specularIntegrator = new IntegratorSpecular(); //m_diffuseIntegrator = new IntegratorDiffuse(); m_maxTraceLevel = 5; }
public double CalculateAlpha(IIntegrator integrator, int deg, Array layer, double[] r, double h, int N) { double[] u = layer.Values; double uavg = 2 * integrator.GetIntegral(u.Select((uj, j) => uj * r[j]), h, N); return(2 * integrator.GetIntegral(u.Select((uj, j) => Math.Pow(uj, deg) * r[j]), h, N) / Math.Pow(uavg, deg)); }
public TestSummary(ITestSet tests, IIntegrator integrator, double targetError) { this.Results = new List <TestResult>(); this.TestSet = tests.Name; this.Integrator = integrator.Name; this.TargetError = targetError; }
/// <summary> /// Initializes a new instance of the <see cref="DynamicSimulationFramework.Simulation.State"/> class. /// </summary> /// <param name='w'> /// World to be simulated. /// </param> /// <param name='dt'> /// Size of the time steps /// </param> /// <param name='solver'> /// <see cref="irolver"/> /// </param> public State(World w, double dt, IIntegrator integrator) { World = w; TimeStep = dt; Time = 0; RigidStates = new Dictionary<IRigid, RigidState> (); Integrator = integrator; Solver = new Jacobi (); }
public AggregatedDistanceOutput Calculate(AircraftData aircraftData, IIntegrator integrator, int nrOfFailedEngines, double density, double gravitationalAcceleration, CalculationSettings calculationSettings) { return(aggregatedDistanceCalculator.Calculate(aircraftData, integrator, nrOfFailedEngines, density, gravitationalAcceleration, calculationSettings)); }
/// <summary> /// Initializes the engine and sets the instance value. /// </summary> void Awake() { instance = this; bodyCount = 0; bodies = new List <DBody>(); detector = new SimpleDetector(); integrator = new EulerImplicit(); contacts = new HashSet <Manifold>(); simulate = false; }
/// <summary> /// Initializes the engine and sets the instance value. /// </summary> void Awake() { instance = this; bodyCount = 0; bodies = new List <DBody>(); detector = new HashGridDetector(cellSize, sceneWidth, sceneHeight); integrator = new EulerImplicit(); contacts = new HashSet <Manifold>(); simulate = false; }
public MultiThreadingRenderer(int i, Aggregate objects, List <ILight> lights, ICamera camera, Film film) { threadId = i; this.camera = camera.Clone(); this.integrator = (IIntegrator)Activator.CreateInstance(Constants.Integrator); this.film = film; this.sampler = (ISampler)Activator.CreateInstance(Constants.Sampler); this.objects = objects; this.lights = lights; }
/// <summary> /// Create a new, empty ForceSimulator. /// </summary> /// <param name="integr">the Integrator to use</param> public ForceSimulator(IIntegrator integr) { mIntegrator = integr; iforces = new IForce[5]; sforces = new IForce[5]; iflen = 0; sflen = 0; mItems = new List <ForceItem>(); springs = new List <Spring>(); }
/// <summary> /// Create a new, empty ForceSimulator. /// </summary> /// <param name="integr">the Integrator to use</param> public ForceSimulator(IIntegrator integr) { mIntegrator = integr; iforces = new IForce[5]; sforces = new IForce[5]; iflen = 0; sflen = 0; mItems = new List<ForceItem>(); springs = new List<Spring>(); }
public IDistanceCalculator CreateAbortedTakeOffDistanceCalculator(AircraftData data, IIntegrator integrator, double density, double gravitationalAcceleration, CalculationSettings calculationSettings) { INormalTakeOffDynamicsCalculator normalTakeOffDynamicsCalculator = takeOffDynamicsCalculatorFactory.CreateNormalTakeOffDynamics(data, density, gravitationalAcceleration); IFailureTakeOffDynamicsCalculator failureTakeOffDynamicsCalculator = takeOffDynamicsCalculatorFactory.CreateAbortedTakeOffDynamics(data, density, gravitationalAcceleration); return(new DistanceCalculator(normalTakeOffDynamicsCalculator, failureTakeOffDynamicsCalculator, integrator, calculationSettings)); }
public LinearCoupleSystem(IIntegrator integrator) : base(integrator) { LinearNode linear1 = new LinearNode(1, 2, 0); linear1.Name = "u"; LinearNode linear2 = new LinearNode(0, -1, 0); linear2.Name = "v"; linear1.AddIncomingNode(linear2); linear2.AddIncomingNode(linear1); this.Nodes = new[] { linear1, linear2 }; }
public CalculationInput(GeneralSimulationSettingsData generalSimulationSettings, int failureVelocity, AircraftData aircraftData, IIntegrator integrator, int nrOfFailedEngines, double density, double gravitationalAcceleration) { GeneralSimulationSettings = generalSimulationSettings; FailureVelocity = failureVelocity; AircraftData = aircraftData; Integrator = integrator; NrOfFailedEngines = nrOfFailedEngines; Density = density; GravitationalAcceleration = gravitationalAcceleration; }
public void Run(ITestSet tests, IIntegrator integrator, double targetError) { listView1.Items.Clear(); var summary = new TestSummary(tests, integrator, targetError); var functions = tests.GetTestFunctions(); int total = 0, failed = 0; Util.Tic(); foreach (var item in functions) { total++; try { var value = integrator.Integrate(item, targetError); Console.WriteLine(value); var result = GetTestResult(item, value); ShowTestResult(result, targetError); summary.Add(result); if (result.HasInvalidValue()) { failed++; } } catch (Exception e) { ProcessError(item, e); failed++; } } summary.Time = Util.Toc(); summary.TotalCount = total; summary.FailedCount = failed; ShowTestSummary(summary); }
void Awake() { scene = GetComponent <PhysicalScene>(); scene.Load(); if (scene.integratorType == "explicit-euler") { integrator = new ExplicitEulerIntegrator(); } else if (scene.integratorType == "symplectic-euler") { integrator = new SymplecticEulerIntegrator(); } else { Debug.Assert(false, "Can Not Find Any Suitable Integrator."); } }
public AggregatedDistanceOutput Calculate(AircraftData aircraftData, IIntegrator integrator, int nrOfFailedEngines, double density, double gravitationalAcceleration, CalculationSettings calculationSettings) { if (aircraftData == null) { throw new ArgumentNullException(nameof(aircraftData)); } if (integrator == null) { throw new ArgumentNullException(nameof(integrator)); } if (calculationSettings == null) { throw new ArgumentNullException(nameof(calculationSettings)); } IDistanceCalculator abortedTakeOffCalculator = distanceCalculatorFactory.CreateAbortedTakeOffDistanceCalculator(aircraftData, integrator, density, gravitationalAcceleration, calculationSettings); IDistanceCalculator continuedTakeOffCalculator = distanceCalculatorFactory.CreateContinuedTakeOffDistanceCalculator(aircraftData, integrator, nrOfFailedEngines, density, gravitationalAcceleration, calculationSettings); DistanceCalculatorOutput abortedTakeOffOutput = abortedTakeOffCalculator.Calculate(); DistanceCalculatorOutput continuedTakeOffOutput = continuedTakeOffCalculator.Calculate(); return(new AggregatedDistanceOutput(calculationSettings.FailureSpeed, abortedTakeOffOutput.Distance, continuedTakeOffOutput.Distance)); }
public Physics(IIntegrator Integrator, bool AllowLoadSnapshot, StartupDoneDelegate StartupDone) { this.clock = new Clock(); this.integrator = Integrator; startupDoneDelegate = StartupDone; AllBodies = new LinkedList <CelestialBody>(); BodyDictionary = new Dictionary <string, CelestialBody>(DEFAULT_STARTING_NUM_ALL_BODIES); StarDictionary = new Dictionary <int, Star>(DEFAULT_STARTING_NUM_STARS); SearchDatabase = null; Date = new DateTime(2011, 1, 1); SleepBetweenCycles = 0; createOrbiters(); loadEphemeres(!TEST && AllowLoadSnapshot); if (TEST) { this.TargetDate = TEST_DATE; } else { GoToToday(); } this.ephemeris = this.availableEphemeres.GetClosest(this.TargetDate); invokeEphemeris(SetTimeMode: true, Wait: false, EstablishGravitationalInfluences: true); loadStars(); setupConstellations(); setupCaptioning(); }
public GFNN2LayerSystem( IIntegrator integrator, ToneNode soundSource, bool enableLearning, double middleFrequency = ToneNode.MiddleC, int octaves = 2, int nodesPerOctave = 120) : base(integrator) { this.EnableLearning = enableLearning; // Initialize SIRs this.SIRs = new double[] { // Sub harmonics. 1.0 * 1 / 1, 1.0 * 1 / 2, //1.0 * 1 / 3, //1.0 * 2 / 3, //1.0 * 1 / 4, //1.0 * 3 / 4, //1.0 * 1 / 5, //1.0 * 2 / 5, //1.0 * 3 / 5, //1.0 * 4 / 5, // 12-tone ET. 1.0 * 16 / 15, 1.0 * 9 / 8, 1.0 * 6 / 5, 1.0 * 5 / 4, 1.0 * 4 / 3, 1.0 * 17 / 12, 1.0 * 3 / 2, 1.0 * 8 / 5, 1.0 * 5 / 3, 1.0 * 16 / 9, 1.0 * 15 / 8, 1.0 * 2 / 1, }; _soundSource = soundSource; _layers = new List <List <NeuralOscillatorNode> >(); var layer1 = GenerateLayer( "COC", middleFrequency, octaves, nodesPerOctave, -0.01, // omega=2 pi -1, -1, 0, 0.1, 2.0 * Math.PI); var layer2 = GenerateLayer( "DCN", middleFrequency, octaves, nodesPerOctave, -0.4, 1.2, -1, -0.01, 0.75, 0); // Connect sound source to layer 1. foreach (var node in layer1) { node.AddIncomingNode(soundSource); } // Afferent layer 1 to layer 2. // Connect each node in layer 1 to its corresponding node in layer 2. double afferentWeightPlasticity = 0; double afferentWeightDecay = 0; foreach (var pair in layer1.Zip(layer2, (n1, n2) => new { L1N = n1, L2N = n2 })) { Debug.Assert(pair.L1N.CenterFrequency == pair.L2N.CenterFrequency); pair.L2N.AddIncomingNode(pair.L1N, 1.0, afferentWeightDecay, afferentWeightPlasticity); } // Internal layer 2 to layer 2. double internalWeight = 0.005; double sirMatchThreshold = 0.005; double internalWeightDecay = 1.0; double internalWeightPlasticity = 1.0; int connectionsAdded = 0; int iteration = -1; var outerJoin = layer2 .Join(layer2, n => true, n => true, (n1, n2) => new { N1 = n1, N2 = n2 }) .OrderBy(n => n.N1.CenterFrequency) .ThenBy(n => n.N2.CenterFrequency); foreach (var pair in outerJoin) { iteration++; if (pair.N1 == pair.N2) { continue; } // Learn weights. if (this.EnableLearning) { //if (iteration % 2 != 0) //{ // continue; //} pair.N1.AddIncomingNode(pair.N2, internalWeight, internalWeightDecay, internalWeightPlasticity); pair.N2.AddIncomingNode(pair.N1, internalWeight, internalWeightDecay, internalWeightPlasticity); connectionsAdded += 2; } // Hardcoded weights. else { // Connect layer 2 nodes to each other when they // match a (probably) learned SIR/eigenmultiple frequency. double frequencyRatio = pair.N1.CenterFrequency / pair.N2.CenterFrequency; double frequencyRatioAlt = 1.0 / frequencyRatio; foreach (double sir in this.SIRs) { bool isMatch = MathHelpers.ApproximatelyEqual(frequencyRatio, sir, sirMatchThreshold) || MathHelpers.ApproximatelyEqual(frequencyRatioAlt, sir, sirMatchThreshold); if (!isMatch) { continue; } pair.N1.AddIncomingNode(pair.N2, internalWeight, 0, 0); pair.N2.AddIncomingNode(pair.N1, internalWeight, 0, 0); connectionsAdded += 2; goto NextPair; } } NextPair: continue; } // Assign layers to system. var allNodes = new DynamicalNode[] { soundSource }.Concat(layer1).Concat(layer2); this.Nodes = allNodes; // Remember layers. _layers.Add(layer1); _layers.Add(layer2); // Create hebbian learning system. if (this.EnableLearning) { _hebbianSystem = new ConnectionWeightSystem(new RungeKuttaIntegrator(), this); } }
/// <summary> /// Extension method for resolving the SendGrid integration from the IIntegrator. /// </summary> /// <param name="integrator">Instance of the IIntegrator.</param> /// <returns>Instance of fluent builder for the WardenConfiguration.</returns> public static SendGridIntegration SendGrid(this IIntegrator integrator) => integrator.Resolve <SendGridIntegration>();
public static SmtpIntegration Smtp(this IIntegrator integrator) => integrator.Resolve <SmtpIntegration>();
/// <summary> /// Simulates the movement. /// </summary> /// <param name='dt'> /// Size of the time step /// </param> /// <param name='solver'> /// Used <see cref="ISolver"/> /// </param> public void SimulateMovement(double dt, IIntegrator integrator) { IntegratorResult ir = integrator.Integrate (LinearAcceleration, AngularAcceleration, LinearVelocity, AngularVelocity, dt); LinearVelocity += ir.DeltaLinearVelocity; CenterOfMass += ir.DeltaCenterOfMass; AngularVelocity += ir.DeltaAngularVelocity; AnglesOfRotation += ir.DeltaAnglesOfRotation; }
/// <summary> /// Initializes a new instance of the <see cref="FloatUnaryFunction"/> class. /// </summary> /// <param name="f">A function delegate that takes a float value as a parameter and returns a float value.</param> /// <param name="d">The <see cref="IDifferentiator"/> to use.</param> /// <param name="i">The <see cref="IIntegrator"/> to use.</param> public FloatUnaryFunction(MathFunctions.FloatUnaryFunction f, IDifferentiator d, IIntegrator i) { _function = f; _differentiator = d; _integrator = i; }
public static RayContext startFromPixel(Ray startRay, int pixX, int pixY, Scene _scene, IIntegrator integrator) { RayContext newContext = new RayContext(startRay); newContext.scene = _scene; newContext.m_renderer = integrator; newContext.m_rndContext = new RandomContext(2, 17 * pixX + 73 * pixY); return newContext; }
public GFNN1LayerSystem(IIntegrator integrator, double middleFrequency = 440.0, int octaves = 4, int nodesPerOctave = 120, ToneNode soundSource = null) : base(integrator) { // "A dynamical systems approach to musical tonality.". Large 2010. Section 4 "Predicting Tonality". // Generate list of natural frequencies. We step // linearly through the log-frequency space. int numOctaves = octaves; int numFrequenciesPerOctave = nodesPerOctave; SortedSet <double> frequencies = new SortedSet <double>(); double xMiddle = Math.Log(middleFrequency); double numOctavesHalfPow2 = Math.Pow(2.0, numOctaves / 2.0); double xLowerBound = Math.Log(middleFrequency / numOctavesHalfPow2); double xUpperBound = Math.Log(middleFrequency * numOctavesHalfPow2); double xStepSize = (xUpperBound - xLowerBound) / (numOctaves * numFrequenciesPerOctave); // Some variables. double x; // Some methods Func <double, double> logFrequencyToFrequency = (lf) => Math.Exp(lf); // Add midpoint. x = xMiddle; frequencies.Add(logFrequencyToFrequency(x)); // Add lower frequencies. while (x >= xLowerBound) { x -= xStepSize; frequencies.Add(logFrequencyToFrequency(x)); } // Add upper frequencies. x = xMiddle; while (x <= xUpperBound) { x += xStepSize; frequencies.Add(logFrequencyToFrequency(x)); } // Create nodes. double alpha; double beta; double delta; double epsilon; double omega; // Configuration 1 { // "A canonical model for gradient frequency neural networks. // Equation 20 test parameters. alpha = 0.0; beta = -10.0; delta = -9.0; epsilon = 0.3; omega = 2.0 * Math.PI; } List <DynamicalNode> nodes = new List <DynamicalNode>(); foreach (double frequency in frequencies) { NeuralOscillatorNode node = new NeuralOscillatorNode( 0.0, frequency, epsilon, alpha, beta, beta, delta, omega); node.Name = string.Format("ω{0:F3}", frequency); node.HistorySize = 2; nodes.Add(node); } // Add audio source node if present. if (soundSource != null) { foreach (var node in nodes) { node.AddIncomingNode(soundSource, 1.0, 0.0, 0.0); } nodes.Add(soundSource); this.SoundSource = soundSource; } // Store nodes. this.Nodes = nodes; }
/// <summary> /// Initializes a new instance of the <see cref="DoubleUnaryFunction"/> class. /// </summary> /// <param name="f"> /// A function delegate that takes a double value as a parameter and returns a double value. /// </param> public DoubleUnaryFunction(MathFunctions.DoubleUnaryFunction f) { _function = f; _differentiator = null; _integrator = null; }
/// <summary> /// Extension method for resolving the Seq integration from the IIntegrator. /// </summary> /// <param name="integrator">Instance of the IIntegrator.</param> /// <returns>Instance of fluent builder for the WardenConfiguration.</returns> public static SeqIntegration Seq(this IIntegrator integrator) => integrator.Resolve <SeqIntegration>();
/// <summary> /// Initializes a new instance of the <see cref="FloatUnaryFunction"/> class. /// </summary> /// <param name="f"> /// A function delegate that takes a float value as a parameter and returns a float value. /// </param> public FloatUnaryFunction(MathFunctions.FloatUnaryFunction f) { _function = f; _differentiator = null; _integrator = null; }
/// <summary> /// Extension method for resolving the Cachet integration from the IIntegrator. /// </summary> /// <param name="integrator">Instance of the IIntegrator.</param> /// <returns>Instance of fluent builder for the WardenConfiguration.</returns> public static CachetIntegration Cachet(this IIntegrator integrator) => integrator.Resolve <CachetIntegration>();
/// <summary> /// Extension method for resolving the MS SQL integration from the IIntegrator. /// </summary> /// <param name="integrator">Instance of the IIntegrator.</param> /// <returns>Instance of fluent builder for the WardenConfiguration.</returns> public static MsSqlIntegration MsSql(this IIntegrator integrator) => integrator.Resolve <MsSqlIntegration>();
/// <summary> /// Initializes a new instance of the <see cref="FloatUnaryFunction"/> class. /// </summary> /// <param name="f"> /// A function delegate that takes a float value as a parameter and returns a float value. /// </param> public FloatUnaryFunction(MathFunctions.FloatUnaryFunction f) { _function = f; _differentiator = null; _integrator = null; }
public PixelSamplerOne(IIntegrator integrator) { m_integrator = integrator; }
/// <summary> /// Initializes a new instance of the <see cref="DoubleUnaryFunction"/> class. /// </summary> /// <param name="f">A function delegate that takes a double value as a parameter and returns a double value.</param> /// <param name="d">The <see cref="IDifferentiator"/> to use.</param> /// <param name="i">The <see cref="IIntegrator"/> to use.</param> public DoubleUnaryFunction(MathFunctions.DoubleUnaryFunction f, IDifferentiator d, IIntegrator i) { _function = f; _differentiator = d; _integrator = i; }
/// <summary> /// Creates a new dynamical system using the provided integrator. /// </summary> /// <param name="integrator"></param> public DynamicalSystem(IIntegrator integrator) { this.Integrator = integrator; }
/// <summary> /// Extension method for resolving the Twilio integration from the IIntegrator. /// </summary> /// <param name="integrator">Instance of the IIntegrator.</param> /// <returns>Instance of fluent builder for the WardenConfiguration.</returns> public static TwilioIntegration Twilio(this IIntegrator integrator) => integrator.Resolve <TwilioIntegration>();