public static Tree.RootNode CreateInitialTree() { //var root = TreeGenerator.Start(); var root = new Tree.RootNode(); root.DevelopChildren(); root.SetIndex(); return(root); }
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); }
void GenerateClick(object sender, RoutedEventArgs e) { do { tree = DevelopManager.CreateInitialTree(); individual = new Individual(tree, true); } while (!individual.IsValidWaveform()); individual.Play(); }
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); } }
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); }
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); } }
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]; }
public void Start(Tree.RootNode tree) { Ready = true; Pool.Init(tree); }
/// <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 }); }
public void SetInitial(Tree.RootNode t) { this.tree = t; individual = new Individual(tree, true); }
IEnumerable <Tree.Constant> GetActiveConstants(Tree.RootNode tree) { return(tree.ToBreadthFirstList().OfType <Tree.Constant>().Where(x => x.Parent.IsUsed())); }