示例#1
0
		/// <summary>
		/// Union override that allows the setting of the membership parameters
		/// </summary>
		/// <param name="setOne"></param>
		/// <param name="setTwo"></param>
		/// <param name="setParams"></param>
		/// <returns></returns>
		public FuzzyNumberSet Union( FuzzySet fuzzySet, FuzzySetParameters setParams )
		{
			FuzzyNumberSet returnSet = new FuzzyNumberSet();

			double dSetOneMinMinimum;
			double dSetOneMaxMinimum;
			double dSetOneMinMembership; 
			double dSetOneMaxMembership;
			double dSetOneMinMaximum;
			double dSetOneMaxMaximum;
			double dSetOneMinNumber;
			double dSetOneMaxNumber;
			double dSetTwoMinMinimum;
			double dSetTwoMaxMinimum;
			double dSetTwoMinMembership;
			double dSetTwoMaxMembership;
			double dSetTwoMinMaximum;
			double dSetTwoMaxMaximum;
			double dSetTwoMinNumber;
			double dSetTwoMaxNumber;


			/// get all the items from set one that fit the required ( passed in ) parameters.
			for( int i=0; i<this.Count; i++ )
			{
				if( setParams.SetOneMaxMembership == 0 )
					dSetOneMaxMembership = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership;
				else
					dSetOneMaxMembership = setParams.SetOneMaxMembership;

				if( setParams.SetOneMaxMinimum == 0 )
					dSetOneMaxMinimum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum;
				else
					dSetOneMaxMinimum = setParams.SetOneMaxMinimum;

				if( setParams.SetOneMaxNumber == 0 )
					dSetOneMaxNumber = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number;
				else
					dSetOneMaxNumber = setParams.SetOneMaxNumber;

				if( setParams.SetOneMinMaximum == 0 )
					dSetOneMinMaximum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum;
				else
					dSetOneMinMaximum = setParams.SetOneMinMaximum;

				if( setParams.SetOneMaxMaximum == 0 )
					dSetOneMaxMaximum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum;
				else
					dSetOneMaxMaximum = setParams.SetOneMaxMaximum;

				if( setParams.SetOneMinMembership == 0 )
					dSetOneMinMembership = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership;
				else
					dSetOneMinMembership = setParams.SetOneMinMembership;

				if( setParams.SetOneMinMinimum == 0 )
					dSetOneMinMinimum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum;
				else
					dSetOneMinMinimum = setParams.SetOneMinMinimum;

				if( setParams.SetOneMinNumber == 0 )
					dSetOneMinNumber = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number;
				else
					dSetOneMinNumber = setParams.SetOneMinNumber;

				if( ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership <= dSetOneMaxMembership &&
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum <= dSetOneMaxMaximum &&
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum <= dSetOneMaxMinimum &&
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number  <= dSetOneMaxNumber && 
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership >= dSetOneMinMembership &&
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum >= dSetOneMinMaximum &&
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum >= dSetOneMinMinimum && 
					( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number >= dSetOneMinNumber )
				{
					returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )this.FuzzyArray[ i ] );
				}
			}

			/// Get the ones in set two, not in set one ( though none should be when comparing different sets )
			for( int i=0; i<fuzzySet.Count; i++ )
			{
				if( setParams.SetTwoMaxMembership == 0 )
					dSetTwoMaxMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership;
				else
					dSetTwoMaxMembership = setParams.SetTwoMaxMembership;

				if( setParams.SetTwoMaxMinimum == 0 )
					dSetTwoMaxMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum;
				else
					dSetTwoMaxMinimum = setParams.SetTwoMaxMinimum;

				if( setParams.SetTwoMaxNumber == 0 )
					dSetTwoMaxNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number;
				else
					dSetTwoMaxNumber = setParams.SetTwoMaxNumber;

				if( setParams.SetTwoMinMaximum == 0 )
					dSetTwoMinMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum;
				else
					dSetTwoMinMaximum = setParams.SetTwoMinMaximum;

				if( setParams.SetTwoMaxMaximum == 0 )
					dSetTwoMaxMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum;
				else
					dSetTwoMaxMaximum = setParams.SetTwoMaxMaximum;

				if( setParams.SetTwoMinMembership == 0 )
					dSetTwoMinMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership;
				else
					dSetTwoMinMembership = setParams.SetTwoMinMembership;

				if( setParams.SetTwoMinMinimum == 0 ) 
					dSetTwoMinMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum;
				else
					dSetTwoMinMinimum = setParams.SetTwoMinMinimum;

				if( setParams.SetTwoMinNumber == 0 )
					dSetTwoMinNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number;
				else
					dSetTwoMinNumber = setParams.SetTwoMinNumber;

				for( int n=0; n<fuzzySet.Count; n++ )
				{

					if( setParams.SetOneMaxMembership == 0 )
						dSetOneMaxMembership = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership;
					else
						dSetOneMaxMembership = setParams.SetOneMaxMembership;

					if( setParams.SetOneMaxMinimum == 0 )
						dSetOneMaxMinimum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum;
					else
						dSetOneMaxMinimum = setParams.SetOneMaxMinimum;

					if( setParams.SetOneMaxNumber == 0 )
						dSetOneMaxNumber = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number;
					else
						dSetOneMaxNumber = setParams.SetOneMaxNumber;

					if( setParams.SetOneMinMaximum == 0 )
						dSetOneMinMaximum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum;
					else
						dSetOneMinMaximum = setParams.SetOneMinMaximum;

					if( setParams.SetOneMaxMaximum == 0 )
						dSetOneMaxMaximum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum;
					else
						dSetOneMaxMaximum = setParams.SetOneMaxMaximum;

					if( setParams.SetOneMinMembership == 0 )
						dSetOneMinMembership = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership;
					else
						dSetOneMinMembership = setParams.SetOneMinMembership;

					if( setParams.SetOneMinMinimum == 0 )
						dSetOneMinMinimum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum;
					else
						dSetOneMinMinimum = setParams.SetOneMinMinimum;

					if( setParams.SetOneMinNumber == 0 )
						dSetOneMinNumber = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number;
					else
						dSetOneMinNumber = setParams.SetOneMinNumber;


					if( ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum >= dSetOneMinMaximum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum >= dSetTwoMinMaximum &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum <= dSetOneMaxMaximum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum <= dSetTwoMaxMaximum &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership >= dSetOneMinMembership &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership >= dSetTwoMinMembership &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership <= dSetOneMaxMembership &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership <= dSetTwoMaxMembership &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum >= dSetOneMinMinimum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum >= dSetTwoMinMinimum &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum <= dSetOneMaxMinimum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum <= dSetTwoMaxMinimum &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number >= dSetOneMinNumber &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number >= dSetTwoMinNumber &&
						( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number <= dSetOneMaxNumber &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number <= dSetTwoMaxNumber )
					{
						if( returnSet.IsInSet( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ]  ) == false )
						{
							returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] );
						}
					}
				}
			}

			return returnSet;

		}
