/// <summary> /// Sets the active reference generator from the list of available reference generators /// </summary> /// <param name="refGenType">The reference generator type to set as active.</param> private void SetActiveReferenceGenerator(ReferenceGeneratorType refGenType) { IReferenceGenerator refGen; if (GetReferenceGenerator(refGenType, out refGen)) { activeGenerator = refGen; } else { throw new System.ArgumentException("Reference generator " + refGenType.ToString() + " unavailable."); } }
/// <summary> /// Looks for a reference generator of the given type within the list of reference generators in the input manager and is returned if found. /// </summary> /// <param name="refGenType">The type of reference generator to look for.</param> /// <param name="outRefGen">The reference generator object to put the found reference generator in.</param> /// <returns>True if a reference generator was found.</returns> protected bool GetReferenceGenerator(ReferenceGeneratorType refGenType, out IReferenceGenerator outRefGen) { // Look for a reference generator with the given type. foreach (IReferenceGenerator refGen in referenceGenerators) { // If found set it to the referenced reference generator and return true. if (refGen.GeneratorType().Equals(refGenType)) { outRefGen = refGen; return(true); } } // Failed to find a reference generator with the provided type. outRefGen = null; return(false); }
/// <summary> /// Abstract adaptive reference generator to add basic variables used across all generators. /// </summary> /// <param name="xBar">The initial references.</param> /// <param name="xMin">The lower limit for the references.</param> /// <param name="xMax">The upper limit for the references.</param> /// <param name="theta">The initial parameters.</param> /// <param name="thetaMin">The lower limit for the parameters.</param> /// <param name="thetaMax">The upper limit for the parameters.</param> public AdaptiveGenerator(float[] xBar, float[] xMin, float[] xMax, float[] theta, float[] thetaMin, float[] thetaMax, ReferenceGeneratorType generatorType) { if (xBar.Length != xMin.Length || xBar.Length != xMax.Length || theta.Length != xBar.Length || theta.Length != thetaMin.Length || theta.Length != thetaMax.Length) { throw new System.ArgumentOutOfRangeException("The length of the parameters does not match."); } channelSize = xBar.Length; this.xBar = xBar; this.xMin = xMin; this.xMax = xMax; parameterChannelSize = theta.Length; this.theta = theta; this.thetaMin = thetaMin; this.thetaMax = thetaMax; this.generatorType = generatorType; }