public static Action <T1, T2, T3> cast <T1, T2, T3>(SameAction handler) { return((T1 p1, T2 p2, T3 p3) => handler(p1, p2, p3)); }
public static Action <T1, T2> cast <T1, T2>(SameAction handler) { return((T1 p1, T2 p2) => handler(p1, p2)); }
public static Action <T1> cast <T1>(SameAction handler) { return((T1 p1) => handler(p1)); }
public static Action cast(SameAction handler) { return(() => handler()); }
private List <string> ComputeVotingPrefix(List <List <string> > lPlans, Domain d) { List <string> lJointPrefix = new List <string>(); List <List <string> > lPlansSuffix = new List <List <string> >(); foreach (List <string> lPlan in lPlans) { lPlansSuffix.Add(FilterReasoningActions(lPlan)); } string sCurrentAction = ""; SameAction sa = new SameAction(); while (lPlansSuffix.Count >= lPlans.Count / 2 && lPlansSuffix[0].Count > 0) { bool bFoundObservationAction = false; Dictionary <string, int> dVotes = new Dictionary <string, int>(sa); foreach (List <string> lPlan in lPlansSuffix) { if (lPlan.Count > 0) { while (d.IsObservationAction(lPlan[0])) { if (!lJointPrefix.Contains(lPlan[0])) { lJointPrefix.Add(lPlan[0]); } bFoundObservationAction = true; lPlan.RemoveAt(0); } sCurrentAction = lPlan[0]; if (!dVotes.ContainsKey(sCurrentAction)) { dVotes[sCurrentAction] = 0; } dVotes[sCurrentAction]++; } } if (bFoundObservationAction) { break; } string sMaxAction = dVotes.Keys.First(); foreach (KeyValuePair <string, int> p in dVotes) { if (p.Value > dVotes[sMaxAction]) { sMaxAction = p.Key; } } lJointPrefix.Add(sMaxAction); List <List <string> > lNewSuffixes = new List <List <string> >(); foreach (List <string> lPlan in lPlansSuffix) { if (lPlan.Count > 0 && sa.Equals(lPlan[0], sMaxAction)) { lPlan.RemoveAt(0); lNewSuffixes.Add(lPlan); } } lPlansSuffix = lNewSuffixes; } return(lJointPrefix); }
private List <string> ComputeSensingPrefix(List <List <string> > lPlans, Domain d) { List <string> lJointPrefix = new List <string>(); List <List <string> > lPlansSuffix = new List <List <string> >(); foreach (List <string> lPlan in lPlans) { lPlansSuffix.Add(FilterReasoningActions(lPlan)); } SameAction sa = new SameAction(); List <string> lFirstSensingPlan = null, lShortestPlan = null; int iFirstSensingAction = -1; int iAction = 0; int cPlans = lPlansSuffix.Count; for (iAction = 0; cPlans > 0 && lFirstSensingPlan == null; iAction++) { foreach (List <string> lPlan in lPlansSuffix) { if (lPlan.Count == iAction) { if (lShortestPlan == null) { lShortestPlan = lPlan; } cPlans--; } if (iAction < lPlan.Count && d.IsObservationAction(lPlan[iAction])) { iFirstSensingAction = iAction; lFirstSensingPlan = lPlan; } } } if (lFirstSensingPlan == null) { lFirstSensingPlan = lShortestPlan; } if (iFirstSensingAction == -1) { iFirstSensingAction = lFirstSensingPlan.Count; } for (iAction = 0; iAction < iFirstSensingAction; iAction++) { List <List <string> > lNewSuffixes = new List <List <string> >(); foreach (List <string> lPlan in lPlansSuffix) { if (sa.Equals(lPlan[iAction], lFirstSensingPlan[iAction])) { lNewSuffixes.Add(lPlan); } } lJointPrefix.Add(lFirstSensingPlan[iAction]); lPlansSuffix = lNewSuffixes; } foreach (List <string> lPlan in lPlansSuffix) { for (iAction = iFirstSensingAction; iAction < lPlan.Count; iAction++) { if (d.IsObservationAction(lPlan[iAction])) { if (!lJointPrefix.Contains(lPlan[iAction])) { lJointPrefix.Add(lPlan[iAction]); } } else { break; } } } return(lJointPrefix); }