示例#2
0
		/// Set operations
		
		/// <summary>
		/// return a union of the two passed sets
		/// </summary>
		/// <param name="setOne"></param>
		/// <param name="setTwo"></param>
		/// <returns></returns>
		public FuzzyNumberSet Union( FuzzySet fuzzySet )
		{
			FuzzyNumberSet returnSet = new FuzzyNumberSet();
			bool bFound = false;

			for( int i=0; i<this.FuzzyArray.Count; i++ )
			{
				returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )this.FuzzyArray[ i ] );
			}

			/// Get the ones in set one but not in set two
			for( int i=0; i<fuzzySet.Count; i++ )
			{
				bFound = false;

				for( int n=0; n<this.Count; n++ )
				{
					if( ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum == ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership == ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum == ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number == ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number )
					{
						bFound = true;
						n=fuzzySet.Count;
					}
				}

				if( bFound == false )
				{
					returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] );					
				}
			}

			return returnSet;
		}
示例#3
0
		/// <summary>
		/// return an intersection of the two sets and allow the passing in of the required membership values
		/// </summary>
		/// <param name="setOne"></param>
		/// <param name="setTwo"></param>
		/// <param name="setOneMinMembership"></param>
		/// <param name="setOneMaxMembership"></param>
		/// <param name="setTwoMinMembership"></param>
		/// <param name="setTwoMaxMembership"></param>
		/// <returns></returns>
		public FuzzyNumberSet Intersection( FuzzySet fuzzySet, FuzzySetParameters setParams )
		{
			FuzzyNumberSet returnSet = new FuzzyNumberSet();

			double dSetOneMinMinimum;
			double dSetOneMaxMinimum;
			double dSetOneMinMembership; 
			double dSetOneMaxMembership;
			double dSetOneMinMaximum;
			double dSetOneMaxMaximum;
			double dSetOneMinNumber;
			double dSetOneMaxNumber;
			double dSetTwoMinMinimum;
			double dSetTwoMaxMinimum;
			double dSetTwoMinMembership;
			double dSetTwoMaxMembership;
			double dSetTwoMinMaximum;
			double dSetTwoMaxMaximum;
			double dSetTwoMinNumber;
			double dSetTwoMaxNumber;

			for( int i=0; i<this.Count; i++ )
			{

				if( setParams.SetOneMaxMembership == 0 )
					dSetOneMaxMembership = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership;
				else
					dSetOneMaxMembership = setParams.SetOneMaxMembership;

				if( setParams.SetOneMaxMinimum == 0 )
					dSetOneMaxMinimum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum;
				else
					dSetOneMaxMinimum = setParams.SetOneMaxMinimum;

				if( setParams.SetOneMaxNumber == 0 )
					dSetOneMaxNumber = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number;
				else
					dSetOneMaxNumber = setParams.SetOneMaxNumber;

				if( setParams.SetOneMinMaximum == 0 )
					dSetOneMinMaximum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum;
				else
					dSetOneMinMaximum = setParams.SetOneMinMaximum;

				if( setParams.SetOneMaxMaximum == 0 )
					dSetOneMaxMaximum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum;
				else
					dSetOneMaxMaximum = setParams.SetOneMaxMaximum;

				if( setParams.SetOneMinMembership == 0 )
					dSetOneMinMembership = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership;
				else
					dSetOneMinMembership = setParams.SetOneMinMembership;

				if( setParams.SetOneMinMinimum == 0 )
					dSetOneMinMinimum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum;
				else
					dSetOneMinMinimum = setParams.SetOneMinMinimum;

				if( setParams.SetOneMinNumber == 0 )
					dSetOneMinNumber = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number;
				else
					dSetOneMinNumber = setParams.SetOneMinNumber;

				for( int n=0; n<fuzzySet.Count; n++ )
				{

					if( setParams.SetTwoMaxMembership == 0 )
						dSetTwoMaxMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership;
					else
						dSetTwoMaxMembership = setParams.SetTwoMaxMembership;

					if( setParams.SetTwoMaxMinimum == 0 )
						dSetTwoMaxMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum;
					else
						dSetTwoMaxMinimum = setParams.SetTwoMaxMinimum;

					if( setParams.SetTwoMaxNumber == 0 )
						dSetTwoMaxNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number;
					else
						dSetTwoMaxNumber = setParams.SetTwoMaxNumber;

					if( setParams.SetTwoMinMaximum == 0 )
						dSetTwoMinMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum;
					else
						dSetTwoMinMaximum = setParams.SetTwoMinMaximum;

					if( setParams.SetTwoMaxMaximum == 0 )
						dSetTwoMaxMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum;
					else
						dSetTwoMaxMaximum = setParams.SetTwoMaxMaximum;

					if( setParams.SetTwoMinMembership == 0 )
						dSetTwoMinMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership;
					else
						dSetTwoMinMembership = setParams.SetTwoMinMembership;

					if( setParams.SetTwoMinMinimum == 0 ) 
						dSetTwoMinMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum;
					else
						dSetTwoMinMinimum = setParams.SetTwoMinMinimum;

					if( setParams.SetTwoMinNumber == 0 )
						dSetTwoMinNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number;
					else
						dSetTwoMinNumber = setParams.SetTwoMinNumber;

					if( ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum >= dSetOneMinMaximum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum >= dSetTwoMinMaximum &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum <= dSetOneMaxMaximum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum <= dSetTwoMaxMaximum &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership >= dSetOneMinMembership &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership >= dSetTwoMinMembership &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership <= dSetOneMaxMembership &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership <= dSetTwoMaxMembership &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum >= dSetOneMinMinimum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum >= dSetTwoMinMinimum &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum <= dSetOneMaxMinimum &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum <= dSetTwoMaxMinimum &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number >= dSetOneMinNumber &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number >= dSetTwoMinNumber &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number <= dSetOneMaxNumber &&
						( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number <= dSetTwoMaxNumber )
					{

						if( dSetOneMinMaximum >= dSetTwoMinMaximum &&
							dSetOneMaxMaximum <= dSetTwoMaxMaximum &&
							dSetOneMinMembership >= dSetTwoMinMembership &&
							dSetOneMaxMembership <= dSetTwoMaxMembership &&
							dSetOneMinMinimum >= dSetTwoMinMinimum &&
							dSetOneMaxMinimum <= dSetTwoMaxMinimum &&
							dSetOneMinNumber >= dSetTwoMinNumber &&
							dSetOneMaxNumber <= dSetTwoMaxNumber )					
						{
							returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )this.FuzzyArray[ i ] );
						}
					}
				}
			}

			return returnSet;

		}
