public static ElementalArray CompareMembership(ElementalArray array) { ElementalArray firstResult = (ElementalArray)array.Elements[0].Value; ElementalArray secondResult = (ElementalArray)array.Elements[1].Value; ElementalArray membershipLess = StaticConstants.False; ElementalArray membershipEqual = StaticConstants.False; ElementalArray membershipGreater = StaticConstants.False; if (firstResult == StaticConstants.True) { if (secondResult == StaticConstants.True) { membershipEqual = StaticConstants.True; } else { membershipGreater = StaticConstants.True; } } else { if (secondResult == StaticConstants.True) { membershipLess = StaticConstants.True; } else { membershipEqual = StaticConstants.True; } } return(new ElementalArray(new[] { membershipLess, membershipEqual, membershipGreater })); }
private static void ElementalUnitArrayAddToList <T>(List <T> instance, ElementalArray array) { foreach (var item in array.Elements) { T value = ElementalUnitArrayTo <T>(item.Value); instance.Add(value); } }
public FuzzyElementWiseUnitCompareLoop(ElementalArray lhs, ElementalArray rhs) { // if GetLoopControlMembership(ElementWiseUnitComparer) // => Comparer.MovedNext And ComparisonResult = Membership.Equal // ComparisonResult = UnitEnumeratorCompare(lhs.Enumerator, rhs.Enumerator) // => {lhs.Current ^ rhs.Current} ? Membership.Equal : (lhs.Current ? Membership.Greater: Membership.Less); /* Fuzzy Rules: * if LoopStateNone Then Init * if LoopStateInit Then Loop * if LoopStateLoop Then Evaluate * if LoopStateEvaluate and Evaluate() Then LoopAction * if LoopStateLoopBody Then LoopAction(); * if LoopStateDone Then LoopExit(); */ /* * If NotLoopInitialized then Initialize * If InLoopBody Then ExecuteLoop() * --- or -- * If Not LoopFinished Then ExecuteLoop() * --- Generic rule * If Not ReachedTarget Then Move() * */ dynamic LoopState = null; dynamic LoopStateNone = null; dynamic LoopStateInit = null; dynamic LoopStateLoop = null; dynamic LoopStateEvaluate = null; dynamic LoopStateLoopAction = null; dynamic LoopInit = null; dynamic Loop = null; dynamic Evaluate = null; dynamic LoopAction = null; var loopActions = new Dictionary <dynamic, dynamic> { { LoopStateNone, LoopInit }, { LoopStateInit, Loop }, { LoopStateLoop, Evaluate }, { LoopStateEvaluate, LoopAction }, { LoopStateLoopAction, Loop }, }; Func <dynamic, dynamic> GetMembership = (state) => { return(loopActions[state]); }; var loopMembership = GetMembership(LoopState); }
public static T ElementalUnitArrayTo <T>(ElementalArray array) { dynamic incremental = default(T); var type = typeof(T); if (!type.IsValueType)// Hmmm!!! Require UserDefined Conversion operators? { incremental = Activator.CreateInstance <T>(); } if (type == typeof(bool)) { incremental = array.Elements.Count > 0; } else if (type.IsArray) { var listType = typeof(List <>); var genericType = listType.MakeGenericType(type.GetElementType()); dynamic listInstance = Activator.CreateInstance(genericType); ElementalUnitArrayAddToList(listInstance, array); return(listInstance.ToArray()); } else if (type == typeof(string)) { StringBuilder sb = new System.Text.StringBuilder(); foreach (var item in array.Elements) { char c = ElementalUnitArrayTo <char>(item.Value); sb.Append(c); } incremental = sb.ToString(); } else { var enumerator = array.Elements.GetEnumerator(); while (enumerator.MoveNext()) { incremental++; } } return(incremental); }
public ElementArraySiblingEnumerator(ElementalArray elementalArray) { this.elementalArray = elementalArray; }
public ElementalUnitCompareEnumerator(ElementalArray a, ElementalArray b) { this.elementalArrayA = a; this.elementalArrayB = b; }
public static ElementalArray IsGreaterOrEqual(ElementalArray comparisonMembership) => (ElementalArray)comparisonMembership.Elements[1].Value == StaticConstants.True ? StaticConstants.False : StaticConstants.True;
public static ElementalArray IsGreater(ElementalArray comparisonMembership) => (ElementalArray)comparisonMembership.Elements[2].Value;
public static ElementalArray IsEqual(ElementalArray comparisonMembership) => (ElementalArray)comparisonMembership.Elements[1].Value;
// built in operators: Implement as Linguistic variables. public static ElementalArray IsLessThan(ElementalArray comparisonMembership) => (ElementalArray)comparisonMembership.Elements[0].Value;