static void Main() { FuzzyApp.Initalize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Main()); }
private void OKBtn_Click(object sender, EventArgs e) { LingVariable temp; if (TypeCombo.SelectedItem.Equals("Input")) { temp = new LingVariable(NameTxT.Text, VarType.Input); List <double> rang = FuzzyApp.tokString(RangeTxT.Text); temp.setRange(rang[0], rang[1]); double value = (rang[1] - rang[0]) * 0.5; temp.addMF(new Trimf("mf", rang[0], (rang[0] + value), rang[1])); FuzzyApp.InputVariables.Add(temp); ParentTab.SelectedTab = ParentTab.TabPages[0]; } else { temp = new LingVariable(NameTxT.Text, VarType.Output); List <double> rang = FuzzyApp.tokString(RangeTxT.Text); temp.setRange(rang[0], rang[1]); double value = (rang[1] - rang[0]) * 0.5; temp.addMF(new Trimf("mf", rang[0], (rang[0] + value), rang[1])); FuzzyApp.OutputVariables.Add(temp); ParentTab.SelectedTab = ParentTab.TabPages[1]; } this.Close(); }
private void MfBtn_Click(object sender, EventArgs e) { if (!MFView.Items.ContainsKey(MFNameTxT.Text)) { List <double> pts = FuzzyApp.tokString(MFParamTxT.Text); FuzzyLogicController.MFs.MemberShipFunction mftemp; if (MFTypeCombo.SelectedIndex == 0) { mftemp = new FuzzyLogicController.MFs.Trimf(MFNameTxT.Text, pts[0], pts[1], pts[2]); Current.MFs.Add(mftemp); popualteMF(mftemp); } else if (MFTypeCombo.SelectedIndex == 1) { mftemp = new FuzzyLogicController.MFs.Trapmf(MFNameTxT.Text, pts[0], pts[1], pts[2], pts[3]); Current.MFs.Add(mftemp); popualteMF(mftemp); } Populate(); this.ChartPanel.Paint += new PaintEventHandler(drawSelectedMF); this.ChartPanel.Refresh(); } else { MessageBox.Show("It Exists!!! Try a new mf name", "MemberShip Function Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void CloseToolStripMenuItem_Click(object sender, EventArgs e) { FuzzyApp.Initalize(); variable1.ClearVariable(); InputView.Clear(); OutputView.Clear(); reultsUI1.loadVariables(); }
private void OnRangeEdit(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Current.Range = FuzzyApp.tokString(RangeTxT.Text); this.ChartPanel.Paint += new PaintEventHandler(drawSelectedMF); this.ChartPanel.Refresh(); Populate(); } }
private void SaveMFBtn_Click(object sender, EventArgs e) { if (MFView.Items.Count > 0) { Current.MFs[MFView.SelectedIndices[0]].Name = MFNameTxT.Text; MFView.Items[MFView.SelectedIndices[0]].Name = MFNameTxT.Text; MFView.Items[MFView.SelectedIndices[0]].Text = MFNameTxT.Text; Current.MFs[MFView.SelectedIndices[0]].Params = FuzzyApp.tokString(MFParamTxT.Text); this.ChartPanel.Paint += new PaintEventHandler(drawSelectedMF); this.ChartPanel.Refresh(); Populate(); } }
private void Test2ToolStripMenuItem_Click(object sender, EventArgs e) { FuzzyApp.Initalize(); variable1.ClearVariable(); InputView.Clear(); OutputView.Clear(); FuzzyApp.defaultSettings2(); if (FuzzyApp.InputVariables.Count > 0) { variable1.Current = FuzzyApp.InputVariables[0]; variable1.Populate(); populateVariables(); } }
public RuleItemUI(String var, InOutType Type) { this.Name = var; InitializeComponent(); if (Type == InOutType.In) { _current = FuzzyApp.getVariablebyName(FuzzyApp.InputVariables, var); } else { _current = FuzzyApp.getVariablebyName(FuzzyApp.OutputVariables, var); } VarText.Text = _current.Name; this.Name = var; MFCombo.DataSource = _current.MFs; MFCombo.ValueMember = "Name"; MFCombo.DisplayMember = "Name"; MFCombo.SelectedValue = ((FuzzyLogicController.MFs.MemberShipFunction)MFCombo.Items[0]).Name; _item = new RuleItem(_current.Name, (String)MFCombo.SelectedValue); }
private void InTxT_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { clearAll(); List <double> inputs = FuzzyApp.tokString(InTxT.Text); CrispPan.RowCount = FuzzyApp.InputVariables.Count; for (int i = 0; i < FuzzyApp.InputVariables.Count; i++) { CrispPan.Controls.Add(TextLabel(FuzzyApp.InputVariables[i].Name + " : " + inputs[i], TextType.Normal)); } //Fuzzification List <FuzzySet> InSets = new List <FuzzySet>(); for (int i = 0; i < FuzzyApp.InputVariables.Count; i++) { InSets.Add(new FuzzySet(FuzzyApp.FuzzyControl.Fuzzification(inputs[i], FuzzyApp.InputVariables[i]), FuzzyApp.InputVariables[i].Name)); } for (int i = 0; i < InSets.Count; i++) { FuzzPan.Controls.Add(TextLabel(InSets[i].Variable, TextType.Normal)); for (int j = 0; j < InSets[i].Set.Count; j++) { FuzzPan.Controls.Add(TextLabel(InSets[i].Set[j].MemberShipName + ":" + InSets[i].Set[j].FuzzyValue.ToString(), TextType.Normal)); } } //Inference Engine InferEngine engine = new InferEngine(FuzzyApp.Configuration, FuzzyApp.Rules, InSets); List <FuzzySet> RuleResults = engine.evaluateRules(); EnginePan.Controls.Add(TextLabel("Сработавшие правила ", TextType.Header)); for (int i = 0; i < engine.FiredRules.Count; i++) { EnginePan.Controls.Add(TextLabel("Правило " + engine.FiredRules[i].ToString(), TextType.Normal, FuzzyApp.Rules[engine.FiredRules[i] - 1].ToString())); } for (int i = 0; i < RuleResults.Count; i++) { DeFuzzPan.Controls.Add(TextLabel(RuleResults[i].Variable, TextType.Header)); for (int j = 0; j < RuleResults[i].Set.Count; j++) { DeFuzzPan.Controls.Add(TextLabel(RuleResults[i].Set[j].MemberShipName + " : " + RuleResults[i].Set[j].FuzzyValue.ToString(), TextType.Normal)); } } //deFuzzification List <double> CrispValues = new List <double>(); for (int i = 0; i < FuzzyApp.OutputVariables.Count; i++) { CrispValues.Add(FuzzyApp.FuzzyControl.DeFuzzification(RuleResults, FuzzyApp.OutputVariables[i])); } for (int i = 0; i < CrispValues.Count; i++) { String text = FuzzyApp.OutputVariables[i].Name + " : " + CrispValues[i].ToString(); CrispView.Items.Add(text); } } }