public static IFuzzySet CompositionOfBinaryRelations(IFuzzySet relation1, IFuzzySet relation2, IBinaryFunction tNorm, IBinaryFunction sNorm) //zadatak ne specificira koristi li se max-min kompozicija { //stoga je konfigurabilno MutableFuzzySet compositeRelation = new MutableFuzzySet(Domain.Combine(relation1.GetDomain().GetComponent(0), relation2.GetDomain().GetComponent(1))); if (relation1 == relation2) //jer ugnjezdjeni foreach nad istom 'relation' instancom stvara probleme { relation2 = DeepCopy(relation1); } foreach (DomainElement element1 in compositeRelation.GetDomain()) { int x = element1.GetComponentValue(0); int z = element1.GetComponentValue(1); double funccomp = compositeRelation.GetValueAt(DomainElement.Of(x, z)); double Max = 0; foreach (DomainElement element_a in relation1.GetDomain()) //funca { foreach (DomainElement element_b in relation2.GetDomain()) //funcb { if (element_a.GetComponentValue(1) == element_b.GetComponentValue(0)) { int y = element_a.GetComponentValue(1); //y Max = sNorm.ValueAt(tNorm.ValueAt(relation1.GetValueAt(DomainElement.Of(x, y)), relation2.GetValueAt(DomainElement.Of(y, z))), Max); } } } compositeRelation.Set(DomainElement.Of(x, z), Max); } return(compositeRelation); }
public static IFuzzySet BinaryOperation(IFuzzySet set1, IFuzzySet set2, IBinaryFunction function) { var newSet = new MutableFuzzySet(set1.GetDomain()); foreach (var element in set1.GetDomain()) { newSet.Set(element, function.ValueAt(set1.GetValueAt(element), set2.GetValueAt(element))); } return(newSet); }
public static IFuzzySet BinaryOperation(IFuzzySet fuzzySetA, IFuzzySet fuzzySetB, IBinaryFunction binary) { MutableFuzzySet A = new MutableFuzzySet(fuzzySetA.GetDomain()); //if (fuzzySetA.GetDomain() != fuzzySetB.GetDomain()) //{ // if (fuzzySetA.GetDomain().GetComponent(fuzzySetA.GetDomain().GetNumberOfComponents() - 1) != fuzzySetB.GetDomain().GetComponent(fuzzySetB.GetDomain().GetNumberOfComponents() - 1)) // { // Console.WriteLine("Can't do binary operation on sets with different domains"); // return A; // } //} foreach (DomainElement e in fuzzySetA.GetDomain()) { A.Set(e, binary.ValueAt(fuzzySetA.GetValueAt(e), fuzzySetB.GetValueAt(e))); } return(A); }