Click here to Skip to main content
15,891,184 members
Articles / Programming Languages / C#

Fuzzy Framework

Rate me:
Please Sign up or sign in to vote.
4.93/5 (107 votes)
27 Jan 2011CPOL26 min read 139.9K   12.5K   185  
In the following article, we briefly introduce Fuzzy Framework library which supports calculations based on fuzzy logic in .NET.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FuzzyFramework.Dimensions;
using FuzzyFramework.Intervals;
using FuzzyFramework.Members;

namespace FuzzyFramework.Sets
{
    /// <summary>
    /// Represents a singleton set. Example is set "36.6°C" on universe &lt;33°C, 45°C&gt; on dimension "body temperature".
    /// </summary>
    public class SingletonSet : ContinuousSet
    {
        private IMember _member;
        
        /// <summary>
        /// Creates new instance of singleton based on specified member
        /// </summary>
        /// <param name="member">member</param>
        public SingletonSet(IMember member) : base( (IContinuousDimension) member.Dimension, member.Caption)
        {
            _member = member;
            buildIntervals(member.ToDecimal);
        }

    
        /// <summary>
        /// Creates new instance of singleton based on specified decimal representation of the member.
        /// </summary>
        /// <param name="dimension">Dimension</param>
        /// <param name="caption">Caption</param>
        /// <param name="value">decimal representation of the member</param>
        public SingletonSet(IContinuousDimension dimension, string caption, decimal value)
            : base(dimension, caption)
        {
            buildIntervals(value);
        }



        private void buildIntervals(decimal value)
        {
            IContinuousDimension dimension = (IContinuousDimension) _dimension;
            if (dimension.MinValue <value)
                _intervals.AddInterval(new Interval(_intervals, dimension.MinValue, value, 0));

            _intervals.AddInterval(new Interval(_intervals, value, value, 1));

            if (dimension.MaxValue > value)
                _intervals.AddInterval(new Interval(_intervals, value, dimension.MaxValue, 0));

        }

        /*
        /// <summary>
        /// The single value for which is the membership degree equal to 1.
        /// </summary>
        public IMember Member
        {
            get
            {
                return _member;
            }
        }
        */
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Czech Republic Czech Republic
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions