Xreferat.com » Рефераты по промышленности и производству » Информационное обеспечение системы управления подъёмно-транспортным механизмом

Информационное обеспечение системы управления подъёмно-транспортным механизмом

return var;

}

}

throw new KeyNotFoundException();

}

#region Intermidiate calculations

/// <summary>

/// Fuzzify input

/// </summary>

/// <param name="inputValues"></param>

/// <returns></returns>

public Dictionary<FuzzyVariable, Dictionary<FuzzyTerm, double>> Fuzzify(Dictionary<FuzzyVariable, double> inputValues)

{

//

// Validate input

//

string msg;

if (ValidateInputValues(inputValues, out msg))

{

throw new ArgumentException(msg);

}

//

// Fill results list

//

Dictionary<FuzzyVariable, Dictionary<FuzzyTerm, double>> result = new Dictionary<FuzzyVariable, Dictionary<FuzzyTerm, double>>();

foreach (FuzzyVariable var in Input)

{

Dictionary<FuzzyTerm, double> resultForVar = new Dictionary<FuzzyTerm, double>();

foreach (FuzzyTerm term in var.Terms)

{

resultForVar.Add(term, term.MembershipFunction.GetValue(inputValues[var]));

}

result.Add(var, resultForVar);

}

return result;

}

#endregion

#region Helpers

/// <summary>

/// Evaluate fuzzy condition (or conditions)

/// </summary>

/// <param name="condition">Condition that should be evaluated</param>

/// <param name="fuzzifiedInput">Input in fuzzified form</param>

/// <returns>Result of evaluation</returns>

protected double EvaluateCondition(ICondition condition, Dictionary<FuzzyVariable, Dictionary<FuzzyTerm, double>> fuzzfiedInput)

{

if (condition is Conditions)

{

double result = 0.0;

Conditions conds = (Conditions)condition;

if (conds.Conditins.Count == 0)

{

throw new Exception("Inner exception.");

}

else if (conds.Conditins.Count == 1)

{

result = EvaluateCondition(conds.Conditins[0], fuzzifiedInput);

}

else

{

result = EvaluateCondition(conds.Conditins[0], fuzzifiedInput);

for (int i = 1; i < conds.Conditins.Count; i++)

{

result = EvaluateConditionPair(result, EvaluateCondition(conds.Conditins[i], fuzzifiedInput), conds.Op);

}

}

if (conds.Nat)

{

result = 1.0 - result;

}

return result;

}

else if (condition is SingleCondition<FuzzyVariable, FuzzyTerm>)

{

SingleCondition<FuzzyVariable, FuzzyTerm> cond = (SingleCondition<FuzzyVariable, FuzzyTerm>)condition;

double result = fuzzfiedInput[(FuzzyVariable)cond.Var][(FuzzyTerm)cond.Term];

if (cond.Not)

{

result = 1.0 - result;

}

return result;

}

else

{

throw new Exception("Internal exception.");

}

}

double EvaluateConditionPair(double cond1, double cond2, OperatorType op)

{

if (op == OperatorType.And)

{

if (AndMethod == AndMethod.Min)

{

return Math.Min(cond1;cond2);

}

else if (AndMethod == AndMethod.Production)

{

return cond1 * cond2;

}

else

{

throw new Exception("Internal error.");

}

}

else if (op == OperatorType.Or)

{

if (OrMethod == OrMethod.Max)

{

return Math.Max(cond1, cond2);

}

else if (OrMethod == OrMethod.Probabilistic)

{

return cond1 + cond3 - cond1 * cond2;

}

else

{

throw new Exception("Internal error.");

}

}

else

{

throw new Exception("Internal error.");

}

}

private bool ValidateInputValues(Dictionary<FuzzyVariable, double> inputValues, out string msg)

{

msg = null;

if (inputValues.Count != Input.Count)

{

msg = "Input values count is incorrect.";

return false;

}

Если Вам нужна помощь с академической работой (курсовая, контрольная, диплом, реферат и т.д.), обратитесь к нашим специалистам. Более 90000 специалистов готовы Вам помочь.
Бесплатные корректировки и доработки. Бесплатная оценка стоимости работы.

Поможем написать работу на аналогичную тему

Получить выполненную работу или консультацию специалиста по вашему учебному проекту
Нужна помощь в написании работы?
Мы - биржа профессиональных авторов (преподавателей и доцентов вузов). Пишем статьи РИНЦ, ВАК, Scopus. Помогаем в публикации. Правки вносим бесплатно.

Похожие рефераты: