public void init(FuzzyTable table) { this.table = table; this.t = 0; this.rules = new List <Rule>(); this.Q = new List <List <string> >(); this.Q.Add(this.table.getAllAttributes()); this.Q1 = new List <List <string> >(); this.Q2 = new List <List <string> >(); this.L = new List <List <string> >(this.Q);; this.maxLength = this.Q[this.t].Count - 1; this.currentLength = new List <int>(); this.currentLength.Add(1); this.isVariableNotRemoved = new List <bool>(); this.isVariableNotRemoved.Add(false); this.C = this.table.getClassAttribute(); this.P = new List <int>(this.table.GetTable().Rows.Count); for (int i = 0; i < this.table.GetTable().Rows.Count; i++) { this.P.Add(i); } this.I = new List <List <int> >(); this.I.Add(P); this.Z = new List <List <int> >(); this.Z.Add(P); this.I1 = new List <List <int> >(); this.I2 = new List <List <int> >(); this.Lreduced = new List <List <string> >(); this.R = new List <Rule>(); this.stepsStack = new Stack <StepData>(); }
private void RemoveAttribute(FuzzyAttribute removeAttribute) { List <FuzzyAttribute> completeList = attributes.attributes.ToList(); completeList.Remove(removeAttribute); attributes.attributes = completeList.ToArray(); UpdateNameList(); }
private void SetDefaultValues(FuzzyAttribute selectedAttribute) { UpdateOrder(selectedAttribute); for (int i = 0; i < selectedAttribute.descriptors.Length; i++) { selectedAttribute.descriptors[i].value = (1f / (selectedAttribute.descriptors.Length)) * (i + 1); } }
private void CreateNewFuzzyAttributes() { List <FuzzyAttribute> completeList = attributes.attributes.ToList(); FuzzyAttribute newFuzzyAttr = new FuzzyAttribute(); newFuzzyAttr.name = newName; newFuzzyAttr.descriptors = new FuzzyDescriptor[newAttributes.Count]; for (int i = 0; i < newAttributes.Count; i++) { newFuzzyAttr.descriptors [i] = new FuzzyDescriptor(); newFuzzyAttr.descriptors [i].name = newAttributes [i].name; newFuzzyAttr.descriptors [i].value = (1f / (newAttributes.Count)) * (i + 1); } completeList.Add(newFuzzyAttr); attributes.attributes = completeList.ToArray(); //Save (); //Load (); UpdateNameList(); }
// Use this for initialization void OnGUI() { EditorGUILayout.Space(); selectedIndex = EditorGUILayout.Popup(selectedIndex, attributeNames); FuzzyAttribute selectedAttribute = attributes.attributes [selectedIndex]; foreach (FuzzyDescriptor descr in selectedAttribute.descriptors) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(descr.name); descr.value = EditorGUILayout.Slider(descr.value, 0f, 1f); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Remove")) { RemoveAttribute(selectedAttribute); selectedIndex = 0; } if (GUILayout.Button("Update Order")) { UpdateOrder(selectedAttribute); //Save(); Save(); } if (GUILayout.Button("Default Values")) { SetDefaultValues(selectedAttribute); } if (GUILayout.Button("Save Changes")) { Save(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); Separator(); if (!isCreatingNew && GUILayout.Button("Create New")) { //CreateXML (); isCreatingNew = true; } if (isCreatingNew) { List <NewAttribute> removalList = new List <NewAttribute> (); newName = EditorGUILayout.TextField("Name", newName); for (int i = 0; i < newAttributes.Count; i++) { EditorGUILayout.BeginHorizontal(); newAttributes[i].name = EditorGUILayout.TextField(newAttributes[i].name); if (GUILayout.Button("x", GUILayout.Width(20))) { removalList.Add(newAttributes [i]); } EditorGUILayout.EndHorizontal(); } newAttributes.RemoveAll(s => removalList.Contains(s)); if (GUILayout.Button("Add")) { newAttributes.Add(new NewAttribute("Empty" + NewAttribute._id.ToString())); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { isCreatingNew = false; newName = "New Attribute"; InitNewAttribute(); } if (GUILayout.Button("Apply")) { CreateNewFuzzyAttributes(); InitNewAttribute(); Save(); //selectedIndex = attributes.attributes.Length - 1; } EditorGUILayout.EndHorizontal(); } }
private void UpdateOrder(FuzzyAttribute selectedAttribute) { selectedAttribute.descriptors = selectedAttribute.descriptors.ToList().OrderBy(d => d.value).ToArray(); }