Ejemplo n.º 1
0
//-------------------------------------------------------------------------------
// General dumping methods -- dumping relevant parts of ontology
//-------------------------------------------------------------------------------
void TBox :: dump ( dumpInterface* dump ) const
{
	dump->prologue();

	// dump all (relevant) roles
	dumpAllRoles(dump);

	// dump all (relevant) concepts
	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		if ( isRelevant(*pc) )
			dumpConcept( dump, *pc );

	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		if ( isRelevant(*pi) )
			dumpConcept( dump, *pi );

	// dump GCIs
	if ( getTG() != bpTOP )
	{
		dump->startAx (diImpliesC);
		dump->dumpTop();
		dump->contAx (diImpliesC);
		dumpExpression ( dump, getTG() );
		dump->finishAx (diImpliesC);
	}

	dump->epilogue();
}
Ejemplo n.º 2
0
void test_sorted3_async(ExPolicy p, IteratorTag)
{
    static_assert(
        hpx::parallel::is_execution_policy<ExPolicy>::value,
        "hpx::parallel::is_execution_policy<ExPolicy>::value");

    typedef std::vector<std::size_t>::iterator base_iterator;
    typedef test::test_iterator<base_iterator, IteratorTag> iterator;

    std::vector<std::size_t> c_beg(10007);
    std::vector<std::size_t> c_end(10007);
    //Fill with sorted values from 0 to 10006
    std::iota(boost::begin(c_beg), boost::end(c_beg), 0);
    std::iota(boost::begin(c_end), boost::end(c_end), 0);
    //add unsorted element to c_beg, c_end at the beginning, end respectively
    c_beg[0] = 20000;
    c_end[c_end.size()-1] = 0;

    hpx::future<bool> f1 = hpx::parallel::is_sorted(p,
        iterator(boost::begin(c_beg)), iterator(boost::end(c_beg)));
    hpx::future<bool> f2 = hpx::parallel::is_sorted(p,
        iterator(boost::begin(c_end)), iterator(boost::end(c_end)));
    f1.wait();
    HPX_TEST(!f1.get());
    f2.wait();
    HPX_TEST(!f2.get());
}
Ejemplo n.º 3
0
 std::pair<ParentsIterator, ParentsIterator>
 parents(VertexID v, const TaskGraph &tg)
{
  InEdgeIterator e,e_end;
  tie(e,e_end) = in_edges(v,tg);
  ParentsIterator c(e,&tg),c_end(e_end,&tg);
  return make_pair(c,c_end);
}
Ejemplo n.º 4
0
std::pair<ChildrenIterator, ChildrenIterator>
children(VertexID v, const TaskGraph &tg)
{
  boost::graph_traits<TaskGraph>::out_edge_iterator e,e_end;
  // OutEdgeIterator e,e_end;
  tie(e,e_end) = out_edges(v,tg);
  ChildrenIterator c(e,&tg),c_end(e_end,&tg);
  return make_pair(c,c_end);
}
Ejemplo n.º 5
0
void test_sorted3(ExPolicy policy, IteratorTag)
{
    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);

    typedef std::vector<std::size_t>::iterator base_iterator;
    typedef test::test_iterator<base_iterator, IteratorTag> iterator;

    std::vector<std::size_t> c_beg(10007);
    std::vector<std::size_t> c_end(10007);
    //Fill with sorted values from 0 to 10006
    std::iota(boost::begin(c_beg), boost::end(c_beg), 0);
    std::iota(boost::begin(c_end), boost::end(c_end), 0);
    //add unsorted element to c_beg, c_end at the beginning, end respectively
    c_beg[0] = 20000;
    c_end[c_end.size()-1] = 0;

    bool is_ordered1 = hpx::parallel::is_sorted(policy,
        iterator(boost::begin(c_beg)), iterator(boost::end(c_beg)));
    bool is_ordered2 = hpx::parallel::is_sorted(policy,
        iterator(boost::begin(c_end)), iterator(boost::end(c_end)));

    HPX_TEST(!is_ordered1);
    HPX_TEST(!is_ordered2);
}
Ejemplo n.º 6
0
void TBox :: buildDAG ( void )
{
	nNominalReferences = 0;

	// init concept indexing
	nC = 1;	// start with 1 to make index 0 an indicator of "not processed"
	ConceptMap.push_back(NULL);

	// make fresh concept and datatype
	concept2dag(pTemp);
	DLTree* freshDT = DTCenter.getFreshDataType();
	addDataExprToHeap ( static_cast<TDataEntry*>(freshDT->Element().getNE()) );
	deleteTree(freshDT);

	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		concept2dag(*pc);
	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		concept2dag(*pi);

	// init heads of simple rules
	for ( TSimpleRules::iterator q = SimpleRules.begin(), q_end = SimpleRules.end(); q < q_end; ++q )
		(*q)->bpHead = tree2dag((*q)->tHead);

	// builds Roles range and domain
	initRangeDomain(ORM);
	initRangeDomain(DRM);

	// build all splits
	for ( TSplitVars::iterator s = getSplits()->begin(), s_end = getSplits()->end(); s != s_end; ++s )
		split2dag(*s);

	RoleMaster::iterator p, p_end;

	// build all GCIs
	DLTree* GCI = Axioms.getGCI();

	// add special domains to the GCIs
	if ( likely(useSpecialDomains) )
		for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
			if ( !(*p)->isSynonym() && (*p)->hasSpecialDomain() )
				GCI = createSNFAnd ( GCI, clone((*p)->getTSpecialDomain()) );

	// take chains that lead to Bot role into account
	if ( !ORM.getBotRole()->isSimple() )
		GCI = createSNFAnd ( GCI,
				new DLTree ( TLexeme(FORALL), createRole(ORM.getBotRole()), createBottom() ) );

	T_G = tree2dag(GCI);
	deleteTree(GCI);

	// mark GCI flags
	GCIs.setGCI(T_G != bpTOP);
	GCIs.setReflexive(ORM.hasReflexiveRoles());

	// builds functional labels for roles
	for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );
	for ( p = DRM.begin(), p_end = DRM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );

	// check the type of the ontology
	if ( nNominalReferences > 0 )
	{
		unsigned int nInd = i_end() - i_begin();
		if ( nInd > 100 && nNominalReferences > nInd )
			isLikeWINE = true;
	}

	// here DAG is complete; set its final size
	DLHeap.setFinalSize();
}
Ejemplo n.º 7
0
void TBox :: gatherRelevanceInfo ( void )
{
	nRelevantCCalls = 0;
	nRelevantBCalls = 0;

	// gather GCIs features
	curFeature = &GCIFeatures;
	markGCIsRelevant();
	clearRelevanceInfo();
	KBFeatures |= GCIFeatures;

	// fills in nominal cloud relevance info
	NCFeatures = GCIFeatures;

	// set up relevance info
	for ( i_iterator pi = i_begin(); pi != i_end(); ++pi )
	{
		setConceptRelevant(*pi);
		NCFeatures |= (*pi)->posFeatures;
	}

	// correct NC inverse role information
	if ( NCFeatures.hasSomeAll() && !RelatedI.empty() )
		NCFeatures.setInverseRoles();

	for ( c_iterator pc = c_begin(); pc != c_end(); ++pc )
		setConceptRelevant(*pc);
	long cSize = ( c_end() - c_begin() ) + ( i_end() - i_begin() );
	size_t bSize = DLHeap.size()-2;

	curFeature = nullptr;

	float cRatio, bRatio = 0, logCSize = 1, logBSize = 1, sqCSize = 1, sqBSize = 1;
	if ( cSize > 10 )
	{
		cRatio = ((float)nRelevantCCalls)/cSize;
		sqCSize = sqrtf((float)cSize);
		if ( cSize > 1 )
			logCSize = logf((float)cSize);
	}
	if ( bSize > 20 )
	{
		bRatio = ((float)nRelevantBCalls)/bSize;
		sqBSize = sqrtf((float)bSize);
		if ( bSize > 1 )
			logBSize = logf((float)bSize);
	}

	if (0)	// relevance stat
	{
	if ( LLM.isWritable(llAlways) && cSize > 10 )
		LL << "There were made " << nRelevantCCalls << " relevance C calls for "
		   << cSize << " concepts\nRC ratio=" << cRatio << ", ratio/logSize="
		   << cRatio/logCSize << ", ratio/sqSize=" << cRatio/sqCSize << ", ratio/size="
		   << cRatio/cSize<< "\n";
	if ( LLM.isWritable(llAlways) && bSize > 20 )
		LL << "There were made " << nRelevantBCalls << " relevance B calls for "
		   << bSize << " nodes\nRB ratio=" << bRatio << ", ratio/logSize="
		   << bRatio/logBSize << ", ratio/sqSize=" << bRatio/sqBSize << ", ratio/size="
		   << bRatio/bSize << "\n";
	}

	// set up GALEN-like flag; based on r/n^{3/2}, add r/n^2<1
	isLikeGALEN = (bRatio > sqBSize*20) && (bRatio < bSize);

	// switch off sorted reasoning iff top role appears
	if ( KBFeatures.hasTopRole() )
		useSortedReasoning = false;
}