Пример #1
0
		public void create_classifier()
		{
			a = new FuzzySet();
			a["low"] = new Triangle(0.0, 0.0, 0.5);
			a["mid"] = new Triangle(0.0, 0.5, 1.0);
			a["high"]= new Triangle(0.5, 1.0, 1.0);			
		}
Пример #2
0
		public TriangleClassifier(string[] names,
			                          double begin=0.0, double end=1.0,
			                          string name="", 
			                          bool edge=false, double cross=1.0)
		{
			this.Domain = new Domains.RationalRange(begin, end);
			double wide, step, p;
			this.Clear();
			if (names.Length<2) {
				throw new ArgumentException();
			}
			if (!edge) {
				wide = (end-begin)*(cross+1) / (2*(names.Length+1));
				step = (end-begin) / (names.Length + 1);
				p = begin + (end-begin) / (names.Length + 1);
			}
			else {
				wide = (end-begin)*cross / (names.Length*2 - 2);
				step = (end-begin) / (names.Length - 1);
				p = begin;
			}
//			Console.WriteLine("Triangle classifier ctor");
//			Console.WriteLine("edge={0}, cross={1}, begin={2}, end={3}, n={4}", edge, cross, begin, end, names.Length);
//			Console.WriteLine("wide={0}, step={1}, p={2}", wide, step, p);
			foreach (string term in names) {
				this[term] = new Triangle(p-wide, p, p+wide);
				Console.WriteLine("term={0}, {1}, {2}, {3}", term, p-wide, p, p+wide);
				p+=step;
			}
		}
Пример #3
0
		public void SmallRangeIterate()
		{
			Subset s = new Triangle(0.0, 2.0, 3.0);
			List<double> a = new List<double>();
			foreach (double num in s.Domain) {
				a.Add(num);
			}
			Assert.AreEqual(0.0, a[0], "Начальное значение неверно");
			Assert.AreEqual(3.0, a[a.Count-1], "Конечное значение неверно");
		}