⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reducer.cpp

📁 The ROSETTA C++ library is a collection of C++ classes and routines that enable discernibility-based
💻 CPP
字号:
//-------------------------------------------------------------------// Author........: Aleksander 豩rn// Date..........: 960307// Description...:// Revisions.....://===================================================================#include <stdafx.h> // Precompiled headers.#include <copyright.h>#include <kernel/algorithms/reducer.h>#include <kernel/algorithms/keyword.h>#include <kernel/structures/decisiontable.h>#include <kernel/structures/discernibilitymatrix.h>#include <kernel/utilities/discerner.h>#include <kernel/utilities/creator.h>#include <kernel/basic/message.h>//-------------------------------------------------------------------// Methods for class Reducer.//===================================================================//-------------------------------------------------------------------// Constructors/destructor.//===================================================================Reducer::Reducer() {  discernibility_  = Reduct::DISCERNIBILITY_FULL;	modulo_decision_ = true;	idg_             = false;	filename_idg_    = Undefined::String();	precompute_      = false;	brt_             = false;	precision_brt_   = 0.1f;}Reducer::~Reducer() {}//-------------------------------------------------------------------// Methods inherited from Identifier.//===================================================================IMPLEMENTIDMETHODS(Reducer, REDUCER, Algorithm)//-------------------------------------------------------------------// Methods inherited from Algorithm.//===================================================================//-------------------------------------------------------------------// Method........: GetParameters// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....://===================================================================StringReducer::GetParameters() const {	String parameters;	// Discernibility.	parameters += Keyword::Discernibility();	parameters += Keyword::Assignment();	parameters += Reduct::GetString(GetDiscernibility());	parameters += Keyword::Separator();	// Modulo decision?	parameters += Keyword::Modulo() + Keyword::Dot() + Keyword::Decision();	parameters += Keyword::Assignment();	parameters += String::Format(ModuloDecision());	// Use BRT?	if (ModuloDecision()) {		parameters += Keyword::Separator();		parameters += Keyword::BRT();		parameters += Keyword::Assignment();		parameters += String::Format(UseBRT());	}	// BRT precision.	if (ModuloDecision() && UseBRT()) {		parameters += Keyword::Separator();		parameters += Keyword::BRT() + Keyword::Dot() + Keyword::Precision();		parameters += Keyword::Assignment();		parameters += String::Format(GetBRTPrecision());	}	// Object selection.	if (GetDiscernibility() == Reduct::DISCERNIBILITY_OBJECT) {		parameters += Keyword::Separator();		parameters += GetObjectSelector().GetParameters();	}	parameters += Keyword::Separator();	// Use IDG?	parameters += Keyword::IDG();	parameters += Keyword::Assignment();	parameters += String::Format(UseIDG());	// IDG filename.	if (UseIDG()) {		parameters += Keyword::Separator();		parameters += Keyword::IDG() + Keyword::Dot() + Keyword::Filename();		parameters += Keyword::Assignment();		parameters += GetIDGFilename();	}	parameters += Keyword::Separator();	// Precompute entries?	parameters += Keyword::Precompute();	parameters += Keyword::Assignment();	parameters += String::Format(PrecomputeMatrix());	return parameters;}//-------------------------------------------------------------------// Method........: SetParameter// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....://===================================================================boolReducer::SetParameter(const String &keyword, const String &value) {	// Discernibility.	if (keyword == Keyword::Discernibility()) {		if (value == Reduct::GetString(Reduct::DISCERNIBILITY_FULL))			return SetDiscernibility(Reduct::DISCERNIBILITY_FULL);		if (value == Reduct::GetString(Reduct::DISCERNIBILITY_OBJECT))			return SetDiscernibility(Reduct::DISCERNIBILITY_OBJECT);		// For backwards compatibility.		String copy(value);		copy.ToLowercase();		if (copy == "object related")			return SetDiscernibility(Reduct::DISCERNIBILITY_OBJECT);		return false;	}	// Modulo decision.	if ((keyword == Keyword::Modulo() + Keyword::Dot() + Keyword::Decision()) && value.IsBoolean())		return ModuloDecision(value.GetBoolean());	// Modulo decision (backwards compatibility).	if (keyword == Keyword::UseDecision() && value.IsBoolean())		return ModuloDecision(value.GetBoolean());	// BRT.	if (keyword == Keyword::BRT() && value.IsBoolean())		return UseBRT(value.GetBoolean());	// BRT precision.	if ((keyword == Keyword::BRT() + Keyword::Dot() + Keyword::Precision()) && value.IsFloat())		return SetBRTPrecision(value.GetFloat());	// IDG.	if (keyword == Keyword::IDG() && value.IsBoolean())		return UseIDG(value.GetBoolean());	// IDG filename.	if (keyword == Keyword::IDG() + Keyword::Dot() + Keyword::Filename())		return SetIDGFilename(value);	// Precompute disc. matrix?	if (keyword == Keyword::Precompute() && value.IsBoolean())		return PrecomputeMatrix(value.GetBoolean());	// Object selection?	if (GetObjectSelector().SetParameter(keyword, value))		return true;	// Unknown keyword/value.	return false;}//-------------------------------------------------------------------// Method........: IsApplicable// Author........: Aleksander 豩rn// Date..........:// Description...: Returns true if the algorithm is applicable to the//                 structure, false otherwise.// Comments......:// Revisions.....://===================================================================boolReducer::IsApplicable(const Structure &structure, bool /*warn*/) const {	return structure.IsA(DECISIONTABLE);}//-------------------------------------------------------------------// Method........: Apply// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......: Note that the whole approach of computing the//                 full discernibility matrix (or rows of it) is not//                 optimal wrt memory considerations. For large//                 datasets or if memory is scarce, then one should//                 consider doing all the absorption on-the-fly and not//                 actually store the matrix entries before building and//                 simplifying the function.//// Revisions.....: A

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -