Beispiel #1
0
        public void UseMutation(IEnumerable <ICrossedTree> trees, ITreeCreator treeCreator, double probability = 0)
        {
            if (probability <= 0)
            {
                return;
            }

            foreach (var tree in trees)
            {
                if (tree.GetChilds().Count() == 0)
                {
                    continue;
                }

                if (Auxiliary.OccurEvent(probability))
                {
                    List <ICrossedTree> fromCandidates = tree.GetChilds().ToList();
                    ICrossedTree        from           = fromCandidates[Auxiliary.SelectCandidateIndex(new int[fromCandidates.Count].Select(d => d + 1).ToArray())];

                    ICrossedTree to = treeCreator.GetInstance(from.SublevelsCount);

                    bool a = tree.ChangeChild(from, to);

                    continue;
                }

                UseMutation(tree.GetChilds().ToList(), treeCreator, probability);
            }
        }
Beispiel #2
0
        internal TreeSource(ITreeCreator creator)
        {
            if (!string.IsNullOrEmpty(creator.Context))
            {
                Context = DbContextUtil.CreateDbContext(creator.Context);
            }

            Tree = creator.CreateTree(this);
        }
Beispiel #3
0
        public Evolution(ITreeCreator treeCreator, int populationCount, List <double[]> args, List <double> etalon)
        {
            TreeCreator = treeCreator;

            PopulationCount = populationCount;

            selectionair = new Selection(args, etalon, calcError);

            mutator = new Mutation();
        }
Beispiel #4
0
        public Presenter(IView view)
        {
            _view                = view;
            _view.AddNode       += OnAddNode;
            _view.DeleteNode    += OnDeleteNode;
            _view.Clear         += OnClear;
            _view.ChangeFactor  += OnChangeFactor;
            _view.Reload        += OnReload;
            _view.SelectLinked  += OnSelectLinked;
            _view.SelectArray   += OnSelectArray;
            _view.SortByEven    += OnSortByEven;
            _view.SortByOdd     += OnSortByOdd;
            _view.FillTestData  += OnFillTestData;
            _view.MakeImmutable += OnMakeImmutable;

            _creator = new LinkedTreeCreator <int>();
            _tree    = _creator.CreateTree();
            RefreshView();
        }
Beispiel #5
0
        /// <summary>
        /// Creates tree from formula
        /// </summary>
        /// <param name="formula">The formula</param>
        /// <param name="creator">The creator</param>
        /// <returns>The tree</returns>
        public static ObjectFormulaTree CreateTree(MathFormula formula, IFormulaObjectCreator creator)
        {
            ObjectFormulaTree tree = new ObjectFormulaTree(formula, creator);
            IObjectOperation  op   = tree.Operation;

            if (op is ITreeCreator)
            {
                ITreeCreator      tc = op as ITreeCreator;
                ObjectFormulaTree tp = tc.Tree;
                if (tp != null)
                {
                    return(tp);
                }
            }
            if (op == null)
            {
                return(null);
            }
            return(tree);
        }
 // private to prevent direct instantiation.
 public AssemblyManipulationService()
 {
     treeCreator = ViewModelRepository.Instance.Resolver.Container.GetExport <ITreeCreator>().Value;
 }
Beispiel #7
0
 public HuffmanAlgorithm(ISymbolAnalyzer analyzer, ITreeCreator creator)
 {
     _analyzer = analyzer;
     _creator  = creator;
 }
Beispiel #8
0
 private void OnSelectLinked(object sender, EventArgs e)
 {
     _creator = new LinkedTreeCreator <int>();
     _tree    = _creator.CreateTree(_tree.Factor);
     RefreshView();
 }