/// <summary> /// Set the value of a solute by specifying a delta. Will throw if solute not found. /// </summary> /// <param name="name">Name of solute</param> /// <param name="delta">Delta values to be added to solute</param> public void Add(string name, double[] delta) { Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (foundSolute == null) { throw new Exception("Cannot find solute: " + name); } foundSolute.Value = MathUtilities.Add(foundSolute.Value, delta); }
/// <summary> /// Set the value of a solute by specifying a delta. Will throw if solute not found. /// </summary> /// <param name="name">Name of solute</param> /// <param name="callingModelType">Type of calling model</param> /// <param name="delta">Delta values to be subtracted from solute</param> public void Subtract(string name, SoluteSetterType callingModelType, double[] delta) { Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (foundSolute == null) { throw new Exception("Cannot find solute: " + name); } foundSolute.SetValue(callingModelType, MathUtilities.Subtract(foundSolute.GetValue(), delta)); }
/// <summary> /// Set the value of a solute. Will throw if solute not found. /// </summary> /// <param name="name">Name of solute</param> /// <param name="value">Value of solute</param> public void SetSolute(string name, double[] value) { Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (foundSolute == null) { throw new Exception("Cannot find solute: " + name); } foundSolute.Value = value; }
/// <summary> /// Add a delta value to the top layer of a solute. Will throw if solute not found. /// </summary> /// <param name="name">Name of solute</param> /// <param name="layerIndex">Layer index to add delta to</param> /// <param name="delta">Value to be added to top layer of solute</param> public void AddToLayer(int layerIndex, string name, double delta) { Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (foundSolute == null) { throw new Exception("Cannot find solute: " + name); } double[] values = foundSolute.Value; values[layerIndex] += delta; foundSolute.Value = values; }
public IFuzzySystem UniversalMethod(IFuzzySystem FSystem, ILearnAlgorithmConf config) { init(FSystem, config); ////////////////////////////////////////////////////////////////////////////////////Первоначальная генерация for (int u = 0; u < MCount; u++) { ///Создаем частицу for (int i = 0; i < max_Features; i++) { if (rand.NextDouble() > 0.5) { Solute[i] = true; } else { Solute[i] = false; } } ///Проверяем, есть ли признаки. Если частица пуста, рандомный признак становится единицей if (Solute.Count(x => x == true) == 0) { BestSolute[rand.Next(BestSolute.Count())] = true; } ; //Заносим частицу в популяцию test.Add(Solute.Clone() as bool[]); //Заносим признаки в классификатор FSystem.AcceptedFeatures = test[test.Count - 1]; Errors.Add(FSystem.ErrorLearnSamples(FSystem.AbstractRulesBase()[0])); if (Errors[u] < Ebest) { Ebest = Errors[u]; BestSolute = test[u].Clone() as bool[]; Console.WriteLine("Найдена частица с ошибкой E=" + Errors[u]); Storage.Add(new FeatureSelectionModel(FSystem, BestSolute)); } Console.WriteLine(Errors[u]); } /////////////////////////////////////////// Сгенерировали первоначальные частицы, ура! algoritm(); Storage = FeatureSelectionModel.Distinct(Storage); FeatureSelectionModel.Sort(Storage, SortWay); FSystem.AcceptedFeatures = BestSolute; return(FSystem); }
/// <summary> /// Return the value of a solute. Will throw if solute not found. /// </summary> /// <param name="name">Name of solute</param> public double[] GetSolute(string name) { if (solutes == null) { FindSolutes(); } Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (foundSolute == null) { throw new Exception("Cannot find solute: " + name); } return(foundSolute.Value); }
/// <summary> /// Performs some initalisation tasks, set name and array sizes /// </summary> /// <param name="ThisSolute">A reference to the solute which this type represents</param> public void InitialiseSoluteType(Solute ThisSolute) { // Set the name of the solute SetSoluteName(); // Initialise and set the initial solute amount SoluteAmount = ThisSolute.Amount_kgha(); // Initilise the solute transfomed arrays SoluteAdsorbed = new double[SoluteAmount.Length]; deltaSoluteDiffusion = new double[SoluteAmount.Length]; fractionSoluteTransformation = new double[SoluteAmount.Length]; deltaSoluteTransformed = new double[SoluteAmount.Length]; InhibitionEffect = new double[SoluteAmount.Length]; }
/// <summary> /// Add a delta value to the top layer of a solute. Will throw if solute not found. /// </summary> /// <param name="name">Name of solute</param> /// <param name="layerIndex">Layer index to add delta to</param> /// <param name="delta">Value to be added to top layer of solute</param> public void AddToLayer(int layerIndex, string name, double delta) { Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (foundSolute == null) { throw new Exception("Cannot find solute: " + name); } // Check to see if there is a 'AddToTopLayer' method. if (foundSolute.addToTopLayerMethod == null) { double[] values = foundSolute.Value; values[layerIndex] += delta; foundSolute.Value = values; } else { foundSolute.addToTopLayerMethod.Invoke(foundSolute.model, new object[] { delta }); } }