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 SlowVelocity(string name) { Name = name; FuzzySet = new CalculatedFuzzySet(IDomain.IntRange(0, 100), StandardFuzzySets.LFunction(0, 100)); }
public KormiloFuzzySystem(Defuzzifier defuzzifier) { this.defuzzifier = defuzzifier; IDomain angle = Domain.IntRange(-90, 91); 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 CriticalClose = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(20, 40)); IFuzzySet Close = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(40, 90)); IFuzzySet Far = new CalculatedFuzzySet(distance, StandardFuzzySets.GammaFunction(100, 200)); IFuzzySet VeryFar = new CalculatedFuzzySet(distance, StandardFuzzySets.GammaFunction(300, 400)); //IFuzzySet NotFar = Operations.UnaryOperation(Far, Operations.ZadehNot()); IFuzzySet Backward = new MutableFuzzySet(direction).Set(DomainElement.Of(0), 1); IFuzzySet Forward = new MutableFuzzySet(direction).Set(DomainElement.Of(1), 1); IFuzzySet Left = new MutableFuzzySet(angle).Set(DomainElement.Of(90), 1); //IFuzzySet Left = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(0, 30, 50)); //IFuzzySet FullLeft = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(55, 70, 80)); IFuzzySet Neutral = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(-10, 0, 10)); //IFuzzySet Right = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(-50, -30, 0)); IFuzzySet Right = new MutableFuzzySet(angle).Set(DomainElement.Of(-90), 1); //IFuzzySet FullRight = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(-80, -70, -55)); // L, D, LK, RK, V, S rules = new List <Rule>(); rules.Add(new Rule(new[] { Id, Close, Id, Id, Iv, Forward }, Left, tNorm, implication)); rules.Add(new Rule(new[] { Close, Id, Id, Id, Iv, Forward }, Right, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Id, Close, Iv, Forward }, Left, tNorm, implication)); rules.Add(new Rule(new[] { Id, Id, Close, Id, Iv, Forward }, Right, tNorm, implication)); rules.Add(new Rule(new[] { VeryFar, Id, Id, Id, Iv, Backward }, Left, tNorm, implication)); rules.Add(new Rule(new[] { Id, VeryFar, Id, Id, Iv, Backward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { Far, Close, Id, Id, Iv, Forward }, Left, tNorm, implication)); //rules.Add(new Rule(new[] { Id, Close, Id, CriticalClose, Iv, Forward }, FullLeft)); //rules.Add(new Rule(new[] { Far, Close, Id, Id, Iv, Backward }, Left, tNorm, implication)); //rules.Add(new Rule(new[] { Far, Far, Id, Id, Iv, Forward }, Neutral)); //rules.Add(new Rule(new[] { Close, Far, Id, Id, Iv, Forward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { Close, Id, CriticalClose, Id, Iv, Forward }, FullRight)); //rules.Add(new Rule(new[] { Close, Far, Id, Id, Iv, Backward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { Far, Id, Close, Close, Iv, Forward }, Left, tNorm, implication)); //rules.Add(new Rule(new[] { Id, Far, Close, Close, Iv, Forward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { VeryFar, VeryFar, Close, Close, Iv, Forward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { Far, Id, Close, Close, Iv, Backward }, Right, tNorm, implication)); ////rules.Add(new Rule(new[] { Id, Far, Close, Close, Iv, Backward }, Left, tNorm, implication)); //rules.Add(new Rule(new[] { Close, Close, Id, Close, Iv, Forward }, Left, tNorm, implication)); //rules.Add(new Rule(new[] { Close, Close, Close, Id, Iv, Forward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { Id, Id, Id, Id, Iv, Backward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { VeryFar, Id, Close, Close, Iv, Forward }, Right, tNorm, implication)); //rules.Add(new Rule(new[] { Id, VeryFar, Close, Close, Iv, Forward }, Left, tNorm, implication)); }
public NegativeAcceleration(string name) { Name = name; FuzzySet = new CalculatedFuzzySet(IDomain.IntRange(-50, 51), StandardFuzzySets.LFunction(-50, 0)); }
private void KormiloRuleBook() { KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(35)), Rule.UANTEC.IndexOfElement(DomainElement.Of(60))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensKor(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(-60)), Rule.UKOR.IndexOfElement(DomainElement.Of(-45)), Rule.UKOR.IndexOfElement(DomainElement.Of(-30))) //umjeren udesno ) ) ); KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(50)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.GammaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(70)), Rule.UANTEC.IndexOfElement(DomainElement.Of(90))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(35)), Rule.UANTEC.IndexOfElement(DomainElement.Of(75)), Rule.UANTEC.IndexOfElement(DomainElement.Of(135))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensKor(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(-90)), Rule.UKOR.IndexOfElement(DomainElement.Of(-80)), Rule.UKOR.IndexOfElement(DomainElement.Of(-55))) //ostro udesno ) ) ); KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(35)), Rule.UANTEC.IndexOfElement(DomainElement.Of(60))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensKor(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(30)), Rule.UKOR.IndexOfElement(DomainElement.Of(45)), Rule.UKOR.IndexOfElement(DomainElement.Of(60))) //umjeren ulijevo ) ) ); KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.GammaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(70)), Rule.UANTEC.IndexOfElement(DomainElement.Of(90))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(50)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(35)), Rule.UANTEC.IndexOfElement(DomainElement.Of(75)), Rule.UANTEC.IndexOfElement(DomainElement.Of(135))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensKor(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(55)), Rule.UKOR.IndexOfElement(DomainElement.Of(80)), Rule.UKOR.IndexOfElement(DomainElement.Of(90))) //ostro ulijevo ) ) ); KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(30)), Rule.UANTEC.IndexOfElement(DomainElement.Of(50))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(30)), Rule.UANTEC.IndexOfElement(DomainElement.Of(60))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensKor(StandardFuzzySets.LFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(-80)), Rule.UKOR.IndexOfElement(DomainElement.Of(-25))) //ostro udesno vrlo blizu lijevo neovisno o brzini ) ) ); KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(30)), Rule.UANTEC.IndexOfElement(DomainElement.Of(50))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(30)), Rule.UANTEC.IndexOfElement(DomainElement.Of(60))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensKor(StandardFuzzySets.GammaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(25)), Rule.UKOR.IndexOfElement(DomainElement.Of(80))) //ostro ulijevo vrlo blizu desno neovisno o brzini ) ) ); KormiloRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(-2)), Rule.UKOR.IndexOfElement(DomainElement.Of(0)), Rule.UKOR.IndexOfElement(DomainElement.Of(1))) ), Rule.MakeFuzzyRuleConsequensAcc(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(-90)), Rule.UKOR.IndexOfElement(DomainElement.Of(-85)), Rule.UKOR.IndexOfElement(DomainElement.Of(-80))) ) //rotiraj ) ); }
public SharpRightHelmRotation(string name) { Name = name; FuzzySet = new CalculatedFuzzySet(IDomain.IntRange(-90, 91), StandardFuzzySets.LFunction(-90, -60)); }
private void AkcelRuleBook() { AkcelRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(50)), Rule.UANTEC.IndexOfElement(DomainElement.Of(75))) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleConsequensAcc(StandardFuzzySets.LambdaFunction( Rule.UACC.IndexOfElement(DomainElement.Of(0)), Rule.UACC.IndexOfElement(DomainElement.Of(10)), Rule.UACC.IndexOfElement(DomainElement.Of(20))) ) //ubrzaj do 75 ) ); AkcelRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), //vrlo blizu obali lijevo Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), //nebitno desno Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), //vrlo blizu LK Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.GammaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(80)), Rule.UANTEC.IndexOfElement(DomainElement.Of(200))) ), //umjereno blizu LK Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(35)), Rule.UANTEC.IndexOfElement(DomainElement.Of(65)), Rule.UANTEC.IndexOfElement(DomainElement.Of(135))) //do cca 90 px/s ), //velika brzina Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), //nebitno S?? //TODO mozda popraviti domenu od S Rule.MakeFuzzyRuleConsequensAcc(StandardFuzzySets.LambdaFunction( Rule.UACC.IndexOfElement(DomainElement.Of(-30)), Rule.UACC.IndexOfElement(DomainElement.Of(-22)), Rule.UACC.IndexOfElement(DomainElement.Of(0))) ) //zavoj ) ); AkcelRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), //nebitno lijevo Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), //umjereno blizu desno Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.GammaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(80)), Rule.UANTEC.IndexOfElement(DomainElement.Of(200))) ), //umjereno blizu LK Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(0)), Rule.UANTEC.IndexOfElement(DomainElement.Of(80))) ), //umjereno blizu DK Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UANTEC.IndexOfElement(DomainElement.Of(35)), Rule.UANTEC.IndexOfElement(DomainElement.Of(65)), Rule.UANTEC.IndexOfElement(DomainElement.Of(135))) //do cca 90 px/s ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), //nebitno S?? //TODO mozda popraviti domenu od S Rule.MakeFuzzyRuleConsequensAcc(StandardFuzzySets.LambdaFunction( Rule.UACC.IndexOfElement(DomainElement.Of(-30)), Rule.UACC.IndexOfElement(DomainElement.Of(-22)), Rule.UACC.IndexOfElement(DomainElement.Of(0))) ) //zavoj ) ); AkcelRules.Add( new Rule( Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.UniversalFunction( 1) ), Rule.MakeFuzzyRuleAntecedent(StandardFuzzySets.LambdaFunction( Rule.UKOR.IndexOfElement(DomainElement.Of(-1)), Rule.UKOR.IndexOfElement(DomainElement.Of(0)), Rule.UKOR.IndexOfElement(DomainElement.Of(1))) ), Rule.MakeFuzzyRuleConsequensAcc(StandardFuzzySets.LambdaFunction( Rule.UACC.IndexOfElement(DomainElement.Of(-30)), Rule.UACC.IndexOfElement(DomainElement.Of(-22)), Rule.UACC.IndexOfElement(DomainElement.Of(0))) ) //rotiraj ) ); }
public ShortDistance(string name) { Name = name; FuzzySet = new CalculatedFuzzySet(IDomain.IntRange(0, 1301), StandardFuzzySets.LFunction(40, 60)); }