Beispiel #1
0
/*!
 *  \brief Write switch type operator into an XML stream.
 *  \param ioStreamer XML stream in which the operator is written.
 *  \param inIndent Whether XML output should be indented.
 */
void HPC::SwitchTypeOp::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag(getName(), inIndent);
	for(OperatorSetMap::const_iterator lIterMap = mOperatorSetMap.begin(); lIterMap != mOperatorSetMap.end(); ++lIterMap){
		ioStreamer.openTag(lIterMap->first, inIndent);
		for(Operator::Bag::const_iterator lIterBag = lIterMap->second.begin(); lIterBag != lIterMap->second.end(); ++lIterBag){
			Operator::Handle lOp = castHandleT<Operator>(*lIterBag);
			lOp->write(ioStreamer, inIndent);
		}
		ioStreamer.closeTag();
	}
	ioStreamer.closeTag();
	Beagle_StackTraceEndM();
}
/*!
 *  \brief Write an instruction super set into a Beagle XML stream.
 *  \param ioStreamer XMl streamer to write the super set into.
 *  \param inIndent Whether XML output should be indented.
 */
void LinGP::InstructionSuperSet::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	ioStreamer.openTag("InstructionSuperSet", inIndent);
	for(unsigned int i=0; i<mInstructionSets.size(); i++) {
		mInstructionSets[i]->write(ioStreamer);
	}
	ioStreamer.closeTag();
}
/*!
 *  \brief Write a primitive super set into a Beagle XML stream.
 *  \param ioStreamer XMl streamer to write the super set into.
 *  \param inIndent Whether XML output should be indented.
 */
void GP::PrimitiveSuperSet::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag("GP-PrimitiveSuperSet", inIndent);
	for(unsigned int i=0; i<mPrimitSets.size(); i++) mPrimitSets[i]->write(ioStreamer, inIndent);
	ioStreamer.closeTag();
	Beagle_StackTraceEndM("void GP::PrimitiveSuperSet::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const");
}
Beispiel #4
0
void PopulationManager::writeContent(PACC::XML::Streamer& ioStreamer, bool inIndent) const {
	schnaps_StackTraceBeginM();
	// write generator
	mGenerator->write(ioStreamer, inIndent);

	// write population source
	ioStreamer.openTag("Population");
	for (PopulationManager::const_iterator lIt = this->begin(); lIt != this->end(); lIt++) {
		ioStreamer.openTag("SubPopulation");
		ioStreamer.insertAttribute("time", SCHNAPS::uint2str(lIt->first));
		ioStreamer.insertAttribute("profile", lIt->second.mProfile);
		ioStreamer.insertAttribute("size", SCHNAPS::uint2str(lIt->second.mSize));
		ioStreamer.closeTag();
	}
	ioStreamer.closeTag();
	schnaps_StackTraceEndM("void SCHNAPS::Simulation::PopulationManager::writeContent(PACC::XML::Streamer&, bool) const");
}
/*!
 *  \brief Write a genotype into a XML streamer.
 *  \param ioStreamer XML streamer to use.
 *  \param inIndent Whether XML output should be indented.
 */
void Genotype::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag("Genotype", inIndent);
	ioStreamer.insertAttribute("type", getType());
	writeContent(ioStreamer, inIndent);
	ioStreamer.closeTag();
	Beagle_StackTraceEndM("void Genotype::write(PACC::XML::Streamer&,bool) const");
}
/*!
 *  \brief Write an max hits termination operator into a XML stream.
 *  \param ioStreamer XML streamer in which the operator is written.
 *  \param inIndent Whether XML output should be indented.
 */
void GP::TermMaxHitsOp::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag(getName(), inIndent);
	if(mMaxHits != NULL) ioStreamer.insertAttribute("hits", uint2str(mMaxHits->getWrappedValue()));
	else ioStreamer.insertAttribute("hits", uint2str(mMaxHitsDefault));
	ioStreamer.closeTag();
	Beagle_StackTraceEndM("void GP::TermMaxHitsOp::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const");
}
Beispiel #7
0
/*!
 *  \brief Write concept map of the factory into a XML streamer.
 *  \param ioStreamer XML streamer to write factory concept map into.
 *  \param inIndent Whether XML output should be indented.
 */
