📄 rsesreductshortener.cpp
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================
#include <stdafx.h> // Precompiled headers.
#include <copyright.h>
#include <kernel/rses/algorithms/rsesreductshortener.h>
#include <kernel/algorithms/keyword.h>
#include <kernel/rses/structures/rsesreducts.h>
#include <kernel/rses/structures/rsesdecisiontable.h>
#include <kernel/rses/library/trr_mem.h>
#include <kernel/rses/library/trr_calc.h>
#include <kernel/rses/library/err.h>
#include <kernel/basic/message.h>
//-------------------------------------------------------------------
// Methods for class RSESReductShortener.
//===================================================================
//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================
//-------------------------------------------------------------------
// Method........: Constructor
// Author........:
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
RSESReductShortener::RSESReductShortener() {
SetDiscernibilityRatio(0.75);
}
//-------------------------------------------------------------------
// Method........: Destructor
// Author........:
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
RSESReductShortener::~RSESReductShortener() {
}
//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================
IMPLEMENTIDMETHODS(RSESReductShortener, RSESREDUCTSHORTENER, ReductShortener)
//-------------------------------------------------------------------
// Methods inherited from Algorithm.
//===================================================================
//-------------------------------------------------------------------
// Method........: GetParameters
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
String
RSESReductShortener::GetParameters() const {
String parameters;
parameters += Keyword::Ratio();
parameters += Keyword::Assignment();
parameters += String::Format(GetDiscernibilityRatio());
return parameters;
}
//-------------------------------------------------------------------
// Method........: SetParameter
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
RSESReductShortener::SetParameter(const String &keyword, const String &value) {
if (keyword == Keyword::Ratio() && value.IsFloat())
return SetDiscernibilityRatio(value.GetFloat());
return false;
}
//-------------------------------------------------------------------
// Method........: IsApplicable
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
RSESReductShortener::IsApplicable(const Structure &structure, bool /*warn*/) const {
return structure.IsA(RSESREDUCTS);
}
//-------------------------------------------------------------------
// Method........: Apply
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Assumes that library clients use handles.
// Revisions.....:
//===================================================================
Structure *
RSESReductShortener::Apply(Structure &structure) const {
// Verify input.
if (!IsApplicable(structure))
return NULL;
// Cast to verified type.
Handle<RSESReducts> reducts = dynamic_cast(RSESReducts *, &structure);
// Get originating RSES decision table.
Handle<RSESDecisionTable> table = dynamic_cast(RSESDecisionTable *, reducts->FindParent(RSESDECISIONTABLE));
if (table.IsNULL()) {
Message::Error("Could not find originating RSES decision table.");
return NULL;
}
// Is the embedded RSES object instantiated?
if (reducts->reducts_ == NULL) {
Message::Error("No reducts to shorten.");
return NULL;
}
// Does the embedded reduct and rule memory have any rules attached?
try {
if (reducts->reducts_->NoRules() > 0) {
Message::Error("Cannot shorten reducts with derived rules.");
return NULL;
}
}
catch (Error &error) {
Message::RSESError("Error accessing embedded RSES reduct and rule memory.", error.GetMessage());
return NULL;
}
// Do the shortening.
/*
try {
TRedRulCalc algorithm;
algorithm.ShortenReducts(table->decisiontable_, reducts->reducts_, GetDiscernibilityRatio());
}
catch (Error &error) {
Message::RSESError("Error shortening reducts with reduct shortener from RSES library.", error.GetMessage());
return NULL;
}
return reducts.Release();
*/
Message::Error("Not yet implemented in the RSES library.");
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -