private void ButtonAddFluent_Click(object sender, RoutedEventArgs e) { if (TextBoxFluents.Text == "") { LabelFluentsActionsValidation.Content = "Fluent name is required."; return; } if (!System.Text.RegularExpressions.Regex.IsMatch(TextBoxFluents.Text, @"[a-zA-Z]+[a-zA-Z0-9\-]*$")) { LabelFluentsActionsValidation.Content = "Fluent name should be alphanumeric."; return; } if (!Fluents.Contains(Fluents.FirstOrDefault(f => (f.Name == TextBoxFluents.Text)))) { var f = new Fluent { Name = this.TextBoxFluents.Text }; Fluents.Add(f); TextBoxFluents.Text = ""; LabelFluentsActionsValidation.Content = ""; } else { LabelFluentsActionsValidation.Content = "Fluent with this name already exists."; } }
private void findAllStates() { int n = Fluents.Count; int NumOfStates = (int)Math.Pow(2, n); List <State> AllStates = new List <State>(); Fluent[] allFluents = Fluents.ToArray(); for (int i = 0; i < NumOfStates; i++) { bool[] fluentsSign = Utility.DecimalToBinary(i, n); Hashtable stateFluents = new Hashtable(); for (int j = 0; j < n; j++) { stateFluents.Add(allFluents[j], fluentsSign[j]); } AllStates.Add(new State(stateFluents)); } this.states = AllStates; if (Always != null) { foreach (Formula f in Always) { List <State> newState = f.GetResultStates(); this.states = newState; } } }
public void AddFluent(string fluent) { var negFluent = "not_" + fluent; Fluents.Add(fluent); Fluents.Add(negFluent); Negations.Add($"negation({fluent}, {negFluent})."); Negations.Add($"negation({negFluent}, {fluent})."); }
private void ButtonRemoveFluent_Click(object sender, RoutedEventArgs e) { if (ListBoxFluents.SelectedIndex == -1) { return; } var fluent = (Fluent)ListBoxFluents.SelectedValue; Fluents.Remove(fluent); }
public HashSet <string> New(string agent, string action, AppState state, AppState state2) { var fluent = Fluents.Where(p => p.IsInertial) .Where(p => state.GetVariable(p.Label) != state2.GetVariable(p.Label)) .Select(p => p.Label).ToList(); var releasesFluent = history.Releases .Where(p => p.Action == action) .Where(p => p.Agents == null || p.Agents.Contains(agent)) .Where(p => state.EvaluateCondition(p.Condition)) .Select(p => p.Fluent).ToList(); return(new HashSet <string>(fluent.Union(releasesFluent))); }
public void Clear() { Fluents.Clear(); Negations.Clear(); }