当前位置: 首页>>代码示例>>Java>>正文


Java Configuration类代码示例

本文整理汇总了Java中org.deri.iris.Configuration的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Configuration类属于org.deri.iris包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.deri.iris.Configuration; //导入依赖的package包/类
public static void execute( String program, Configuration configuration )
{
	Thread t = new Thread( new ExecutionTask( program, configuration ), "Evaluation task" );

	t.setPriority( Thread.MIN_PRIORITY );
	t.start();
	
	try
	{
		t.join( configuration.evaluationTimeoutMilliseconds );
	}
	catch( InterruptedException e )
	{
	}
	
	if ( t.isAlive() )
	{
		t.stop();
		System.out.println( "Timeout exceeded: " + configuration.evaluationTimeoutMilliseconds + "ms" );
	}
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:22,代码来源:Demo.java

示例2: evaluateRules

import org.deri.iris.Configuration; //导入依赖的package包/类
public void evaluateRules( List<ICompiledRule> rules, IFacts facts, Configuration configuration ) throws EvaluationException
{
	boolean cont = true;
	while( cont )
	{
		cont = false;
		
		// For each rule in the collection (stratum)
		for (final ICompiledRule rule : rules )
		{
			IRelation delta = rule.evaluate();

			if( delta != null && delta.size() > 0 )
			{
				IPredicate predicate = rule.headPredicate();
				if( facts.get( predicate ).addAll( delta ) )
					cont = true;
			}
		}
	}
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:22,代码来源:NaiveEvaluator.java

示例3: removeDeducedTuples

import org.deri.iris.Configuration; //导入依赖的package包/类
/**
 * Helper to remove tuples from a delta that are already known or computed.
 * @param predicate The predicate identifying the relation.
 * @param delta The deltas produced by the last round of evaluation.
 * @param programFacts The already known or computed facts.
 * @return
 */
private static IRelation removeDeducedTuples( IPredicate predicate, IRelation delta, IRelation programFacts, Configuration configuration )
{
	// If there is nothing to take away from, or just nothing to take-away...
	if( delta.size() == 0 || programFacts.size() == 0 )
		return delta;
	
	IRelation result = configuration.relationFactory.createRelation();
	
	for( int t = 0; t < delta.size(); ++ t )
	{
		ITuple tuple = delta.get( t );
		if( ! programFacts.contains( tuple ) )
			result.add( tuple );
	}
	
	return result;
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:25,代码来源:SemiNaiveEvaluator.java

示例4: HeadSubstituter

import org.deri.iris.Configuration; //导入依赖的package包/类
/**
 * Constructor.
 * @param variables The variables from the rule body.
 * @param headTuple The tuple from the rule head.
 * @throws EvaluationException If unbound variables occur.
 */
public HeadSubstituter( List<IVariable> variables, ITuple headTuple, Configuration configuration ) throws EvaluationException
{
	assert variables != null;
	assert headTuple != null;
	assert configuration != null;
	
	mConfiguration = configuration;
	
	mHeadTuple = headTuple;

	// Work out the indices of variables in substitution order
	List<IVariable> variablesToSubstitute = TermMatchingAndSubstitution.getVariables( mHeadTuple, false );
	mIndices = new int[ variablesToSubstitute.size() ];
	
	int i = 0;
	for( IVariable variable : variablesToSubstitute )
	{
		int index = variables.indexOf( variable );
		if( index < 0 )
			throw new RuleUnsafeException( "Unbound variable in rule head: " + variable );
		mIndices[ i++ ] = index;
	}
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:30,代码来源:HeadSubstituter.java

示例5: FirstSubgoal

import org.deri.iris.Configuration; //导入依赖的package包/类
/**
 * Constructor.
 * @param predicate The predicate for this literal.
 * @param relation The relation for this literal.
 * @param viewCriteria The tuple from the sub-goal in the rule.
 * @param equivalentTerms The equivalent terms.
 */
public FirstSubgoal( IPredicate predicate, IRelation relation, ITuple viewCriteria, 
		IEquivalentTerms equivalentTerms, Configuration configuration )
{
	assert predicate != null;
	assert relation != null;
	assert viewCriteria != null;
	assert configuration != null;
	
	mConfiguration = configuration;
	
	mView = new View( relation, viewCriteria, equivalentTerms, mConfiguration.relationFactory );

	mPredicate = predicate;
	mViewCriteria = viewCriteria;
	mOutputVariables = mView.variables();
	mEquivalentTerms = equivalentTerms;
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:25,代码来源:FirstSubgoal.java

示例6: testDivideByZeroStop

import org.deri.iris.Configuration; //导入依赖的package包/类
public void testDivideByZeroStop() throws Exception
{
	String program =
		"a(0)." +
		"a(1)." +
		"b(0)." +
		"d(?Z) :- a(?X), b(?Y), ?X / ?Y = ?Z." +
		"?-d(?X).";
	
	try
	{
		Configuration configuration = KnowledgeBaseFactory.getDefaultConfiguration();
		configuration.evaluationDivideByZeroBehaviour = Configuration.DivideByZeroBehaviour.STOP;
		
		Helper.executeAndCheckResults( program, "", configuration, "Divide by zero should stop" );

		fail( "Should have thrown an EvaluationException" );
	}
	catch( EvaluationException e )
	{
		
	}
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:24,代码来源:ConfigurationTest.java

示例7: executeAndCheckResults

import org.deri.iris.Configuration; //导入依赖的package包/类
public static void executeAndCheckResults( String program, String expected, Configuration configuration, String evaluationName ) throws Exception
{
	Parser parser = new Parser();
	parser.parse( program );
	List<IQuery> queries = parser.getQueries();

	assert queries.size() <= 1;
	
	IQuery query = null;
	if( queries.size() == 1 )
		query = queries.get( 0 );
	
	// Instantiate the knowledge-base
	IKnowledgeBase kb = KnowledgeBaseFactory.createKnowledgeBase( parser.getFacts(), parser.getRules(), configuration );
	
	// Execute the query
	if( query != null )
		kb.execute( query );
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:20,代码来源:MagicSetsTest.java

示例8: setUp

import org.deri.iris.Configuration; //导入依赖的package包/类
protected void setUp() throws Exception {
	// Set up the knowledge base consisting of a set of facts and a set of
	// rules.

	// Create the default configuration.
	defaultConfiguration = new Configuration();

	// Create the facts.
	facts = createFacts();

	// Create the rules.
	rules = createRules();

	// Create the queries.
	queries = createQueries();
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:17,代码来源:EvaluationTest.java

示例9: testNoOptimisers

import org.deri.iris.Configuration; //导入依赖的package包/类
public void testNoOptimisers() throws Exception{
	Configuration configuration = new Configuration();
	
	StrategyFactory factory = new StrategyFactory();
	
	configuration.programOptmimisers.clear();
	configuration.evaluationStrategyFactory = factory;

	IFacts facts = createFacts();
	List<IRule> rules = createRules();
	IQuery query = createQuery();
	
	OptimisedProgramStrategyAdaptor adaptor = new OptimisedProgramStrategyAdaptor( facts, rules, configuration );
	
	adaptor.evaluateQuery( query, null );
	
	assertTrue( facts == factory.mStrategy.mGivenFacts );	// Same object
	assertTrue( rules == factory.mStrategy.mGivenRules );	// Same object
	assertTrue( query == factory.mStrategy.mGivenQuery );	// Same object
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:21,代码来源:OptimisedProgramStrategyAdaptorTest.java

示例10: testHasInputAllBound

import org.deri.iris.Configuration; //导入依赖的package包/类
public void testHasInputAllBound() throws Exception
{
	Configuration configuration = new Configuration();
	IRelation inputRelation = configuration.relationFactory.createRelation();
	
	inputRelation.add( Helper.createTuple( 1, 2, 3 ) );
	inputRelation.add( Helper.createTuple( 4, 4, 8 ) );
	inputRelation.add( Helper.createTuple( 1, 2, 4 ) );
	inputRelation.add( Helper.createTuple( 1, 3, 3 ) );
	
	ITuple criteria = Helper.createTuple( "X", "Y", "Z" );
	View view = new View( inputRelation, criteria, configuration.relationFactory );
	
	IBuiltinAtom builtinPredicate = new AddBuiltin( criteria.toArray( new ITerm[0]) );
	
	Builtin builtin = new Builtin( view.variables(), builtinPredicate, true, 
			new IgnoreTermEquivalence(), configuration );
	
	IRelation result = builtin.process( view );
	
	assertEquals( 2, result.size() );
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:23,代码来源:BuiltinTest.java

示例11: testTooManyUnbound

import org.deri.iris.Configuration; //导入依赖的package包/类
public void testTooManyUnbound()
{
	Configuration configuration = new Configuration();
	IRelation inputRelation = configuration.relationFactory.createRelation();
	ITuple criteria = Helper.createTuple( "X" );
	View view = new View( inputRelation, criteria, configuration.relationFactory );
	
	ITuple builtinTuple = Helper.createTuple( "X", "Y", "Z" );
	IBuiltinAtom builtinPredicate = new AddBuiltin( builtinTuple.toArray( new ITerm[0]) );
	
	try
	{
		new Builtin( view.variables(), builtinPredicate, true, 
				new IgnoreTermEquivalence(), configuration );
		fail( "Builtin should have thrown an exception" );
	}
	catch( Exception e ) // TODO Choose the proper exception type later
	{
	}
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:21,代码来源:BuiltinTest.java

示例12: testNoInput

import org.deri.iris.Configuration; //导入依赖的package包/类
public void testNoInput() throws Exception
{
	Configuration configuration = new Configuration();
	ITuple builtinTuple = Helper.createTuple( 3, 4, "X" );
	IBuiltinAtom builtinPredicate = new AddBuiltin( builtinTuple.toArray( new ITerm[0]) );
	
	Builtin builtin = new Builtin( new ArrayList<IVariable>(), builtinPredicate, true, 
			new IgnoreTermEquivalence(), configuration );
	
	IRelation output = builtin.process( mRelationWithOneZeroLengthTuple );
	
	assertEquals( Helper.createTerm( "X" ), builtin.getOutputVariables().get( 0 ) );

	assertEquals( 1, output.size() );
	assertEquals( Helper.createTerm( 7 ), output.get( 0 ).get( 0 ) );
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:17,代码来源:BuiltinTest.java

示例13: testSimpleSource

import org.deri.iris.Configuration; //导入依赖的package包/类
/**
 * Tests the handling of a simple data source.
 * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1846034&group_id=167309&atid=842437">maintenance #1846034: Create a interface to plug in external datasources</a>
 */
public void testSimpleSource() throws Exception {
	final String prog = "?- a(?X).";

	final Parser p = new Parser();
	p.parse(prog);

	final IQuery q = p.getQueries().iterator().next();

	// setting up the configuration
	final Configuration conf = KnowledgeBaseFactory.getDefaultConfiguration();
	conf.externalDataSources.add(new SimpleSource());

	// setting up the knowledge base
	IKnowledgeBase kb = KnowledgeBaseFactory.createKnowledgeBase(null, null, conf);

	// executing the query
	final IRelation result = kb.execute(q);

	// asserting the result
	assertEquals("There must be exactly one fact", 1, result.size());
	assertEquals("Couldn't find the correct fact", T_A, result.get(0));
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:27,代码来源:DataSourceTest.java

示例14: OptimisedProgramStrategyAdaptor

import org.deri.iris.Configuration; //导入依赖的package包/类
/**
 * Constructor.
 * @param facts The original program's facts (which will not get modified).
 * @param rules The original program's rules.
 * @param configuration The knowledge-base configuration object.
 */
public OptimisedProgramStrategyAdaptor( IFacts facts, List<IRule> rules, Configuration configuration )
{
	mFacts = facts;
	mRules = rules;
	mConfiguration = configuration;
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:13,代码来源:OptimisedProgramStrategyAdaptor.java

示例15: ProgramDoubler

import org.deri.iris.Configuration; //导入依赖的package包/类
/**
 * Constructor.
 * @param rules The rules from the original program.
 * @param facts The facts from the original program.
 * @param configuration The configuration object for the knowledge base.
 */
public ProgramDoubler( List<IRule> rules, IFacts facts, Configuration configuration )
{
	mOriginalRules = rules;
	mOriginalFacts = facts;
	mConfiguration = configuration;
	
	calculateStartingRuleBase();
	calculateNegativeRuleBase();
	calculatePositiveRuleBase();
}
 
开发者ID:NICTA,项目名称:iris-reasoner,代码行数:17,代码来源:ProgramDoubler.java


注:本文中的org.deri.iris.Configuration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。