12,396,230 members (66,029 online)

79.1K views
31 bookmarked
Posted

# Fuzzy Logic Vs Adaline Neural Network

, 29 Oct 2003
An experiment to see if it possible to duplicate the behavior of the Adaline Network using Fuzzy Logic.
 Fuzzy Logic Vs Adaline Neural Network Fuzzy Logic Library Fuzzy Logic Library.csproj.user Fuzzy Logic Vs Adaline Neural Network App.ico bin Debug Fuzzy Logic Library.dll Fuzzy Logic Vs Adaline Neural Network.exe Lin2Var.trn Fuzzy Logic Vs Adaline Neural Network.csproj.user ```using System; namespace Fuzzy_Logic_Library { /// /// Simple rule interface /// public interface IFuzzyBasicComparisonRules { bool IsGreaterThan { get; set; } bool IsLessThan { get; set; } bool IsEqual { get; set; } } public interface IFuzzyExtendedComparisonRules { bool IsNotEqual { get; set; } bool IsLessThanOrEqual { get; set; } bool IsGreaterThanOrEqual { get; set; } } /// /// reimplement the integer class ( grrrr ) /// public class FuzzyInteger : IFuzzyBasicComparisonRules { private bool bGreaterThan; private bool bLessThan; private bool bEqual; private Int32 integer; public int Number { get { return integer; } set { integer = value; } } public FuzzyInteger() { bGreaterThan = false; bLessThan = false; bEqual = false; } public FuzzyInteger( int nValue ) { integer = nValue; bGreaterThan = false; bLessThan = false; bEqual = false; } public FuzzyInteger( bool greaterThan ) : this() { bGreaterThan = greaterThan; } public FuzzyInteger( int nValue, bool greaterThan ) : this( greaterThan ) { integer = nValue; } public FuzzyInteger( bool greaterThan, bool lessThan ) : this() { bGreaterThan = greaterThan; bLessThan = lessThan; } public FuzzyInteger( int nValue, bool greaterThan, bool lessThan ) : this( greaterThan, lessThan ) { integer = nValue; } public FuzzyInteger( bool greaterThan, bool lessThan, bool equal ) { bGreaterThan = greaterThan; bLessThan = lessThan; bEqual = equal; } public FuzzyInteger( int nValue, bool greaterThan, bool lessThan, bool equal ) : this( greaterThan, lessThan, equal ) { integer = nValue; } #region IFuzzyBasicComparisonRules Members public bool IsGreaterThan { get { // TODO: Add FuzzyBasicComparisonRules.IsGreaterThan getter implementation return bGreaterThan; } set { // TODO: Add FuzzyBasicComparisonRules.IsGreaterThan setter implementation bGreaterThan = value; } } public bool IsLessThan { get { // TODO: Add FuzzyBasicComparisonRules.IsLessThan getter implementation return bLessThan; } set { // TODO: Add FuzzyBasicComparisonRules.IsLessThan setter implementation bLessThan = value; } } public bool IsEqual { get { // TODO: Add FuzzyBasicComparisonRules.IsEqual getter implementation return bEqual; } set { // TODO: Add FuzzyBasicComparisionRules.IsEqual setter implementation bEqual = value; } } #endregion public static FuzzyInteger operator +( FuzzyInteger num, int number ) { return new FuzzyInteger( num.Number + number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator +( FuzzyInteger num, FuzzyInteger number ) { return new FuzzyInteger( num.Number + number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator -( FuzzyInteger num, int number ) { return new FuzzyInteger( num.Number - number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator -( FuzzyInteger num, FuzzyInteger number ) { return new FuzzyInteger( num.Number - number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator *( FuzzyInteger num, int number ) { return new FuzzyInteger( num.Number * number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator *( FuzzyInteger num, FuzzyInteger number ) { return new FuzzyInteger( num.Number * number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator /( FuzzyInteger num, int number ) { return new FuzzyInteger( num.Number / number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator /( FuzzyInteger num, FuzzyInteger number ) { return new FuzzyInteger( num.Number / number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator %( FuzzyInteger num, int number ) { return new FuzzyInteger( num.Number % number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator %( FuzzyInteger num, FuzzyInteger number ) { return new FuzzyInteger( num.Number % number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator ++( FuzzyInteger num ) { return new FuzzyInteger( num.Number++, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyInteger operator --( FuzzyInteger num ) { return new FuzzyInteger( num.Number--, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static bool operator ==( FuzzyInteger num, int number ) { if( num.Number == number ) return true; else return false; } public static bool operator ==( FuzzyInteger num, FuzzyInteger number ) { if( num.Number == number.Number ) return true; else return false; } public static bool operator !=( FuzzyInteger num, int number ) { if( num.Number != number ) return true; else return false; } public static bool operator !=( FuzzyInteger num, FuzzyInteger number ) { if( num.Number != number.Number ) return true; else return false; } public static bool operator >( FuzzyInteger num, int number ) { if( num.Number > number ) return true; else return false; } public static bool operator >( FuzzyInteger num, FuzzyInteger number ) { if( num.Number > number.Number ) return true; else return false; } public static bool operator <( FuzzyInteger num, int number ) { if( num.Number < number ) return true; else return false; } public static bool operator <( FuzzyInteger num, FuzzyInteger number ) { if( num.Number < number.Number ) return true; else return false; } public static bool operator >=( FuzzyInteger num, int number ) { if( num.Number >= number ) return true; else return false; } public static bool operator >=( FuzzyInteger num, FuzzyInteger number ) { if( num.Number >= number.Number ) return true; else return false; } public static bool operator <=( FuzzyInteger num, int number ) { if( num.Number <= number ) return true; else return false; } public static bool operator <=( FuzzyInteger num, FuzzyInteger number ) { if( num.Number <= number.Number ) return true; else return false; } public override bool Equals(object obj) { return base.Equals (obj); } public override int GetHashCode() { return base.GetHashCode (); } public override string ToString() { return base.ToString () + ", IsGreaterThan :- " + this.IsGreaterThan.ToString() + ", IsLessThan :- " + this.IsLessThan.ToString() + ", IsEqual :- " + this.IsEqual.ToString(); } } /// /// implement the fuzzy double class /// public class FuzzyDouble : IFuzzyBasicComparisonRules { private bool bGreaterThan; private bool bLessThan; private bool bEqual; private double dNumber; public double Number { get { return dNumber; } set { dNumber = value; } } public FuzzyDouble() { bGreaterThan = false; bLessThan = false; bEqual = false; } public FuzzyDouble( double dValue ) { dNumber = dValue; bGreaterThan = false; bLessThan = false; bEqual = false; } public FuzzyDouble( bool greaterThan ) : this() { bGreaterThan = greaterThan; } public FuzzyDouble( double dValue, bool greaterThan ) : this( greaterThan ) { dNumber = dValue; } public FuzzyDouble( bool greaterThan, bool lessThan ) : this() { bGreaterThan = greaterThan; bLessThan = lessThan; } public FuzzyDouble( double dValue, bool greaterThan, bool lessThan ) : this( greaterThan, lessThan ) { dNumber = dValue; } public FuzzyDouble( bool greaterThan, bool lessThan, bool equal ) { bGreaterThan = greaterThan; bLessThan = lessThan; bEqual = equal; } public FuzzyDouble( double dValue, bool greaterThan, bool lessThan, bool equal ) : this( greaterThan, lessThan, equal ) { dNumber = dValue; } #region IFuzzyBasicComparisonRules Members public bool IsGreaterThan { get { // TODO: Add FuzzyBasicComparisonRules.IsGreaterThan getter implementation return bGreaterThan; } set { // TODO: Add FuzzyBasicComparisonRules.IsGreaterThan setter implementation bGreaterThan = value; } } public bool IsLessThan { get { // TODO: Add FuzzyBasicComparisonRules.IsLessThan getter implementation return bLessThan; } set { // TODO: Add FuzzyBasicComparisionRules.IsLessThan setter implementation bLessThan = value; } } public bool IsEqual { get { // TODO: Add FuzzyBasicComparisonRules.IsEqual getter implementation return bEqual; } set { // TODO: Add FuzzyBasicComparisonRules.IsEqual setter implementation bEqual = value; } } #endregion public static FuzzyDouble operator +( FuzzyDouble num, int number ) { return new FuzzyDouble( num.Number + number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator +( FuzzyDouble num, FuzzyDouble number ) { return new FuzzyDouble( num.Number + number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator -( FuzzyDouble num, int number ) { return new FuzzyDouble( num.Number - number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator -( FuzzyDouble num, FuzzyInteger number ) { return new FuzzyDouble( num.Number - number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator *( FuzzyDouble num, int number ) { return new FuzzyDouble( num.Number * number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator *( FuzzyDouble num, FuzzyDouble number ) { return new FuzzyDouble( num.Number * number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator /( FuzzyDouble num, int number ) { return new FuzzyDouble( num.Number / number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator /( FuzzyDouble num, FuzzyDouble number ) { return new FuzzyDouble( num.Number / number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator %( FuzzyDouble num, int number ) { return new FuzzyDouble( num.Number % number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator %( FuzzyDouble num, FuzzyInteger number ) { return new FuzzyDouble( num.Number % number.Number, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator ++( FuzzyDouble num ) { return new FuzzyDouble( num.Number++, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static FuzzyDouble operator --( FuzzyDouble num ) { return new FuzzyDouble( num.Number--, num.IsGreaterThan, num.IsLessThan, num.IsEqual ); } public static bool operator ==( FuzzyDouble num, int number ) { if( num.Number == number ) return true; else return false; } public static bool operator ==( FuzzyDouble num, FuzzyDouble number ) { if( num.Number == number.Number ) return true; else return false; } public static bool operator !=( FuzzyDouble num, int number ) { if( num.Number != number ) return true; else return false; } public static bool operator !=( FuzzyDouble num, FuzzyDouble number ) { if( num.Number != number.Number ) return true; else return false; } public static bool operator >( FuzzyDouble num, int number ) { if( num.Number > number ) return true; else return false; } public static bool operator >( FuzzyDouble num, FuzzyDouble number ) { if( num.Number > number.Number ) return true; else return false; } public static bool operator <( FuzzyDouble num, int number ) { if( num.Number < number ) return true; else return false; } public static bool operator <( FuzzyDouble num, FuzzyDouble number ) { if( num.Number < number.Number ) return true; else return false; } public static bool operator >=( FuzzyDouble num, int number ) { if( num.Number >= number ) return true; else return false; } public static bool operator >=( FuzzyDouble num, FuzzyDouble number ) { if( num.Number >= number.Number ) return true; else return false; } public static bool operator <=( FuzzyDouble num, int number ) { if( num.Number <= number ) return true; else return false; } public static bool operator <=( FuzzyDouble num, FuzzyDouble number ) { if( num.Number <= number.Number ) return true; else return false; } public override bool Equals(object obj) { return base.Equals (obj); } public override int GetHashCode() { return base.GetHashCode (); } public override string ToString() { return base.ToString () + ", IsGreaterThan :- " + this.IsGreaterThan.ToString() + ", IsLessThan :- " + this.IsLessThan.ToString() + ", IsEqual :- " + this.IsEqual.ToString(); } } } ```

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

A list of licenses authors might use can be found here