/*--------------------------------------------------------- * * Data Mining (C-RAM) * */ #include #include "mine.h" /* rule is a bit vector where "1" is don't care */ cuint16 sum, elements; unsigned int rawVariables[dataPoints], rawData[dataPoints]; /* problem parallized over rules */ #define rule PEid /* evaluate ((rule | variables) == (unsigned) variableMask) */ /* using C-RAM assembler code */ cboolean valid(const int variables) { int j, remainder = variables; cboolean r; rule.operate(0, op_one, writex); for (j = 0; j < independentVariables; j++) { if ((remainder & 1) == 0) rule.operate(j, op_xandm, writex); remainder = remainder >> 1; } r.operate(0, op_x, groupwrite); return (r); } /* insert data elements in an un-sophisticted way */ void parallelInsert(const unsigned int variables, const unsigned int data) { #ifdef NOASSEMBLER cif((rule | variables) == (unsigned) variableMask) #else /* NOASSEMBLER */ cif(valid(variables)) #endif /* NOASSEMBLER */ sum += data; elements += 1; cend } void inline insert(const unsigned int variables, const unsigned int data) { parallelInsert(variables, data); } cuint8 score() { cuint8 scores; scores = sum / elements; cif(elements < 1000 && elements > 100) scores = 0; cend return (scores); } unsigned int mine() { cuint17 bestRule; cuint8 scores; unsigned int dataElement; for (dataElement = 0; dataElement < dataPoints; dataElement++) insert(rawVariables[dataElement], rawData[dataElement]); scores = score(); bestRule.broadcast(scores.findmaxUnique(), rule); return (bestRule[0]); }