void Factory::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag("Factory", inIndent);
	std::map< std::string, std::string > lSortedMap;
	for(Factory::ConceptMap::const_iterator lIter=mConceptMap.begin();
	        lIter!=mConceptMap.end(); ++lIter) {
		lSortedMap[lIter->first] = lIter->second;
	}
	for(std::map< std::string, std::string >::const_iterator lIterSM=lSortedMap.begin();
	        lIterSM!=lSortedMap.end(); ++lIterSM) {
		ioStreamer.openTag("Concept", false);
		ioStreamer.insertAttribute("name", lIterSM->first);
		ioStreamer.insertAttribute("type", lIterSM->second);
		ioStreamer.closeTag();
	}
	ioStreamer.closeTag();
	Beagle_StackTraceEndM();
}
Beispiel #8
0
/*!
 *  \brief Write a max fitness termination operator into a XML stream.
 *  \param ioStreamer XML stream in which the operator is written.
 *  \param inIndent Whether XML output should be indented.
 */
void TermMaxFitnessOp::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag(getName(), inIndent);
	if(mMaxFitness != NULL)
		ioStreamer.insertAttribute("fitness", dbl2str(mMaxFitness->getWrappedValue()));
	else ioStreamer.insertAttribute("fitness", dbl2str(mMaxFitnessDefault));
	ioStreamer.closeTag();
	Beagle_StackTraceEndM();
}
/*!
 *  \brief Write OversizeOp operator into XML streamer.
 *  \param ioStreamer XML streamer to write OversizeOp operator into.
 *  \param inIndent Whether XML output should be indented.
 */
void OversizeOp::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag(getName(), inIndent);
	ioStreamer.insertAttribute("ratio_name", mOversizeRatioName);
	for(BreederNode::Handle lNode=getRootNode(); lNode!=NULL; lNode=lNode->getNextSibling()) {
		lNode->write(ioStreamer, inIndent);
	}
	ioStreamer.closeTag();
	Beagle_StackTraceEndM("void OversizeOp::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const");
}
/*!
 *  \brief Write a Koza's fitness into a Beagle XML streamer.
 *  \param ioStreamer XML streamer to use to write the fitness values.
 *  \param inIndent Whether XML output should be indented.
 */
void GP::FitnessKoza::writeContent(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag("Normalized", false);
	ioStreamer.insertStringContent(dbl2str(mValue));
	ioStreamer.closeTag();
	ioStreamer.openTag("Adjusted", false);
	ioStreamer.insertStringContent(dbl2str(mAdjustedFitness));
	ioStreamer.closeTag();
	ioStreamer.openTag("Standardized", false);
	ioStreamer.insertStringContent(dbl2str(mStandardizedFitness));
	ioStreamer.closeTag();
	ioStreamer.openTag("Raw", false);
	ioStreamer.insertStringContent(dbl2str(mRawFitness));
	ioStreamer.closeTag();
	ioStreamer.openTag("Hits", false);
	ioStreamer.insertStringContent(uint2str(mHits));
	ioStreamer.closeTag();
	Beagle_StackTraceEndM("void GP::FitnessKoza::writeContent(PACC::XML::Streamer&, bool) const");
}
Beispiel #11
0
/*!
 *  \brief Write a multiobjective fitness into an XML streamer.
 *  \param ioStreamer XML streamer to use to write the fitness value.
 *  \param inIndent Whether XML output should be indented.
 */
void FitnessMultiObj::writeContent(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.insertAttribute("size", uint2str(size()));
	for(unsigned int i=0; i<size(); ++i) {
		ioStreamer.openTag("Obj", false);
		ioStreamer.insertStringContent(dbl2str((*this)[i]));
		ioStreamer.closeTag();
	}
	Beagle_StackTraceEndM();
}
Beispiel #12
0
/*!
 *  \brief Write the actual vivarium population in a XML streamer.
 *  \param ioStreamer XML streamer to write the vivarium population into.
 *  \param inIndent Whether XML output should be indented.
 */
void Vivarium::writePopulation(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	ioStreamer.openTag("Population", inIndent);
	ioStreamer.insertAttribute("size", uint2str(size()));
	for(unsigned int i=0; i<size(); ++i) {
		Beagle_NonNullPointerAssertM((*this)[i]);
		(*this)[i]->write(ioStreamer, inIndent);
	}
	ioStreamer.closeTag();
	Beagle_StackTraceEndM();
}
Beispiel #13
0
/*!
 *  \brief Write fitness of an individual into a XML streamer.
 *  \param ioStreamer XML streamer to write the fitness into.
 *  \param inIndent Whether XML output should be indented.
 */
void Individual::writeFitness(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	if(mFitness == NULL) {
		ioStreamer.openTag("Fitness", false);
		ioStreamer.insertAttribute("valid", "no");
		ioStreamer.closeTag();
	} else {
		mFitness->write(ioStreamer, inIndent);
	}
	Beagle_StackTraceEndM();
}
/*!
 *  \brief Write a stats into a XML streamer.
 *  \param ioStreamer XML streamer used to write the stats into.
 *  \param inIndent Whether XML output should be indented.
 */
