📄 approximator.cpp
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================
#include <stdafx.h> // Precompiled headers.
#include <copyright.h>
#include <kernel/algorithms/approximator.h>
#include <kernel/algorithms/partitioner.h>
#include <kernel/algorithms/keyword.h>
#include <kernel/structures/decisiontable.h>
#include <kernel/structures/reduct.h>
#include <kernel/structures/equivalenceclass.h>
#include <kernel/structures/equivalenceclasses.h>
#include <kernel/structures/approximation.h>
#include <kernel/utilities/creator.h>
#include <kernel/basic/message.h>
#include <common/objectmanager.h>
//-------------------------------------------------------------------
// Methods for class Approximator.
//===================================================================
//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================
Approximator::Approximator() {
decision_ = Undefined::Integer();
attributes_ = Undefined::String();
precision_ = 0.0f;
}
Approximator::~Approximator() {
}
//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================
IMPLEMENTIDMETHODS(Approximator, APPROXIMATOR, Algorithm)
//-------------------------------------------------------------------
// Methods inherited from Algorithm.
//===================================================================
//-------------------------------------------------------------------
// Method........: GetParameters
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
String
Approximator::GetParameters() const {
String parameters, formatted;
// Decision.
parameters += Keyword::Decision();
parameters += Keyword::Assignment();
parameters += String::Format(GetDecisionValue());
parameters += Keyword::Separator();
// Precision.
parameters += Keyword::Precision();
parameters += Keyword::Assignment();
parameters += String::Format(GetPrecision());
parameters += Keyword::Separator();
// Attributes.
parameters += Keyword::Attributes();
parameters += Keyword::Assignment();
parameters += GetAttributes();
return parameters;
}
//-------------------------------------------------------------------
// Method........: SetParameter
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
Approximator::SetParameter(const String &keyword, const String &value) {
// Decision.
if (keyword == Keyword::Decision() && value.IsInteger())
return SetDecisionValue(value.GetInteger());
// Precision.
if (keyword == Keyword::Precision() && value.IsFloat())
return SetPrecision(value.GetFloat());
// Attributes.
if (keyword == Keyword::Attributes())
return SetAttributes(value);
return false;
}
//-------------------------------------------------------------------
// Method........: IsApplicable
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns true if the algorithm is applicable to the
// structure, false otherwise.
// Comments......:
// Revisions.....:
//===================================================================
bool
Approximator::IsApplicable(const Structure &structure, bool /*warn*/) const {
return structure.IsA(DECISIONTABLE);
}
//-------------------------------------------------------------------
// Method........: Apply
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Calculates the rough approximation of the set of
// objects with a certain decision, using a certain
// set of attributes. A precision level p can be set.
//
// Let m be the rough membership value. Assign the
// eq. classes as follows:
//
// if m >= 1 - p then in lower appr.
// if m > p then in upper appr.
//
// Note that p = 0 implies the "traditional" meaning
// of the lower/upper approximations.
//
// The value of p should lie in the range [0, 0.5].
//
// Comments......: Assumes that library clients use handles.
// Revisions.....: A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -