Exemplo n.º 1
0
bool operator==( Relation& relationA, Relation& relationB ) {

	// Check to see if name is the same
	if ( relationA.getName( ) != relationB.getName( ) ) {
		return false;
	}

	// Check for the same attributes
	if ( relationA.getAttributes( ) != relationB.getAttributes( ) ) {
		return false;
	}

	// Check for the same keys
	if ( relationA.getKeys( ) != relationB.getKeys( ) ) {
		return false;
	}

	// Check for number of rows
	if ( relationA.getNumTuples( ) != relationB.getNumTuples( ) ) {
		return false;
	}

	// Make sure each row exists in both relations
	for ( unsigned i = 0; i < relationB.getNumTuples( ); ++i ) {
		if ( !relationA.hasTuple( relationB.getRow( i ) ) ) {
			return false;
		}
	}

	return true;
}
Exemplo n.º 2
0
ExampleSet::ExampleSet(const Relation &relation)
{
	size = relation.getNInstances(), inVars = 0, outVars = 0;

	// Calcula a quantidade de variáveis de entrada e saída que existirão
	for (const Attribute* attr : relation.getAttributes())
	{
		uint inc = attr->isNumeric() ? 1 : attr->getNominalCard();

		if (attr->isLast())
			outVars += inc;
		else
			inVars += inc;
	}

	set(size, inVars, outVars);
}