void Stats::writeContent(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	if(mValid) {
		if(mID.empty() == false) ioStreamer.insertAttribute("id", mID);
		ioStreamer.insertAttribute("generation", uint2str(mGeneration));
		ioStreamer.insertAttribute("popsize", uint2str(mPopSize));
		std::set<std::string> lSortedItemKey;
		for(ItemMap::const_iterator lIterMap=mItemMap.begin(); lIterMap!=mItemMap.end(); ++lIterMap) {
			lSortedItemKey.insert(lIterMap->first);
		}
		for(std::set<std::string>::const_iterator lIterSet=lSortedItemKey.begin();
		    lIterSet!=lSortedItemKey.end(); ++lIterSet) {
			ioStreamer.openTag("Item", false);
			ioStreamer.insertAttribute("key", *lIterSet);
			ItemMap::const_iterator lIterMap = mItemMap.find(*lIterSet);
			ioStreamer.insertStringContent(dbl2str(lIterMap->second,12));
			ioStreamer.closeTag();
		}
		for(unsigned int i=0; i<size(); ++i) {
			ioStreamer.openTag("Measure", inIndent);
			ioStreamer.insertAttribute("id", (*this)[i].mID);
			ioStreamer.openTag("Avg", false);
			ioStreamer.insertStringContent(dbl2str((*this)[i].mAvg,12));
			ioStreamer.closeTag();
			ioStreamer.openTag("Std", false);
			ioStreamer.insertStringContent(dbl2str((*this)[i].mStd,12));
			ioStreamer.closeTag();
			ioStreamer.openTag("Max", false);
			ioStreamer.insertStringContent(dbl2str((*this)[i].mMax,12));
			ioStreamer.closeTag();
			ioStreamer.openTag("Min", false);
			ioStreamer.insertStringContent(dbl2str((*this)[i].mMin,12));
			ioStreamer.closeTag();
			ioStreamer.closeTag();
		}
	} else ioStreamer.insertAttribute("valid", "no");
	Beagle_StackTraceEndM("void Stats::writeContent(PACC::XML::Streamer&,bool) const");
}
Beispiel #15
0
/*!
 *  \brief Write members of the vivarium in a XML streamer.
 *  \param ioStreamer XML streamer to write the members into.
 *  \param inIndent Whether XML output should be indented.
 */
void Vivarium::writeMembers(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	Beagle_StackTraceBeginM();
	for(MemberMap::const_iterator lIterMap=mMemberMap.begin();
	        lIterMap!=mMemberMap.end(); ++lIterMap) {
		ioStreamer.openTag(lIterMap->first, inIndent);
		Member::Handle lMember = castHandleT<Member>(lIterMap->second);
		ioStreamer.insertAttribute("type", lMember->getType());
		lMember->writeContent(ioStreamer, inIndent);
		ioStreamer.closeTag();
	}
	Beagle_StackTraceEndM();
}
Beispiel #16
0
/*!
 *  \brief Write a primitive sub-tree into a XML streamer.
 *  \param ioStreamer A reference to the XML streamer to write the tree into.
 *  \param inN Index of the actual subtree root node in the vector.
 *  \param inIndent Whether XML output should be indented.
 *  \throw SCHNAPS::Core::AssertException if the subtree size doesn't match.
 */
