コード例 #1
0
ファイル: ReasonerNom.cpp プロジェクト: dgu123/factplusplus
bool
NominalReasoner :: consistentNominalCloud ( void )
{
	if ( LLM.isWritable(llBegSat) )
		LL << "\n--------------------------------------------\n"
			  "Checking consistency of an ontology with individuals:";
	if ( LLM.isWritable(llGTA) )
		LL << "\n";

	bool result = false;

	// reserve the root for the forthcoming reasoning
	if ( initNewNode ( CGraph.getRoot(), DepSet(), bpTOP ) ||
		 initNominalCloud() )	// clash during initialisation
		result = false;
	else	// perform a normal reasoning
		result = runSat();

	if ( result && noBranchingOps() )
	{	// all nominal cloud is classified w/o branching -- make a barrier
		if ( LLM.isWritable(llSRState) )
			LL << "InitNominalReasoner[";
		curNode = NULL;
		createBCBarrier();
		save();
		nonDetShift = 1;	// the barrier doesn't introduce branching itself
		if ( LLM.isWritable(llSRState) )
			LL << "]";
	}

	if ( LLM.isWritable(llSatResult) )
		LL << "\nThe ontology is " << (result ? "consistent" : "INCONSISTENT");

	if ( !result )
		return false;

	// ABox is consistent -> create cache for every nominal in KB
	for ( SingletonVector::iterator p = Nominals.begin(); p != Nominals.end(); ++p )
		updateClassifiedSingleton(*p);

	return true;
}
コード例 #2
0
//=========================================================
bool TesterManager::resolveDeps(std::vector<std::string>& strsDepsToRunFirst) const
{
	strsDepsToRunFirst.clear();
	if (m_MTC.empty()) {
		return true;
	}
	std::map<std::string, DepSet> fdsc;
	DepSet dsOut, dsHasDependants;
	unsigned long ulGFDS = 0;
	for (MapTesterClasses::const_iterator mtcit = m_MTC.begin(); mtcit != m_MTC.end(); ++mtcit) {
		const std::string& strClName = mtcit->first;
		if (strClName.empty()) {
			DBG_ERR("Manager '%s', empty class name", m_strName.c_str());
			continue;
		}
		const TesterClass* pTC = mtcit->second;
		if (nullptr == pTC) {
			DBG_ERR("Manager '%s', class '%s': nullptr TesterClass pointer", m_strName.c_str(), strClName.c_str());
			continue;
		}
		DepSet ds;
		ulGFDS |= getFullDepSet(strClName, ds, DepSet(), &fdsc);
		dsOut.insert(ds.begin(), ds.end());
	}
	DepSet::const_iterator dscit = dsOut.begin();
	for (; dscit != dsOut.end(); ++dscit) {
		const std::string& strName = *dscit;
		std::map<std::string, DepSet>::const_iterator fdscit = fdsc.find(strName);
		if (fdsc.end() != fdscit) {
			dsHasDependants.insert(fdscit->second.begin(), fdscit->second.end());
		}
	}
	dscit = dsHasDependants.begin();
	for (; dscit != dsHasDependants.end(); ++dscit) {
		strsDepsToRunFirst.push_back(*dscit);
	}
	//std::sort(strsDepsToRunFirst.begin(), strsDepsToRunFirst.end(), FullDepSetCompare(fdsc));
	sortByDeps(strsDepsToRunFirst, fdsc);
	return (0 == (GFDS_Looped_Deps & ulGFDS));
}