Esempio n. 1
0
        private void LoadSettingsFile()
        {
            SettingsXml s = SettingsXml.Load(Path);

            if (s.F1.Empty)
            {
                throw new Exception("F1 matrix empty");
            }
            if (s.F2.Empty)
            {
                throw new Exception("F2 matrix empty");
            }
            if (s.F1.Cols != s.F1.Rows)
            {
                throw new Exception("F1 matrix must be a square matrix");
            }
            if (s.F2.Cols != s.F2.Rows)
            {
                throw new Exception("F2 matrix must be a square matrix");
            }
            if (s.F1.Cols != s.F2.Cols)
            {
                throw new Exception("F1 must be the same size as F2");
            }

            uint oldCols = engine.Matrix1.Cols;

            if (LoadMatricies)
            {
                engine.Matrix1    = s.F1;
                engine.Matrix2    = s.F2;
                engine.NodesCount = s.F1.Cols;
                engine.Mutation   = s.Mutation;
            }

            if (LoadPopSize)
            {
                engine.IndividualsLength = s.PopSize;
                engine.ReCreateEvolutionary();
            }
            else if (LoadIndividuals)
            {
                engine.Evolutionary.Individuals = s.Individuals;
            }
            else
            {
                if (oldCols != s.F1.Cols)
                {
                    throw new Exception("Cannot leave old population, matricies size are different");
                }

                var copy = engine.Evolutionary.Individuals.ToArray();
                engine.ReCreateEvolutionary();
                engine.Evolutionary.Individuals = copy;
            }
        }