unsigned int PrimitiveTree::writeSubTree(PACC::XML::Streamer& ioStreamer, unsigned int inN, bool inIndent) const {
	schnaps_StackTraceBeginM();
	schnaps_AssertM(inN < size());
	unsigned int lNumberArguments = (*this)[inN].mPrimitive->getNumberArguments();
	ioStreamer.openTag((*this)[inN].mPrimitive->getName(), inIndent);
	(*this)[inN].mPrimitive->writeContent(ioStreamer, inIndent);
	
	unsigned int lSubTreeSize = 1;
	for (unsigned int i = 0; i < lNumberArguments; ++i) {
		lSubTreeSize += writeSubTree(ioStreamer, (lSubTreeSize+inN), inIndent);
	}
	schnaps_AssertM(lSubTreeSize == (*this)[inN].mSubTreeSize);
	
	ioStreamer.closeTag();
	return lSubTreeSize;
	schnaps_StackTraceEndM("void SCHNAPS::Core::PrimitiveTree::writeSubTree(PACC::XML::Streamer&, bool) const");
}
void TreeSTag::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const {
	Beagle_StackTraceBeginM();
	
	ioStreamer.openTag("Genotype", inIndent);
	ioStreamer.insertAttribute("type", "gptreetag");
	ioStreamer.insertAttribute("structureid", uint2str(mStructureID));
	ioStreamer.insertAttribute("size", uint2str(size()));
	ioStreamer.insertAttribute("depth", uint2str(getTreeDepth()));
	ioStreamer.insertAttribute("primitSetId", uint2str(getPrimitiveSetIndex()));
	ioStreamer.insertAttribute("nbArgs", uint2str(getNumberArguments()));
	if(size() > 0) {
		unsigned int lSizeSubTree = writeSubTree(ioStreamer, 0, inIndent);
		Beagle_AssertM(lSizeSubTree == size());
	}
	ioStreamer.closeTag();
	
//	if(mBondGraph!=NULL) {
//		mBondGraph->write(ioStreamer,inIndent);
//	} 
	
	Beagle_StackTraceEndM("void GP::Tree::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const");
}
void BGFitness::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const {
	//	Beagle_StackTraceBeginM();
	ioStreamer.openTag("Fitness", inIndent);
	ioStreamer.insertAttribute("type", "LogFitness");
	if(isValid()) {
		ioStreamer.openTag("Obj", inIndent);

		ioStreamer.insertStringContent(dbl2str(mFitness).c_str());

		ioStreamer.closeTag();
		ioStreamer.openTag("OriObj", inIndent);
		
		ioStreamer.insertStringContent(dbl2str(mOriginalFitness).c_str());
		
		ioStreamer.closeTag();
		
		//State Matrix
		ioStreamer.openTag("StateMatrices",inIndent);
//		MatrixInterface lInterface;		
		for(unsigned int i = 0; i < mStateMatrices.size(); ++i) {
			mStateMatrices[i].write(ioStreamer);
//			lInterface.write(mStateMatrices[i],ioStreamer);
		}
		ioStreamer.closeTag();
		
		if(mDataSet.size() == 0) {
			for(unsigned int i = 0; i < mVariableData.size(); ++i) {
				ioStreamer.openTag("Data", false);
				ioStreamer.insertAttribute("Name", mVariableName[i]);
				ioStreamer.insertAttribute("usize", uint2str(mUncompressedSize[i]));
				ioStreamer.insertStringContent(mVariableData[i]);
				ioStreamer.closeTag();
			}
		} else {
			for(std::map<unsigned int, double>::const_iterator lIter = mDataSet.begin(); lIter != mDataSet.end(); ++lIter) {
				ioStreamer.openTag("DataSet", inIndent);
				ioStreamer.insertAttribute("ID", uint2str(lIter->first));
				ioStreamer.openTag("Obj", false);
				ioStreamer.insertStringContent( dbl2str(lIter->second).c_str() );
				ioStreamer.closeTag();
				for(unsigned int i = 0; i < mVariableData.size(); ++i) {
					if(lIter->first == mVariableDataSet[i]) {
						ioStreamer.openTag("Data", false);
						ioStreamer.insertAttribute("Name", mVariableName[i]);
						ioStreamer.insertAttribute("usize", uint2str(mUncompressedSize[i]));
						ioStreamer.insertStringContent(mVariableData[i]);
						ioStreamer.closeTag();
					}
				}
				ioStreamer.closeTag();
			}
		}
		
		if(!mInfo.empty()) {
			ioStreamer.openTag("Info", inIndent);
			for(std::map<std::string,std::string>::const_iterator lIter = mInfo.begin(); lIter != mInfo.end(); ++lIter) {
				ioStreamer.openTag(lIter->first, false);
				ioStreamer.insertStringContent( lIter->second );
				ioStreamer.closeTag();
			}		
			ioStreamer.closeTag();
		}
		if(mBondGraph!=NULL) {
			mBondGraph->write(ioStreamer,false);
		}
		if(mSimplifiedBondGraph!=NULL) {
			ioStreamer.openTag("SimplifiedBondGraph", inIndent);
			mSimplifiedBondGraph->write(ioStreamer,false);
			ioStreamer.closeTag();
		}
		
	}
	else ioStreamer.insertAttribute("valid", "no");
	ioStreamer.closeTag();
	//	Beagle_StackTraceEndM("void LogFitness::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const");
}
Beispiel #19
0
/*!
 *  \brief Write an instruction set into a XML streamer.
 *  \param ioStreamer XML streamer to use to read the instruction set into.
 *  \param inIndent Whether XML output should be indented.
 */
void LinGP::InstructionSet::write(PACC::XML::Streamer& ioStreamer, bool inIndent) const
{
	ioStreamer.openTag("InstructionSet", inIndent);
	for(unsigned int i=0; i<size(); i++) (*this)[i]->write(ioStreamer, inIndent);
	ioStreamer.closeTag();
}