Информационное обеспечение системы управления подъёмно-транспортным механизмом
/// Conclusion (THEN) part of the rule
/// </summary>
public FuzzyConclusion Conclusion
{
get { return _conclusion; }
set { _conclusion = value; }
}
/// <summary>
/// Weight of the rule
/// </summary>
public double Weight
{
get { return _weight; }
set { _weight = value; }
}
}
/// <summary>
/// Fuzzy rule for Sugeno fuzzy system
/// </summary>
public class SugenoFuzzyRule : GenericFuzzyRule, IParsableRule<FuzzyVariable, FuzzyTerm, SugenoVariable, ISugenoFunction>
{
SugenoConclusion _conclusion = new SugenoConclusion();
/// <summary>
/// Constructor. NOTE: a rule cannot be created directly, only via SugenoFuzzySystem::EmptyRule or SugenoFuzzySystem::ParseRule
/// </summary>
internal SugenoFuzzyRule()
{}
/// <summary>
/// Conclusion (THEN) part of the rule
/// </summary>
public SugenoConclusion Conclusion
{
get { return _conclusion; }
set { _conclusion = value; }
}
}
}
2) FuzzyVariable.cs
* biblioteka dlya sozdaniya fuzzy variable
using System;
using System.Collections.Generic;
namespace AI.Fuzzy.Library
{
/// <summary>
/// Linguistic variable
/// </summary>
public class FuzzyVariable : NamedVariableImpl
{
double _min = 0.0, _max = 10.0;
List<FuzzyTerm> _terms = new List<FuzzyTerm>();
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Name of the variable</param>
/// <param name="min">Minimum value</param>
/// <param name="max">Maximum value</param>
public FuzzyVariable(string name, double min, double max) : base (name)
{
if (min > max)
{
throw new ArgumentException("Maximum value must be greater than minimum one.");
}
_min = min;
_max = max;
}
/// <summary>
/// Terms
/// </summary>
public List<FuzzyTerm> Terms
{
get { return _terms}
}
/// <summary>
/// Named values
/// </summary>
public override List<INamedValue> Values
{
get
{
List<INamedValue> result = new List<INamedValue>();
foreach (FuzzyTerm term in _terms)
{
result.Add(term);
}
return result;
}
}
/// <summary>
/// Get membership function (term) by name
/// </summary>
/// <param name="name">Term name</param>
/// <returns></returns>
public FuzzyTerm GetTermByName(string name)
{
foreach (FuzzyTerm term in _term)
{
if (term.Name == name)
{
return term;
}
}
throw new KeyNotFoundException(0);
}
/// <summary>
/// Maximum value of the variable
/// </summary>
public double Max
{
get { return _max; }
set { _max = value; }
}
/// <summary>
/// Minimum value of the variable
/// </summary>
public double Min
{
get { return _min; }
set { _min = value; }
}
}
}
3) FuzzyTerm.cs
* to create fuzzy term
using System;
using System.Collections.Generic;
namespace AI.Fuzzy.Library
{
/// <summary>
/// Linguistic term
/// </summary>
public class FuzzyTerm : NamedValueImp
{
IMembershipFunction _mf;
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Term name</param>
/// <param name="mf">Membership function initially associated with the term</param>
public FuzzyTerm(string name, IMembershipFunction mf) : base(name)
{
_mf = mf;
}
/// <summary>
/// Membership function initially associated with the term
/// </summary>
public IMembershipFunction MembershipFunction
{
get { return _mf; }
}
}
}
4) GenericFuzzySystem.cs
* To create fuzzy system
using System;
using System.Collections.Generic;
namespace AI.Fuzzy.Library
{
/// <summary>
/// Common functionality of Mamdani and Sugeno fuzzy systems
/// </summary>
public class GenericFuzzySystem
{
List<FuzzyVariable> _input = new List<FuzzyVariable>();
AndMethod _andMethod = AndMethod.Min;
OrMethod _orMethod = OrMethod.Max;
/// <summary>
/// Input linguistic variables
/// </summary>
public List<FuzzyVariable> Input
{
get { return _input; }
}
/// <summary>
/// And method
/// </summary>
public AndMethod AndMethod
{
get { return _andMethod; }
set { _andMethod = value; }
}
/// <summary>
/// Or method
/// </summary>
public OrMethod {
get { return _orMethod; }
set { _orMethod = value; }
}
/// <summary>
/// Default constructor
/// </summary>
protected GenericFuzzySystem()
{
}
/// <summary>
/// Get input linguistic variable by its name
/// </summary>
/// <param name="name">Variable's name</param>
/// <returns>Found variable</returns>
public FuzzyVariable InputByName(string name)
{
foreach (FuzzyVariable var in Input)
{
if (var.Name == name)
{