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

📄 rsesorthogonalfilescaler.cpp

📁 粗慥集成算法集合 ,并有详细的文档资料和测试数据处
💻 CPP
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........: 960628
// Description...:
// Revisions.....:
//===================================================================

#include <stdafx.h> // Precompiled headers.
#include <copyright.h>

#include <kernel/rses/algorithms/rsesorthogonalfilescaler.h>

#include <kernel/rses/structures/rsesdecisiontable.h>

#include <kernel/rses/library/tscal.h>
#include <kernel/rses/library/tdtable.h>
#include <kernel/rses/library/err.h>

#include <kernel/utilities/creator.h>

//-------------------------------------------------------------------
// Methods for class RSESOrthogonalFileScaler.
//===================================================================

//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================

//-------------------------------------------------------------------
// Method........: Constructor
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================

RSESOrthogonalFileScaler::RSESOrthogonalFileScaler() {
	SetMode(Scaler::MODE_LOAD);
}

//-------------------------------------------------------------------
// Method........: Destructor
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================

RSESOrthogonalFileScaler::~RSESOrthogonalFileScaler() {
}

//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================

IMPLEMENTIDMETHODS(RSESOrthogonalFileScaler, RSESORTHOGONALFILESCALER, OrthogonalFileScaler)

//-------------------------------------------------------------------
// Methods inherited from Algorithm.
//===================================================================

//-------------------------------------------------------------------
// Method........: IsApplicable
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns true if the algorithm is applicable to the
//                 structure, false otherwise.
// Comments......:
// Revisions.....:
//===================================================================

bool
RSESOrthogonalFileScaler::IsApplicable(const Structure &structure, bool /*warn*/) const {
	return structure.IsA(RSESDECISIONTABLE);
}

//-------------------------------------------------------------------
// Methods inherited from OrthogonalScaler.
//===================================================================

//-------------------------------------------------------------------
// Method........: Discretize
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================

DecisionTable *
RSESOrthogonalFileScaler::Discretize(DecisionTable &table) const {

	// Check if input is of expected type.
	if (!IsApplicable(table))
		return NULL;

	// Cast to verified type.
	Handle<RSESDecisionTable> wrapper = dynamic_cast(RSESDecisionTable *, &table);

	TDTable *input;
	TDTable *output;

	// Get embedded RSES table.
	input = wrapper->decisiontable_;

	if (input == NULL) {
		Message::Error("The input RSES decision table is invalid.");
		return NULL;
	}

	bool masked = true;

	// Is there anything to scale?
	if ((wrapper->GetNoObjects(masked) == 0) || (wrapper->GetNoAttributes(masked) == 0)) {
		Message::Error("The decision table is empty and cannot be scaled.");
		return NULL;
	}

	// Set scaling method (cfr. RSES technical doc.)
	int method = 0;

	// Perform scaling. Scale from a given file containing cut values.
	try {
		TScaler scaler;
		output = scaler.ScalFromFile(input, const_cast(char *, GetFilename().GetBuffer()), method);
	}
	catch (Error &error) {
		Message::RSESError("An error occurred during scaling of decision table.", error.GetMessage());
		return NULL;
	}

	// Was an output produced?
	if (output == NULL) {
		Message::Error("The RSES scaler did not produce a valid output.");
		return NULL;
	}

	// Is there no need to create a new wrapper?
	if (output == input)
		return wrapper.Release();

	// Create a wrapper for the result.
	Handle<RSESDecisionTable> result = Creator::RSESDecisionTable();

	// Clean up and prepare the result wrapper.
	delete result->decisiontable_;
	result->decisiontable_ = output;

	return result.Release();

}

⌨️ 快捷键说明

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