示例#4
0
		/// <summary>
		/// exclusive or taking the fuzzy parameter set.
		/// </summary>
		/// <param name="setOne"></param>
		/// <param name="setTwo"></param>
		/// <param name="setParams"></param>
		/// <returns></returns>
		public FuzzyNumberSet ExclusiveOR( FuzzySet fuzzySet, FuzzySetParameters setParams )
		{
			FuzzyNumberSet returnSet = new FuzzyNumberSet();
			bool bFound = false;

			double dSetOneMinMinimum;
			double dSetOneMaxMinimum;
			double dSetOneMinMembership; 
			double dSetOneMaxMembership;
			double dSetOneMinMaximum;
			double dSetOneMaxMaximum;
			double dSetOneMinNumber;
			double dSetOneMaxNumber;
			double dSetTwoMinMinimum;
			double dSetTwoMaxMinimum;
			double dSetTwoMinMembership;
			double dSetTwoMaxMembership;
			double dSetTwoMinMaximum;
			double dSetTwoMaxMaximum;
			double dSetTwoMinNumber;
			double dSetTwoMaxNumber;


			/// Get the ones in set one but not in set two
			for( int i=0; i<this.Count; i++ )
			{
				bFound = false;

				if( setParams.SetOneMaxMembership == 0 )
					dSetOneMaxMembership = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership;
				else
					dSetOneMaxMembership = setParams.SetOneMaxMembership;

				if( setParams.SetOneMaxMinimum == 0 )
					dSetOneMaxMinimum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum;
				else
					dSetOneMaxMinimum = setParams.SetOneMaxMinimum;

				if( setParams.SetOneMaxNumber == 0 )
					dSetOneMaxNumber = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number;
				else
					dSetOneMaxNumber = setParams.SetOneMaxNumber;

				if( setParams.SetOneMinMaximum == 0 )
					dSetOneMinMaximum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum;
				else
					dSetOneMinMaximum = setParams.SetOneMinMaximum;

				if( setParams.SetOneMaxMaximum == 0 )
					dSetOneMaxMaximum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum;
				else
					dSetOneMaxMaximum = setParams.SetOneMaxMaximum;

				if( setParams.SetOneMinMembership == 0 )
					dSetOneMinMembership = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership;
				else
					dSetOneMinMembership = setParams.SetOneMinMembership;

				if( setParams.SetOneMinMinimum == 0 )
					dSetOneMinMinimum = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum;
				else
					dSetOneMinMinimum = setParams.SetOneMinMinimum;

				if( setParams.SetOneMinNumber == 0 )
					dSetOneMinNumber = ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number;
				else
					dSetOneMinNumber = setParams.SetOneMinNumber;


				for( int n=0; n<fuzzySet.Count; n++ )
				{
					if( setParams.SetTwoMaxMembership == 0 )
						dSetTwoMaxMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership;
					else
						dSetTwoMaxMembership = setParams.SetTwoMaxMembership;

					if( setParams.SetTwoMaxMinimum == 0 )
						dSetTwoMaxMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum;
					else
						dSetTwoMaxMinimum = setParams.SetTwoMaxMinimum;

					if( setParams.SetTwoMaxNumber == 0 )
						dSetTwoMaxNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number;
					else
						dSetTwoMaxNumber = setParams.SetTwoMaxNumber;

					if( setParams.SetTwoMinMaximum == 0 )
						dSetTwoMinMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum;
					else
						dSetTwoMinMaximum = setParams.SetTwoMinMaximum;

					if( setParams.SetTwoMaxMaximum == 0 )
						dSetTwoMaxMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum;
					else
						dSetTwoMaxMaximum = setParams.SetTwoMaxMaximum;

					if( setParams.SetTwoMinMembership == 0 )
						dSetTwoMinMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership;
					else
						dSetTwoMinMembership = setParams.SetTwoMinMembership;

					if( setParams.SetTwoMinMinimum == 0 ) 
						dSetTwoMinMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum;
					else
						dSetTwoMinMinimum = setParams.SetTwoMinMinimum;

					if( setParams.SetTwoMinNumber == 0 )
						dSetTwoMinNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number;
					else
						dSetTwoMinNumber = setParams.SetTwoMinNumber;


					if( dSetOneMinMaximum >= dSetTwoMinMaximum &&
						dSetOneMaxMaximum <= dSetTwoMaxMaximum &&
						dSetOneMinMembership >= dSetTwoMinMembership &&
						dSetOneMaxMembership <= dSetTwoMaxMembership &&
						dSetOneMinMinimum >= dSetTwoMinMinimum &&
						dSetOneMaxMinimum <= dSetTwoMaxMinimum &&
						dSetOneMinNumber >= dSetTwoMinNumber &&
						dSetOneMaxNumber <= dSetTwoMaxNumber )						
					{
						bFound = true;
						n=fuzzySet.Count;
					}
				}

				if( bFound == false )
				{
					returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )this.FuzzyArray[ i ] );
				}
			}

			/// get the ones in set two but not in set one
			for( int i=0; i<fuzzySet.Count; i++ )
			{
				bFound = false;

				if( setParams.SetTwoMaxMembership == 0 )
					dSetTwoMaxMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership;
				else
					dSetTwoMaxMembership = setParams.SetTwoMaxMembership;

				if( setParams.SetTwoMaxMinimum == 0 )
					dSetTwoMaxMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum;
				else
					dSetTwoMaxMinimum = setParams.SetTwoMaxMinimum;

				if( setParams.SetTwoMaxNumber == 0 )
					dSetTwoMaxNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number;
				else
					dSetTwoMaxNumber = setParams.SetTwoMaxNumber;

				if( setParams.SetTwoMinMaximum == 0 )
					dSetTwoMinMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum;
				else
					dSetTwoMinMaximum = setParams.SetTwoMinMaximum;

				if( setParams.SetTwoMaxMaximum == 0 )
					dSetTwoMaxMaximum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Maximum;
				else
					dSetTwoMaxMaximum = setParams.SetTwoMaxMaximum;

				if( setParams.SetTwoMinMembership == 0 )
					dSetTwoMinMembership = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Membership;
				else
					dSetTwoMinMembership = setParams.SetTwoMinMembership;

				if( setParams.SetTwoMinMinimum == 0 ) 
					dSetTwoMinMinimum = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Minimum;
				else
					dSetTwoMinMinimum = setParams.SetTwoMinMinimum;

				if( setParams.SetTwoMinNumber == 0 )
					dSetTwoMinNumber = ( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] ).Number;
				else
					dSetTwoMinNumber = setParams.SetTwoMinNumber;


				for( int n=0; n<this.Count; n++ )
				{
					if( setParams.SetOneMaxMembership == 0 )
						dSetOneMaxMembership = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership;
					else
						dSetOneMaxMembership = setParams.SetOneMaxMembership;

					if( setParams.SetOneMaxMinimum == 0 )
						dSetOneMaxMinimum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum;
					else
						dSetOneMaxMinimum = setParams.SetOneMaxMinimum;

					if( setParams.SetOneMaxNumber == 0 )
						dSetOneMaxNumber = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number;
					else
						dSetOneMaxNumber = setParams.SetOneMaxNumber;

					if( setParams.SetOneMinMaximum == 0 )
						dSetOneMinMaximum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum;
					else
						dSetOneMinMaximum = setParams.SetOneMinMaximum;

					if( setParams.SetOneMaxMaximum == 0 )
						dSetOneMaxMaximum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Maximum;
					else
						dSetOneMaxMaximum = setParams.SetOneMaxMaximum;

					if( setParams.SetOneMinMembership == 0 )
						dSetOneMinMembership = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Membership;
					else
						dSetOneMinMembership = setParams.SetOneMinMembership;

					if( setParams.SetOneMinMinimum == 0 )
						dSetOneMinMinimum = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Minimum;
					else
						dSetOneMinMinimum = setParams.SetOneMinMinimum;

					if( setParams.SetOneMinNumber == 0 )
						dSetOneMinNumber = ( ( FuzzyNumber )this.FuzzyArray[ n ] ).Number;
					else
						dSetOneMinNumber = setParams.SetOneMinNumber;


					if( dSetOneMinMaximum >= dSetTwoMinMaximum &&
						dSetOneMaxMaximum <= dSetTwoMaxMaximum &&
						dSetOneMinMembership >= dSetTwoMinMembership &&
						dSetOneMaxMembership <= dSetTwoMaxMembership &&
						dSetOneMinMinimum >= dSetTwoMinMinimum &&
						dSetOneMaxMinimum <= dSetTwoMaxMinimum &&
						dSetOneMinNumber >= dSetTwoMinNumber &&
						dSetOneMaxNumber <= dSetTwoMaxNumber )						
					{
						bFound = true;
						n=this.Count;
					}
				}

				if( bFound == false )
				{
					returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )fuzzySet.FuzzyArray[ i ] );
				}
			}

			return returnSet;

		}
示例#5
0
		/// <summary>
		/// return an intersection of the two sets
		/// </summary>
		/// <param name="setOne"></param>
		/// <param name="?"></param>
		/// <returns></returns>
		public FuzzyNumberSet Intersection( FuzzySet fuzzySet )
		{
			FuzzyNumberSet returnSet = new FuzzyNumberSet();

			for( int i=0; i<this.Count; i++ )
			{
				for( int n=0; n<fuzzySet.Count; n++ )
				{
					/// can't decide if name and id should be in here or not
					/// leave them out for now as they are meant to be optional
					if( ( ( FuzzyNumber )this.FuzzyArray[ i ] ).Maximum == ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Maximum &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Membership == ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Membership &&
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Minimum == ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Minimum && 
						( ( FuzzyNumber )this.FuzzyArray[ i ] ).Number == ( ( FuzzyNumber )fuzzySet.FuzzyArray[ n ] ).Number )
					{
						returnSet[ returnSet.Count + 1 ] = new FuzzyNumber( ( FuzzyNumber )this.FuzzyArray[ i ] );
					}
				}
			}

			return returnSet;
		}