public static void Primjer23() { IDomain u = Domain.IntRange(1, 5); // {1,2,3,4} IFuzzySet r = new MutableFuzzySet(Domain.Combine(u, u)) .Set(DomainElement.Of(1, 1), 1) .Set(DomainElement.Of(2, 2), 1) .Set(DomainElement.Of(3, 3), 1) .Set(DomainElement.Of(4, 4), 1) .Set(DomainElement.Of(1, 2), 0.3) .Set(DomainElement.Of(2, 1), 0.3) .Set(DomainElement.Of(2, 3), 0.5) .Set(DomainElement.Of(3, 2), 0.5) .Set(DomainElement.Of(3, 4), 0.2) .Set(DomainElement.Of(4, 3), 0.2); IFuzzySet r2 = r; Console.WriteLine("Početna relacija je neizrazita relacija ekvivalencije? " + Relations.Relations.IsFuzzyEquivalence(r2)); Console.WriteLine(); for (int i = 1; i <= 3; i++) { r2 = Relations.Relations.CompositionOfBinaryRelations(r2, r, Operations.Operations.ZadehAnd(), Operations.Operations.ZadehOr()); Console.WriteLine("Broj odrađenih kompozicija: " + i + ". Relacija je:"); foreach (DomainElement e in r2.GetDomain()) { Console.WriteLine("mu(" + e + ")=" + r2.GetValueAt(e)); } Console.WriteLine("Ova relacija je neizrazita relacija ekvivalencije? " + Relations.Relations.IsFuzzyEquivalence(r2)); Console.WriteLine(); } }
public static bool IsMaxMinTransitive(IFuzzySet relation) { if (!IsUTimesURelation(relation)) { return(false); } IDomain domain = relation.GetDomain()[0]; foreach (var x in domain) { foreach (var z in domain) { var value = 0.0; foreach (var y in domain) { var xy = relation.GetValueAt(DomainElement.Of(x[0], y[0])); var yz = relation.GetValueAt(DomainElement.Of(y[0], z[0])); value = Math.Max(value, Math.Min(xy, yz)); } if (value > relation.GetValueAt(DomainElement.Of(x[0], z[0]))) { return(false); } } } return(true); }
public BadDirection(string name) { Name = name; FuzzySet = new MutableFuzzySet(IDomain.IntRange(0, 2)) .Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.0); }
public static bool IsMaxMinTransitive(IFuzzySet relation) { IFuzzySet copiedRelation = DeepCopy(relation); //jer ugnjezdjeni foreach nad istom 'relation' instancom stvara probleme foreach (DomainElement element1 in relation.GetDomain()) { int x = element1.GetComponentValue(0); int z = element1.GetComponentValue(1); double funcxz = relation.GetValueAt(DomainElement.Of(x, z)); double Max = 0; foreach (DomainElement element2 in copiedRelation.GetDomain()) { if (element2.GetComponentValue(0) == element2.GetComponentValue(1)) { int y = element2.GetComponentValue(0); if (Math.Min(copiedRelation.GetValueAt(DomainElement.Of(x, y)), copiedRelation.GetValueAt(DomainElement.Of(y, z))) > Max) { Max = Math.Min(copiedRelation.GetValueAt(DomainElement.Of(x, y)), copiedRelation.GetValueAt(DomainElement.Of(y, z))); } } } if (funcxz < Max) { return(false); } } return(true); }
public static void Test32() { IDomain u = Domain.IntRange(-5, 6); // {-5,-4,...,4,5} IDomain u2 = Domain.Combine(u, u); IFuzzySet set = new CalculatedFuzzySet( u2, StandardFuzzySets.LambdaFunction( u2.IndexOfElement(DomainElement.Of(-4, 2)), u2.IndexOfElement(DomainElement.Of(0, 0)), u2.IndexOfElement(DomainElement.Of(4, 2)) ) ); Debug1.Print(set, "Set cf:"); IFuzzySet notSet1 = Operations.Operations.UnaryOperation( set, Operations.Operations.ZadehNot()); Debug1.Print(notSet1, "notSet1:"); IFuzzySet union = Operations.Operations.BinaryOperation( set, notSet1, Operations.Operations.ZadehOr()); Debug1.Print(union, "Set1 union notSet1:"); }
private static void Main() { var d = Domain.IntRange(0, 11); // {0,1,...,10} IFuzzySet set1 = new MutableFuzzySet(d) .Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); Console.WriteLine("Set 1:"); Console.WriteLine(set1); Console.WriteLine(); var d2 = Domain.IntRange(-5, 6); // {-5,-4,...,4,5} IFuzzySet set2 = new CalculatedFuzzySet( d2, StandardFuzzySets.LambdaFunction( d2.IndexOfElement(DomainElement.Of(-4)), d2.IndexOfElement(DomainElement.Of(0)), d2.IndexOfElement(DomainElement.Of(4)) ) ); Console.WriteLine("Set 2:"); Console.WriteLine(set2); Console.WriteLine(); Console.ReadKey(); }
private static void Main() { var d = Domain.IntRange(0, 11); // {0,1,...,10} IFuzzySet set1 = new MutableFuzzySet(d) .Set(DomainElement.Of(0), 0.4) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); Console.WriteLine("Set 1:"); Console.WriteLine(set1); Console.WriteLine(); var notSet1 = Operations.UnaryOperation(set1, Operations.ZadehNot()); Console.WriteLine("notSet 1:"); Console.WriteLine(notSet1); Console.WriteLine(); var union = Operations.BinaryOperation(set1, notSet1, Operations.ZadehOr()); Console.WriteLine("Set1 union notSet1:"); Console.WriteLine(union); Console.WriteLine(); var hinters = Operations.BinaryOperation(set1, notSet1, Operations.HamacherTNorm(1.0)); Console.WriteLine("Set1 intersection with notSet1 using parameterised Hamacher T norm with parameter 1.0:"); Console.WriteLine(hinters); Console.WriteLine(); Console.ReadKey(); }
public static IFuzzySet CompositionOfBinaryRelations(IFuzzySet r1, IFuzzySet r2) { IDomain xDomain = r1.GetDomain()[0]; IDomain yDomain = r1.GetDomain()[1]; IDomain zDomain = r2.GetDomain()[1]; var result = new MutableFuzzySet(Domain.Combine(xDomain, zDomain)); var or = Operations.ZadehOr(); var and = Operations.ZadehAnd(); foreach (var x in xDomain) { foreach (var z in zDomain) { var value = 0.0; foreach (var y in yDomain) { var value1 = r1.GetValueAt(DomainElement.Of(x[0], y[0])); var value2 = r2.GetValueAt(DomainElement.Of(y[0], z[0])); value = or(value, and(value1, value2)); } result.Set(DomainElement.Of(x[0], z[0]), value); } } return(result); }
public IFuzzySet SingleRuleConclusionProduct(int L, int D, int LK, int DK, int V, int S) //TODO napravi varijantu i za StrojMinimum i za StrojProdukt { double[] antecMembershipFunctions = new double[] { _antec1.GetValueAt(DomainElement.Of(L)), _antec2.GetValueAt(DomainElement.Of(D)), _antec3.GetValueAt(DomainElement.Of(LK)), _antec4.GetValueAt(DomainElement.Of(DK)), _antec5.GetValueAt(DomainElement.Of(V)), _antec6.GetValueAt(DomainElement.Of(S)) }; double prodMembershipFunc = 1; foreach (double var in antecMembershipFunctions) { prodMembershipFunc *= var; } IFuzzySet antecedents = new CalculatedFuzzySet( //mjere pripadnosti su na minimumu mj.pripadnosti antecedenata _conseq.GetDomain(), StandardFuzzySets.UniversalFunction(prodMembershipFunc) ); //KormiloFuzzySystemMin.Print(antecedents, "antecedents:"); //KormiloFuzzySystemMin.Print(_conseq, "_conseq:"); //KormiloFuzzySystemMin.Print(_antec5, "_antec:"); IFuzzySet conclusion = Operations.Operations.BinaryOperation(antecedents, _conseq, Operations.Operations.AlgProduct()); //KormiloFuzzySystemMin.Print(conclusion, "conclusion:"); return(conclusion); }
private static void PrintExample3() { Console.WriteLine("EXAMPLE 3"); IDomain d = IDomain.IntRange(0, 11); IFuzzySet set1 = new MutableFuzzySet(d).Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); PrintFuzzySet(set1, "Set1: "); IFuzzySet notSet1 = Operations.UnaryOperation(set1, Operations.ZadehNot()); PrintFuzzySet(notSet1, "notSet1: "); IFuzzySet union = Operations.BinaryOperation(set1, notSet1, Operations.ZadehOr()); PrintFuzzySet(union, "Set1 U notSet1: "); IFuzzySet hinters = Operations.BinaryOperation(set1, notSet1, Operations.HamacherTNorm(1.0)); PrintFuzzySet(hinters, "Set1 Intersection with notSet1 using parameterised Hamacher T norm with parameter 1.0: "); Console.WriteLine("---------------------------------------"); Console.WriteLine(); }
private static void PrintExample5() { Console.WriteLine("EXAMPLE 5"); IDomain u1 = IDomain.IntRange(1, 5); // {1,2,3,4} IDomain u2 = IDomain.IntRange(1, 4); // {1,2,3} IDomain u3 = IDomain.IntRange(1, 5); // {1,2,3,4} IFuzzySet r1 = new MutableFuzzySet(IDomain.Combine(u1, u2)) .Set(DomainElement.Of(1, 1), 0.3) .Set(DomainElement.Of(1, 2), 1) .Set(DomainElement.Of(3, 3), 0.5) .Set(DomainElement.Of(4, 3), 0.5); IFuzzySet r2 = new MutableFuzzySet(IDomain.Combine(u2, u3)) .Set(DomainElement.Of(1, 1), 1) .Set(DomainElement.Of(2, 1), 0.5) .Set(DomainElement.Of(2, 2), 0.7) .Set(DomainElement.Of(3, 3), 1) .Set(DomainElement.Of(3, 4), 0.4); IFuzzySet r1r2 = Relations.CompositionOfBinaryRelations(r1, r2) !; foreach (var element in r1r2.GetDomain()) { Console.WriteLine($"mu({element}) = {r1r2.GetValueAt(element)}"); } Console.WriteLine("---------------------------------------"); Console.WriteLine(); }
static void Primjer13() { IDomain d = Domain.IntRange(0, 11); IFuzzySet set1 = new MutableFuzzySet(d) .Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); Debug1.Print(set1, "Set1:"); IFuzzySet notSet1 = Operations.Operations.UnaryOperation( set1, Operations.Operations.ZadehNot()); Debug1.Print(notSet1, "notSet1:"); IFuzzySet union = Operations.Operations.BinaryOperation( set1, notSet1, Operations.Operations.ZadehOr()); Debug1.Print(union, "Set1 union notSet1:"); IFuzzySet hinters = Operations.Operations.BinaryOperation( set1, notSet1, Operations.Operations.HamacherTNorm(1.0)); Debug1.Print(hinters, "Set1 intersection with notSet1 using parameterised Hamacher T norm with parameter 1.0:"); IFuzzySet presjek = Operations.Operations.BinaryOperation(set1, notSet1, Operations.Operations.ZadehAnd()); Debug1.Print(presjek, "Set1 presjek notSet1:"); }
private static void Main() { var d1 = Domain.IntRange(0, 5); // {0,1,2,3,4} Console.WriteLine("Elementi domene d1:"); Console.WriteLine(d1); Console.WriteLine(); var d2 = Domain.IntRange(0, 3); // {0,1,2} Console.WriteLine("Elementi domene d2:"); Console.WriteLine(d2); Console.WriteLine(); var d3 = Domain.Combine(d1, d2); Console.WriteLine("Elementi domene d3:"); Console.WriteLine(d3); Console.WriteLine(); Console.WriteLine(d3.ElementForIndex(0)); Console.WriteLine(d3.ElementForIndex(5)); Console.WriteLine(d3.ElementForIndex(14)); Console.WriteLine(d3.IndexOfElement(DomainElement.Of(4, 1))); Console.ReadKey(); }
static void Primjer12() { IDomain d = Domain.IntRange(0, 11); // {0,1,...,10} //Debug1.Print(d, "Elementi domene d1:"); IFuzzySet set1 = new MutableFuzzySet(d) .Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); Debug1.Print(set1, "Set1:"); IDomain d2 = Domain.IntRange(-5, 6); // {-5,-4,...,4,5} IFuzzySet set2 = new CalculatedFuzzySet( d2, StandardFuzzySets.LambdaFunction( d2.IndexOfElement(DomainElement.Of(-4)), d2.IndexOfElement(DomainElement.Of(0)), d2.IndexOfElement(DomainElement.Of(4)) ) ); Debug1.Print(set2, "Set2:"); }
static void Main(string[] args) { IDomain u1 = Domain.IntRange(1, 5); // {1,2,3,4} IDomain u2 = Domain.IntRange(1, 4); // {1,2,3} IDomain u3 = Domain.IntRange(1, 5); // {1,2,3,4} IFuzzySet r1 = new MutableFuzzySet(Domain.Combine(u1, u2)) .Set(DomainElement.Of(1, 1), 0.3) .Set(DomainElement.Of(1, 2), 1) .Set(DomainElement.Of(3, 3), 0.5) .Set(DomainElement.Of(4, 3), 0.5); IFuzzySet r2 = new MutableFuzzySet(Domain.Combine(u2, u3)) .Set(DomainElement.Of(1, 1), 1) .Set(DomainElement.Of(2, 1), 0.5) .Set(DomainElement.Of(2, 2), 0.7) .Set(DomainElement.Of(3, 3), 1) .Set(DomainElement.Of(3, 4), 0.4); IFuzzySet r1r2 = Relations.CompositionOfBinaryRelations(r1, r2); Console.WriteLine(r1r2); Console.ReadKey(); }
public static void Test33() { double[] antecMembershipFunctions = new double[] { 0.8, 0.8, 0.7, 1, 0.7, 0.9 }; double minMembershipFunc = antecMembershipFunctions.Min(); IDomain u = Domain.IntRange(-5, 6); IFuzzySet _conseq = new CalculatedFuzzySet( u, StandardFuzzySets.LambdaFunction( u.IndexOfElement(DomainElement.Of(-5)), u.IndexOfElement(DomainElement.Of(-3)), u.IndexOfElement(DomainElement.Of(0)) ) ); Debug1.Print(_conseq, "Konsekv1:"); IFuzzySet antecedents = new CalculatedFuzzySet( //mjere pripadnosti su na minimumu mj.pripadnosti antecedenata _conseq.GetDomain(), StandardFuzzySets.UniversalFunction(minMembershipFunc) ); IFuzzySet conclusion = Operations.Operations.BinaryOperation(antecedents, _conseq, Operations.Operations.ZadehAnd()); Debug1.Print(conclusion, "Zakljucak1:"); }
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 bool IsSymmetric(IFuzzySet relation) { foreach (DomainElement element1 in relation.GetDomain()) { if (relation.GetValueAt(DomainElement.Of(element1.GetComponentValue(0), element1.GetComponentValue(1))) != relation.GetValueAt(DomainElement.Of(element1.GetComponentValue(1), element1.GetComponentValue(0)))) { return(false); } } return(true); }
public AkcelFuzzySystem(Defuzzifier defuzzifier) { this.defuzzifier = defuzzifier; IDomain acceleration = Domain.IntRange(-5, 6); IDomain direction = Domain.IntRange(0, 2); IDomain distance = Domain.IntRange(0, 1301); IDomain velocity = Domain.IntRange(0, 100); MutableFuzzySet Id = new MutableFuzzySet(distance); MutableFuzzySet Iv = new MutableFuzzySet(velocity); foreach (var element in distance) { Id.Set(element, 1); } foreach (var element in velocity) { Iv.Set(element, 1); } IFuzzySet Slow = new CalculatedFuzzySet(velocity, StandardFuzzySets.LFunction(0, 40)); IFuzzySet Medium = new CalculatedFuzzySet(velocity, StandardFuzzySets.LambdaFunction(37, 45, 55)); IFuzzySet Fast = new CalculatedFuzzySet(velocity, StandardFuzzySets.GammaFunction(48, 60)); IFuzzySet CriticalClose = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(10, 30)); IFuzzySet Close = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(25, 50)); IFuzzySet Far = new CalculatedFuzzySet(distance, StandardFuzzySets.GammaFunction(70, 100)); IFuzzySet Backward = new MutableFuzzySet(direction).Set(DomainElement.Of(0), 1); IFuzzySet Forward = new MutableFuzzySet(direction).Set(DomainElement.Of(1), 1); IFuzzySet SpeedUp = new MutableFuzzySet(acceleration) .Set(DomainElement.Of(5), 1) .Set(DomainElement.Of(4), 0.6) .Set(DomainElement.Of(3), 0.3); IFuzzySet Neutral = new MutableFuzzySet(acceleration).Set(DomainElement.Of(0), 1); IFuzzySet SlowDown = new MutableFuzzySet(acceleration) .Set(DomainElement.Of(-5), 1) .Set(DomainElement.Of(-4), 0.6) .Set(DomainElement.Of(-3), 0.3); // L, D, LK, RK, V, S rules = new List <Rule>(); rules.Add(new Rule(new[] { Id, Id, CriticalClose, Id, Iv, Forward }, Neutral, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Id, CriticalClose, Iv, Forward }, Neutral, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, CriticalClose, Id, Iv, Backward }, Neutral, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Id, CriticalClose, Iv, Backward }, Neutral, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Id, Id, Fast, Forward }, SlowDown, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Id, Id, Medium, Forward }, Neutral, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Id, Id, Slow, Forward }, SpeedUp, tNorm, implication)); }
public static void Test31() { IDomain u = Domain.IntRange(-5, 6); // {-5,-4,...,4,5} IDomain u2 = Domain.Combine(u, u); IFuzzySet set = new CalculatedFuzzySet( u2, StandardFuzzySets.LambdaFunction( u2.IndexOfElement(DomainElement.Of(-4, 2)), u2.IndexOfElement(DomainElement.Of(0, 0)), u2.IndexOfElement(DomainElement.Of(4, 2)) ) ); Debug1.Print(set, "Set cf:"); }
private static void Main(string[] args) { SimpleDomain sd = new SimpleDomain(-4, 5); PrintDomain(sd, "sd: "); IDomain cd = IDomain.Combine(sd, sd); PrintDomain(cd, "cd: "); IDomain d = IDomain.IntRange(0, 11); IFuzzySet set1 = new MutableFuzzySet(d).Set(DomainElement.Of(0), 1.0); PrintFuzzySet(set1, "set1: "); IDomain d2 = IDomain.IntRange(-5, 6); IFuzzySet set2 = new CalculatedFuzzySet(d2, StandardFuzzySets.LambdaFunction(d2.IndexOfElement(DomainElement.Of(-4)), d2.IndexOfElement(DomainElement.Of(0)), d2.IndexOfElement(DomainElement.Of(4)))); PrintFuzzySet(set2, "set2: "); IDomain d7 = IDomain.IntRange(0, 11); IFuzzySet set3 = new MutableFuzzySet(d7).Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); PrintFuzzySet(set3, "set3: "); IFuzzySet notSet3 = Operations.UnaryOperation(set3, Operations.ZadehNot()); PrintFuzzySet(notSet3, "notSet3: "); IFuzzySet union = Operations.BinaryOperation(set3, notSet3, Operations.ZadehOr()); PrintFuzzySet(union, "Set3 U notSet3: "); IFuzzySet hinters = Operations.BinaryOperation(set3, notSet3, Operations.HamacherTNorm(1.0)); PrintFuzzySet(hinters, "Set3 Intersection with notSet3 using parameterised Hamacher T norm with parameter 1.0: "); }
public IFuzzySet Accept(int[] inputs) { IDomain domain = consequent.GetDomain(); MutableFuzzySet solution = new MutableFuzzySet(domain); foreach (var element in domain) { //Console.Error.WriteLine(antecedent[1]); //Console.Error.WriteLine(inputs[0]); double tmp = antecedent[0].GetValueAt(DomainElement.Of(inputs[0])); for (int i = 1; i < antecedent.Length; ++i) { tmp = tNorm(tmp, antecedent[i].GetValueAt(DomainElement.Of(inputs[i]))); } solution.Set(element, implication(tmp, consequent.GetValueAt(element))); } return(solution); }
public static bool IsReflexive(IFuzzySet relation) { if (!IsUTimesURelation(relation)) { return(false); } IDomain domain = relation.GetDomain()[0]; foreach (var element in domain) { int value = element[0]; if (Math.Abs(1 - relation.GetValueAt(DomainElement.Of(value, value))) > TOLERANCE) { return(false); } } return(true); }
private static void PrintExample1() { Console.WriteLine("EXAMPLE 1"); SimpleDomain d1 = new SimpleDomain(0, 5); PrintDomain(d1, "sd: "); SimpleDomain d2 = new SimpleDomain(0, 3); PrintDomain(d2, "sd: "); IDomain d3 = IDomain.Combine(d1, d2); PrintDomain(d3, "cd: "); Console.WriteLine($"({d3.ElementForIndex(0)})"); Console.WriteLine($"({d3.ElementForIndex(5)})"); Console.WriteLine($"({d3.ElementForIndex(13)})"); Console.WriteLine(d3.IndexOfElement(DomainElement.Of(4, 1))); Console.WriteLine("---------------------------------------"); Console.WriteLine(); }
static void Primjer11() { Console.WriteLine("Hi"); IDomain d1 = Domain.IntRange(0, 5); Debug1.Print(d1, "Elementi domene d1:"); IDomain d2 = Domain.IntRange(0, 3); Debug1.Print(d2, "Elementi domene d2:"); IDomain d3 = Domain.Combine(d1, d2); Debug1.Print(d3, "Elementi domene d3:"); //IDomain d4 = Domain.Combine(d1, d3); //Debug1.Print(d4, "Elementi domene d4:"); Console.WriteLine(d3.ElementForIndex(0)); Console.WriteLine(d3.ElementForIndex(5)); Console.WriteLine(d3.ElementForIndex(14)); Console.WriteLine(d3.IndexOfElement(DomainElement.Of(4, 1))); }
private static void PrintExample2() { Console.WriteLine("EXAMPLE 2"); IDomain d = IDomain.IntRange(0, 11); IFuzzySet set1 = new MutableFuzzySet(d) .Set(DomainElement.Of(0), 1.0) .Set(DomainElement.Of(1), 0.8) .Set(DomainElement.Of(2), 0.6) .Set(DomainElement.Of(3), 0.4) .Set(DomainElement.Of(4), 0.2); PrintFuzzySet(set1, "Set1: "); IDomain d2 = IDomain.IntRange(-5, 6); IFuzzySet set2 = new CalculatedFuzzySet(d2, StandardFuzzySets.LambdaFunction(d2.IndexOfElement(DomainElement.Of(-4)), d2.IndexOfElement(DomainElement.Of(0)), d2.IndexOfElement(DomainElement.Of(4)))); PrintFuzzySet(set2, "Set2: "); Console.WriteLine("---------------------------------------"); Console.WriteLine(); }
private static void PrintExample6() { Console.WriteLine("EXAMPLE 6"); IDomain uFinal = IDomain.IntRange(1, 5); // {1,2,3,4} IFuzzySet r = new MutableFuzzySet(IDomain.Combine(uFinal, uFinal)) .Set(DomainElement.Of(1, 1), 1) .Set(DomainElement.Of(2, 2), 1) .Set(DomainElement.Of(3, 3), 1) .Set(DomainElement.Of(4, 4), 1) .Set(DomainElement.Of(1, 2), 0.3) .Set(DomainElement.Of(2, 1), 0.3) .Set(DomainElement.Of(2, 3), 0.5) .Set(DomainElement.Of(3, 2), 0.5) .Set(DomainElement.Of(3, 4), 0.2) .Set(DomainElement.Of(4, 3), 0.2); IFuzzySet r2 = r; Console.WriteLine($"Pocetna relacija je neizrazita relacija ekvivalencija? {Relations.IsFuzzyEquivalence(r2)}"); Console.WriteLine(); for (var i = 0; i < 3; i++) { r2 = Relations.CompositionOfBinaryRelations(r2, r) !; Console.WriteLine($"Broj odradenih kompozicija je: {i + 1}. Relacija je: "); foreach (var element in r2.GetDomain()) { Console.WriteLine($"mu({element}) = {r2.GetValueAt(element)}"); } Console.WriteLine($"Ova relacija je neizrazita relacija ekvivalencije? {Relations.IsFuzzyEquivalence(r2)}"); Console.WriteLine(); } Console.WriteLine("---------------------------------------"); Console.WriteLine(); }
static void Main(string[] args) { IDomain u = Domain.IntRange(1, 5); // {1,2,3,4} IFuzzySet r = new MutableFuzzySet(Domain.Combine(u, u)) .Set(DomainElement.Of(1, 1), 1) .Set(DomainElement.Of(2, 2), 1) .Set(DomainElement.Of(3, 3), 1) .Set(DomainElement.Of(4, 4), 1) .Set(DomainElement.Of(1, 2), 0.3) .Set(DomainElement.Of(2, 1), 0.3) .Set(DomainElement.Of(2, 3), 0.5) .Set(DomainElement.Of(3, 2), 0.5) .Set(DomainElement.Of(3, 4), 0.2) .Set(DomainElement.Of(4, 3), 0.2); IFuzzySet r2 = r; Console.Write("Početna relacija je neizrazita relacija ekvivalencije? "); Console.WriteLine(Relations.IsFuzzyEquivalence(r2)); Console.WriteLine(); for (int i = 1; i <= 3; i++) { r2 = Relations.CompositionOfBinaryRelations(r2, r); Console.WriteLine("Broj odrađenih kompozicija: " + i + ". Relacija je:"); Console.Write(r2); Console.Write("Ova relacija je neizrazita relacija ekvivalencije? "); Console.WriteLine(Relations.IsFuzzyEquivalence(r2)); Console.WriteLine(); } Console.ReadKey(); }
public static bool IsSymmetric(IFuzzySet relation) { if (!IsUTimesURelation(relation)) { return(false); } IDomain domain = relation.GetDomain(); foreach (var domainElement in domain) { int a = domainElement[0]; int b = domainElement[1]; var value1 = relation.GetValueAt(domainElement); var value2 = relation.GetValueAt(DomainElement.Of(b, a)); if (Math.Abs(value1 - value2) > TOLERANCE) { return(false); } } return(true); }
public static void Primjer22() { IDomain u1 = Domain.IntRange(1, 5); // {1,2,3,4} IDomain u2 = Domain.IntRange(1, 4); // {1,2,3} IDomain u3 = Domain.IntRange(1, 5); // {1,2,3,4} IFuzzySet r1 = new MutableFuzzySet(Domain.Combine(u1, u2)) .Set(DomainElement.Of(1, 1), 0.3) .Set(DomainElement.Of(1, 2), 1) .Set(DomainElement.Of(3, 3), 0.5) .Set(DomainElement.Of(4, 3), 0.5); IFuzzySet r2 = new MutableFuzzySet(Domain.Combine(u2, u3)) .Set(DomainElement.Of(1, 1), 1) .Set(DomainElement.Of(2, 1), 0.5) .Set(DomainElement.Of(2, 2), 0.7) .Set(DomainElement.Of(3, 3), 1) .Set(DomainElement.Of(3, 4), 0.4); IFuzzySet r1r2 = Relations.Relations.CompositionOfBinaryRelations(r1, r2, Operations.Operations.ZadehAnd(), Operations.Operations.ZadehOr()); foreach (DomainElement e in r1r2.GetDomain()) { Console.WriteLine("mu(" + e + ")=" + r1r2.GetValueAt(e)); } }