public ActionResult Index() { var watch = Stopwatch.StartNew(); var model = TreeCreator.MakeTree(_context.Departaments.Include(q => q.Employees) .ToList()) .GetNodes .OrderByDescending(q => q.EmployeeCount) .ThenByDescending(q => q.DepartamentCount) .Take(20) .Select(q => new DepartamentModel { Id = q.Id, Title = q.Name, DCount = q.DepartamentCount, ECount = q.EmployeeCount }) .ToList(); watch.Stop(); HttpContext.Items["log"] = _context.Database.Log; ViewBag.Watch = watch.ElapsedMilliseconds; return(View(model)); }
public void Test2B() { string[] a = new string[] { "a (1) -> b, c", "b (3) -> d, e, f", "c (5)", "d (1)", "e (1)", "f (1)" }; string head = Dec7.FindHead(a); TreeCreator builder = new TreeCreator(a, head); Assert.AreEqual(6, builder.FindOffWeight()); }
public void Test2A() { string[] a = new string[] { "a (1) -> b, c, d", "b (2)", "c (2)", "d (3)" }; string head = Dec7.FindHead(a); TreeCreator builder = new TreeCreator(a, head); Assert.AreEqual(2, builder.FindOffWeight()); }
void InspectBranchGroup(TreeCreator tc, TreeCreator.BranchGroup group) { EditorGUI.BeginChangeCheck(); int frequency = EditorGUILayout.IntField("Frequency", group.frequency); int sides = EditorGUILayout.IntSlider("Sides", group.sides, 3, 12); int steps = EditorGUILayout.IntSlider("Steps", group.steps, 2, 16); int spread = EditorGUILayout.IntSlider("Branch Spread", group.branchSpread, 0, 6); float taperBias = EditorGUILayout.Slider("Taper Bias", group.taperBias, .01f, 1f); float kinky = EditorGUILayout.FloatField("Kinky", group.kinky); float lengthScale = EditorGUILayout.Slider("Length Scale", group.lengthScale, 0f, 2f); float radiusScale = EditorGUILayout.Slider("Radius Scale", group.radiusScale, 0f, 2f); int leaves = EditorGUILayout.IntField("Leaves", group.leaves); float leafSize = EditorGUILayout.FloatField("Leaf Size", group.leafSize); float branchHeight = EditorGUILayout.Slider("Branch Height", group.branchHeight, 0f, 1f); float heightBias = EditorGUILayout.FloatField("Height Bias", group.heightBias); float forward = EditorGUILayout.Slider("Forward", group.forward, 0f, 1f); float seekSun = EditorGUILayout.Slider("Seek Sun", group.seekSun, 0f, 1f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Edit branch group"); group.frequency = frequency; group.sides = sides; group.steps = steps; group.branchSpread = spread; group.taperBias = taperBias; group.kinky = kinky; group.lengthScale = lengthScale; group.radiusScale = radiusScale; group.leaves = leaves; group.leafSize = leafSize; group.branchHeight = branchHeight; group.heightBias = heightBias; group.forward = forward; group.seekSun = seekSun; } EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(group.index == 0); if (GUILayout.Button("Remove")) { Undo.RecordObject(target, "Delete branch group"); tc.groups.RemoveAt(group.index); } EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Add Next")) { Undo.RecordObject(target, "Add branch group"); tc.groups.Insert(group.index + 1, new TreeCreator.BranchGroup() { index = group.index + 1 }); } EditorGUILayout.EndHorizontal(); }
public void Chart() { var model = TreeCreator.MakeTree(_context.Departaments.Include(q => q.Employees).ToList()); var node46 = model.GetById(46); var nodeAge = node46.AverageEmployeeAge; // node46.MakeChart(); // var chartModel = node46.BuildChart; Assert.Fail(); }
public ActionResult About() { _model = TreeCreator.MakeTree( _context.Departaments .Include(q => q.Employees) .Include(q => q.Employees .Select(w => w.CitizenshipDescription) ).ToList() ); return(View()); }
static void Main(string[] args) { var t = TreeCreator.CreateTree(); //DepthPreOrderNLR(t); //DepthInOrderLNR(t); //DepthPostOrderLRN(t); var q = new Queue <TreeNode>(); BreadthSearch.BreadthFirstSearch_BottomTopLeftRight(t, q, new Stack <TreeNode>()); System.Console.WriteLine(); System.Console.WriteLine("Program end."); System.Console.Read(); }
private void MainFormLoad(object sender, EventArgs e) { _dataManagerAssembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(assembly => assembly.GetName().Name == "University"); if (_dataManagerAssembly != null) { List <Type> types = _dataManagerAssembly.GetTypes().Where(type => type.Name == "Entry").ToList(); if (types.Count == 0) { return; } _hierarchy = new TypeNode(types[0]); } TreeCreator.Create(_hierarchy); _treeView.Nodes.Add(_hierarchy.Data.Name, _hierarchy.Data.Name); TreeViewCreator.PopulateTreeViewWithHierarchy(_treeView, _hierarchy); }
public IEnumerator GrowTree() { //wait until we hit the ground once (hopefully we'll stay there) yield return(WaitForPlanet()); //wait for some time before spawning tree and setting its planet, and parent yield return(new WaitForSeconds(treeGrowDelay)); GameObject tree = (GameObject)GameObject.Instantiate(treePrefab, transform.position, Quaternion.identity); //, (objGrav.closestPlanet.transform.position - transform.position).normalize); tree.GetComponent <TreeCreator>().segmentCount = gameObject.GetComponent <ObjectGravity>().closestPlanet.GetComponent <TreesOnPlanet>().currentSegmentCount(); GameObject.Destroy(gameObject); TreeCreator tc = tree.GetComponent <TreeCreator>(); tc.planet = objGrav.closestPlanet; //tree.transform.parent = tc.planet.transform; }
private static async Task <TreeNode> CreateTreeFiltered(string path) { var fileSystem = new FileSystem(); var treeCreator = new TreeCreator(fileSystem); var treeFilter = new TreeFilter(fileSystem); treeFilter.PredefinedIgnores = new List <string> { KvdSystemDirectoryPath }; var tree = await treeCreator.Create(path); var treeFiltered = await treeFilter.Filter(tree, path); return(treeFiltered); }
private void NewOperation() { try { string selectedPath = FolderBrowserDialogUtil.InitFolderBrowserDialogForNew(folderBrowserDialog).ShowFolderBrowserDialog(); folderBrowserDialog.Reset(); if (!string.IsNullOrWhiteSpace(selectedPath)) { tvMlbTree.Nodes.Clear(); tvMlbTree.Nodes.Add(TreeCreator.CreateTreeWithPath(selectedPath)); } } catch (Exception ex) { MlbMessageBox.ShowErrorMessageBox(ex.Message); } }
static void Main(string[] args) { TreeCreator<int> creator = new TreeCreator<int>(); creator.ConsoleReader(); Tree<int> sampleTree = creator.CreateTree(); TreeInterator<int> interator = new TreeInterator<int>(sampleTree); Console.WriteLine("Enter sum(int) of elements to look for:"); int seekedSum = int.Parse(Console.ReadLine()); interator.DepthFirstSearch(seekedSum); Console.WriteLine(interator.NodesInformation); Console.WriteLine("Lognest path from root to leaf: " + interator.LongestPathStepCount + " jumps."); Console.WriteLine(interator.LongestPathSteps); Console.WriteLine("Paths sum equlas to {0}:", seekedSum); Console.WriteLine(interator.PathsWithSpecifedSum); }
public void GetByIdTest() { var model = TreeCreator.MakeTree(new CompanyContext().Departaments.Include(q => q.Employees).ToList()) .GetNodes .OrderByDescending(q => q.EmployeeCount) .ThenByDescending(q => q.DepartamentCount) .Take(20) .Select(q => new DepartamentModel { Id = q.Id, Title = q.Name, DCount = q.DepartamentCount, ECount = q.EmployeeCount }) .ToList(); Assert.Fail(); }
public void Test2C() { string[] a = new string[] { "pare (1) -> ugml, padx, fwft", "ugml (68) -> gyxo, ebii, jptl", "padx (45) -> pbga, havc, qoyq", "fwft (72) -> ktlj, cntj, xhth", "gyxo (61)", "ebii (61)", "jptl (61)", "pbga (66)", "havc (66)", "qoyq (66)", "ktlj (57)", "cntj (57)", "xhth (57)" }; string head = Dec7.FindHead(a); TreeCreator builder = new TreeCreator(a, head); Assert.AreEqual(60, builder.FindOffWeight()); }
public override void OnInspectorGUI() { TreeCreator tc = target as TreeCreator; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serializedObject.FindProperty("seed")); EditorGUILayout.PropertyField(serializedObject.FindProperty("height")); EditorGUILayout.PropertyField(serializedObject.FindProperty("radius")); EditorGUILayout.PropertyField(serializedObject.FindProperty("textureScaleX")); EditorGUILayout.PropertyField(serializedObject.FindProperty("textureScaleY")); serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Branch Group " + groupIndex, EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(groupIndex <= 0); if (GUILayout.Button("<", EditorStyles.miniButton)) { groupIndex--; } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(groupIndex >= tc.groups.Count - 1); if (GUILayout.Button(">", EditorStyles.miniButton)) { groupIndex++; } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); groupIndex = EditorGUILayout.IntSlider(groupIndex, 0, tc.groups.Count - 1); InspectBranchGroup(tc, tc.groups[groupIndex]); if (EditorGUI.EndChangeCheck()) { tc.CreateMesh(); } EditorGUILayout.Space(); if (GUILayout.Button("Create Billboards")) { if (!tc.billboardAlbedo) { tc.billboardAlbedo = new Texture2D(1024, 1024, TextureFormat.ARGB32, false); tc.billboardAlbedo.name = tc.gameObject.name + "AlbedoBillboard"; } if (!tc.billboardNormal) { tc.billboardNormal = new Texture2D(1024, 1024, TextureFormat.ARGB32, false); tc.billboardNormal.name = tc.gameObject.name + "NormalBillboard"; } GenerateBillboard(tc.gameObject, tc.GetComponent <MeshFilter>().sharedMesh, tc.GetComponent <MeshRenderer>().sharedMaterials, tc.billboardAlbedo, tc.billboardNormal); if (!AssetDatabase.Contains(tc.billboardAlbedo)) { AssetDatabase.CreateAsset(tc.billboardAlbedo, "Assets/Trees/" + tc.billboardAlbedo.name + ".asset"); } else { EditorUtility.SetDirty(tc.billboardAlbedo); } if (!AssetDatabase.Contains(tc.billboardNormal)) { AssetDatabase.CreateAsset(tc.billboardNormal, "Assets/Trees/" + tc.billboardNormal.name + ".asset"); } else { EditorUtility.SetDirty(tc.billboardNormal); } } }
public void InitializeTest() { treeCreator = new TreeCreator(); }
static void Main(string[] args) { string filePath = @"..\..\..\data\"; //visual studio //string filePath = @".\data\";//visual studio code (project scope) //string filePath = @".\C45\data\";//visual studio code (solution scope) string fileName = "connect-4.csv"; IList <IList <string> > data = new List <IList <string> >(); IList <Column> columns = new List <Column>(); IList <string> columnNames = null; var distinctValues = new List <HashSet <string> >(); #region Read File Console.WriteLine("Start Reading File"); bool isFirstLine = true; foreach (string line in File.ReadLines(Path.Combine(filePath, fileName))) { if (isFirstLine) { isFirstLine = false; columnNames = line.Split(','); for (int i = 0; i < columnNames.Count; i++) { distinctValues.Add(new HashSet <string>()); } continue; } data.Add(line.Split(',')); } Console.WriteLine("End Reading File"); Console.WriteLine("--------------------------"); #endregion #region Split Data Console.WriteLine("Start Splitting Data"); IList <IList <string> > trainingData = new List <IList <string> >(); IList <IList <string> > testData = new List <IList <string> >(); int seed = 13; IList <IList <string> > shuffledData = ShuffleListOfLists(data, seed); float testSize = 0.3f; int testLength = (int)(data.Count * testSize); for (int i = 0; i < testLength; i++) { testData.Add(shuffledData[i]); } for (int i = testLength; i < shuffledData.Count; i++) { trainingData.Add(shuffledData[i]); } Console.WriteLine($"Test set: {testLength} records"); Console.WriteLine($"Traing set: {shuffledData.Count - testLength} records"); Console.WriteLine("End Splitting Data"); Console.WriteLine("--------------------------"); #endregion #region Process Data Console.WriteLine("Start Processing Data"); for (int i = 0; i < trainingData.Count; i++) { for (int j = 0; j < trainingData[i].Count; j++) { if (trainingData[i][j] != "?") { distinctValues[j].Add(trainingData[i][j]); } } } for (int i = 0; i < columnNames.Count; i++) { bool isNominal = false; foreach (string val in distinctValues[i]) { if (!double.TryParse(val, out double val2)) { isNominal = true; break; } } Column col = new Column(columnNames[i], i, isNominal); col.Values = distinctValues[i].ToList(); columns.Add(col); } Console.WriteLine("End Processing Data"); Console.WriteLine("--------------------------"); #endregion #region Create Tree Console.WriteLine("Start Creating Tree"); Node tree = TreeCreator.CreateTree(trainingData, columns); Console.WriteLine("End Creating Tree"); Console.WriteLine("--------------------------"); #endregion #region Predict /*Console.WriteLine("Deciding"); * int rightDecisions = 0; * int missingRows = 0; * foreach (var row in data) * { * if (row.Any(s => s == "?")) * { * missingRows++; * continue; * } * string decision = tree.Decide(row); * if (decision == row[row.Count - 1]) * rightDecisions++; * //Console.WriteLine($"[{decision}] | [{row[row.Count - 1]}]"); * } * Console.WriteLine($"{rightDecisions}/{data.Count - missingRows} right decisions"); * Console.WriteLine("Decided"); * Console.WriteLine("--------------------------");*/ Console.WriteLine("Start Predicting"); int rightPredictions = 0; foreach (var row in testData) { string decision = tree.Decide(row); if (decision == row[row.Count - 1]) { rightPredictions++; } } Console.WriteLine($"{rightPredictions}/{testData.Count} right predictions"); Console.WriteLine("End Predicting"); Console.WriteLine("--------------------------"); #endregion Console.WriteLine("Done!"); }
public ObservableCollection <Node> Parse(string path) { TreeCreator treeCreator = new TreeCreator(); return(new ObservableCollection <Node>(treeCreator.BuildTree(path))); }
private void doGraph() { var s = GameObject.Find("Canvas").GetComponent <TreeCreator>().GetText(); var PS = GetComponent <ParticleSystem>(); //call visitor here s = TreeCreator.Creator(s); //Debug.Log(s); // Method 2 start string source = @" using System; using System.Collections; using System.Collections.Generic; namespace test { public class MyType { public static double Evaluate(float x, float y, float z) { return (double) <!expression!>; } } } "; // Initialice parameters. string expression = s; // Replace parameters in source. string finalSource = source.Replace("<!expression!>", expression); //Debug.Log(finalSource); tcpclnt = new TcpClient(); try { // Deploy IP - c5.xlarge //var ip = "34.205.15.170"; // Development IP - t2.micro //var ip = "18.208.138.62"; // Localhost testings var ip = "localhost"; var port = 8081; tcpclnt.Connect(ip, port); string str = "212 $ " + finalSource; Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen = new ASCIIEncoding(); byte[] ba = asen.GetBytes(str); stm.Write(ba, 0, ba.Length); byte[] bb = new byte[1024]; int k = stm.Read(bb, 0, 1024); string response = ""; for (int i = 0; i < k; i++) { response += Convert.ToChar(bb[i]); } } catch (Exception e) { Debug.Log("Error " + e); } // Make points into an Array. pointsArray = points.ToArray(); // Do Work... StartCoroutine(TCPRequest()); }