コード例 #1
0
ファイル: SoluteManager.cs プロジェクト: cla473/ApsimX
        /// <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);
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
ファイル: SoluteManager.cs プロジェクト: cla473/ApsimX
        /// <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;
        }
コード例 #4
0
ファイル: SoluteManager.cs プロジェクト: matteo801838/ApsimX
        /// <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;
        }
コード例 #5
0
ファイル: grbin.cs プロジェクト: CDMMKY/fuzzy_core
        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);
        }
コード例 #6
0
ファイル: SoluteManager.cs プロジェクト: matteo801838/ApsimX
        /// <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);
        }
コード例 #7
0
    /// <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];
    }
コード例 #8
0
ファイル: SoluteManager.cs プロジェクト: cla473/ApsimX
        /// <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 });
            }
        }