Пример #1
0
        public static Tree.RootNode CreateInitialTree()
        {
            //var root = TreeGenerator.Start();
            var root = new Tree.RootNode();

            root.DevelopChildren();
            root.SetIndex();
            return(root);
        }
Пример #2
0
 public Individual(Tree.RootNode tree, bool useMask)
 {
     Tree     = tree;
     Topology = DevelopManager.DevelopTopology(tree);
     Data     = Enumerable.Range(0, DevelopManager.TableLength).Select(x => (float)Topology.RequireValue(x)).ToArray();
     Normalize();
     Analyzer = new AudioLib.Analyzer(Data, (int)FileUtil.SampleRate);
     Analyzer.CalcSpectrogram(useMask);
 }
Пример #3
0
        void GenerateClick(object sender, RoutedEventArgs e)
        {
            do
            {
                tree       = DevelopManager.CreateInitialTree();
                individual = new Individual(tree, true);
            } while (!individual.IsValidWaveform());

            individual.Play();
        }
Пример #4
0
        private void LoadTreeButtonClick(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "tree binary | *.bin"
            };

            if (dialog.ShowDialog() ?? false)
            {
                initialTree = Tree.RootNode.Deserialize(dialog.FileName);
            }
        }
Пример #5
0
        public static Unit.Renderer DevelopTopology(Tree.RootNode tree)
        {
            var man = new DevelopManager();

            man.tree    = tree;
            tree.Target = man.firstPoint;
            foreach (var item in tree.ToBreadthFirstList())
            {
                item.Process();
            }
            man.render.InitAll();
            return(man.render);
        }
Пример #6
0
        public static void Save(string fileName, Tree.RootNode tree, string target)
        {
            var res = new GAResult();

            res.Tree           = tree;
            res.TargetFileName = target;
            var ser = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            using (var file = System.IO.File.OpenWrite(fileName))
            {
                ser.Serialize(file, res);
            }
        }
Пример #7
0
        public ParameterOptimizer(Tree.RootNode original, AudioLib.Analyzer target)
        {
            rand      = RandomProvider.GetThreadRandom();
            Original  = original;
            items     = GetActiveConstants(original).ToArray();
            Dimension = items.Length;
            Target    = target;

            pool    = new double[PoolSize][];
            pool[0] = items.Select(x => x.Value).ToArray();
            for (int i = 1; i < PoolSize; i++)
            {
                pool[i] = CreateVector();
            }

            history   = new Dictionary <double[], Individual>();
            probTable = new double[PoolSize];
            scores    = new double[PoolSize];
        }
Пример #8
0
 public void Start(Tree.RootNode tree)
 {
     Ready = true;
     Pool.Init(tree);
 }
Пример #9
0
 /// <summary>
 /// 1個体をオリジナルに変異体で構成する
 /// </summary>
 /// <param name="p"></param>
 public void Init(Tree.RootNode p)
 {
     items[0] = new Individual(p, true);
     UpdateInner(() => p.CloneTree().Mutate(rand), new[] { 0 });
 }
Пример #10
0
 public void SetInitial(Tree.RootNode t)
 {
     this.tree  = t;
     individual = new Individual(tree, true);
 }
Пример #11
0
 IEnumerable <Tree.Constant> GetActiveConstants(Tree.RootNode tree)
 {
     return(tree.ToBreadthFirstList().OfType <Tree.Constant>().Where(x => x.Parent.IsUsed()));
 }