示例#1
0
bool Normalization::operator!=(const Normalization &param1)
{
	return !(param1.getMaxValue() == this->getMaxValue() &&
			 param1.getMinValue() == this->getMinValue() &&
			 param1.getThreshold() == this->getThreshold() &&
			 param1.getElongation() == this->getElongation() &&
			 param1.getAmplitude() == this->getAmplitude() &&
			 param1.getType() == this->getType() &&
			 param1.getName() == this->getName());
}
示例#2
0
bool TrainingSetFile::flush()
{
	QXmlStreamWriter tsWriteXML;

	int
			nPatterns = ts->getPatternCount(),
			nInputs = ts->getInputsSize(),
			nTargets = ts->getTargetsSize();

	QString strInputs,
			strTargets;

	vector<vector<double> >
			inputs = ts->getInputs(),
			targets = ts->getTargets();

	Normalization
			*inputsNorm = ts->getInputsNormalization(),
			*targetsNorm = ts->getTargetsNormalization();

	QString
			strInputsNorm = inputsNorm->getName(),
			strTargetsNorm = targetsNorm->getName();

	DataRepresentation
			*idr = ts->getInputsDataRepresentation(),
			*tdr = ts->getTargetsDataRepresentation();

	tsWriteXML.setDevice(this);
	tsWriteXML.setAutoFormatting(true);
	tsWriteXML.setAutoFormattingIndent(3);

	tsWriteXML.writeStartDocument();

	tsWriteXML.writeStartElement(STR_TRAININGSET);
	//Indica el numero de patrones a almacenar
	tsWriteXML.writeAttribute(STR_PATTERNSIZE, QString::number(nPatterns));

	//Indica el tamaño de las entradas
	tsWriteXML.writeAttribute(STR_INPUTSSIZE, QString::number(nInputs));

	//Indica el tamaño de las salidas
	tsWriteXML.writeAttribute(STR_TARGETSSIZE, QString::number(nTargets));

	//Indica propiedades particulares del archivo
	tsWriteXML.writeStartElement(STR_PROPERTIES);
	tsWriteXML.writeAttribute(STR_VERSION, "1.0.0");
	tsWriteXML.writeEndElement();

	//Este parametro indica que representacion grafica se usara para visualizar entradas
	tsWriteXML.writeStartElement(STR_INPUTSDATAREPRESENTATION);
	tsWriteXML.writeAttribute(STR_NAME, idr->getName());
	tsWriteXML.writeAttribute(STR_FORMAT, idr->getImageFormatName());
	tsWriteXML.writeAttribute(STR_WIDTH, QString::number(idr->getWidth()));
	tsWriteXML.writeAttribute(STR_HEIGHT, QString::number(idr->getHeight()));
	tsWriteXML.writeEndElement();

	//Este parametro indica que representacion grafica se usara para visualizar las salidas
	tsWriteXML.writeStartElement(STR_TARGETSDATAREPRESENTATION);
	tsWriteXML.writeAttribute(STR_NAME, tdr->getName());
	tsWriteXML.writeAttribute(STR_FORMAT, tdr->getImageFormatName());
	tsWriteXML.writeAttribute(STR_WIDTH, QString::number(tdr->getWidth()));
	tsWriteXML.writeAttribute(STR_HEIGHT, QString::number(tdr->getHeight()));
	tsWriteXML.writeEndElement();

	//Normalizacion de entradas
	tsWriteXML.writeStartElement(STR_INPUTSNORMALIZATION);
	tsWriteXML.writeAttribute(STR_TYPE, strInputsNorm);
	tsWriteXML.writeAttribute(STR_MAXVALUE, QString::number(inputsNorm->getMaxValue(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_MINVALUE, QString::number(inputsNorm->getMinValue(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_THRESHOLD, QString::number(inputsNorm->getThreshold(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_AMPLITUDE, QString::number(inputsNorm->getAmplitude(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_ELONGATION, QString::number(inputsNorm->getElongation(), decimalformat, decimals));
	tsWriteXML.writeEndElement();

	//Normalizacion de salidas
	tsWriteXML.writeStartElement(STR_TARGETSNORMALIZATION);
	tsWriteXML.writeAttribute(STR_TYPE, strTargetsNorm);
	tsWriteXML.writeAttribute(STR_MAXVALUE, QString::number(targetsNorm->getMaxValue(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_MINVALUE, QString::number(targetsNorm->getMinValue(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_THRESHOLD, QString::number(targetsNorm->getThreshold(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_AMPLITUDE, QString::number(targetsNorm->getAmplitude(), decimalformat, decimals));
	tsWriteXML.writeAttribute(STR_ELONGATION, QString::number(targetsNorm->getElongation(), decimalformat, decimals));
	tsWriteXML.writeEndElement();

	for(int p = 0; p < nPatterns; p++){
		tsWriteXML.writeStartElement(STR_PATTERN);
		tsWriteXML.writeAttribute(STR_INDEX, QString::number(p));
		//Se escriben las entradas
		tsWriteXML.writeStartElement(STR_INPUTS);
		strInputs = "";
		for(int i = 0; i < nInputs; i++){
			strInputs += QString::number(inputs[p][i], decimalformat, decimals);
			if(i != nInputs - 1){
				strInputs += STR_SEPARATOR;
			}
		}
		tsWriteXML.writeCharacters(strInputs);
		tsWriteXML.writeEndElement();//inputs

		//Se escriben las salidas
		tsWriteXML.writeStartElement(STR_TARGETS);
		strTargets = "";
		for(int t = 0; t < nTargets; t++){
			strTargets += QString::number(targets[p][t], decimalformat, decimals);
			if(t != nTargets - 1){
				strTargets += STR_SEPARATOR;
			}
		}
		//		tsXML.writeTextElement("targets", strTargets);
		tsWriteXML.writeCharacters(strTargets);
		tsWriteXML.writeEndElement();//targets
		tsWriteXML.writeEndElement();//pattern
	}
	tsWriteXML.writeEndElement();//trainingset
	tsWriteXML.writeEndDocument();

	return true;
}