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


Java Chunk类代码示例

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


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

示例1: getDoubleArrayFromDistribution

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Converts the <code>Distribution</code> object to <code>double[]</code> array.
 * @param distribution
 * @param chunk (just for reference)
 * @return <code>double[]</code> array
 */
private double[] getDoubleArrayFromDistribution(Distribution distribution, Chunk chunk) {
	
	List<Double> values = distribution.getValues();
	double[] result = new double[values.size()];
	int i = 0; double sum = 0.0;
	for (Double d : values) {
		result[i++] = d.doubleValue();
		sum += d;
	}
	/* sum != 1.0 */
	// seems that we need to introduce less rigorous check here, because of the floating point imprecision
	// therefore, lower and upper limits are introduced. 3 decimal places should be sufficient...
	if(sum < DIST_SUM_LIMIT_LOW || sum > DIST_SUM_LIMIT_HI) {
		throw new ReasonerException(String.format(
				"Sum of distribution values [raw: " + sum + ", formatted: %f] is not equal to 1.0 for node: '%s'. "
				+ "Check performed within limits: %f - %f", sum, chunk.getId(), DIST_SUM_LIMIT_LOW, DIST_SUM_LIMIT_HI));
	}
	return result;
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:26,代码来源:KPARiskAnalysisTool.java

示例2: getOutputModelSlice

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Retrieves the chunk list for <code>ModelSlice.OUTPUT_DATA</code> or empty list if no chunks.
 * In the context of KPA risk analysis tool, output is represented by RISK nodes, as well as INDICATOR nodes 
 * in the RISK network exclusively (tier 2, i.e. KPA level 3).
 * @return chunk list
 */
private Iterable<Chunk> getOutputModelSlice() {
	
	ArrayList<Chunk> chunks = new ArrayList<>();
	for(String bnId : this.networkMap.keySet()) {
		Network bn = this.networkMap.get(bnId);
		String bnPropVal = getUserPropertyValue(bn.getUserProperties(), BN_TYPE_PROP_NAME);
		if(BN_TYPE_PROP_VALUE_RISK.equals(bnPropVal)) {
			// we only get the output from the RISK network - in the RISK network output 
			// is represented by all RISK nodes, as well as all INDICATOR nodes
			chunks.addAll(getChunksForNodeType(bn, NODE_TYPE_PROP_VALUE_RISK));
			chunks.addAll(getChunksForNodeType(bn, NODE_TYPE_PROP_VALUE_INDICATOR));
			break;
		}
	}
	return chunks;
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:23,代码来源:KPARiskAnalysisTool.java

示例3: getField

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
@Override
	public Field getField(Chunk chunk, FieldType field) {

		// should we check here if the node identified by input chunk actually exists / has value ?
		// the thing is that SMILEException ( a runtime exception ), and this one will be thrown in
		// the case node id (i.e. chunk id) supplied is invalid. It's wrapped in getFieldForChunk().
		// E.G. smile.SMILEException: Invalid node id: VerticesXX
		switch(field) {
		case INPUT_VALUE:
			return getDistributionFieldForChunk(chunk);
		case OUTPUT_VALUE:
			return getDistributionFieldForChunk(chunk);
		case QUESTION:
			// as explained, this should return a 'natural language' question.
			// currently, this is extremely simplified, needs further discussion for forming proper questions
			Field result = new Field(DataType.STRING, 
					String.format("What are the distribuion values for '%s' ?", chunk.getId()));
			return result;
		default:
			return null;
//			throw new ReasonerException("Unsupported field type");
		}
	}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:24,代码来源:KPARiskAnalysisTool.java

示例4: invalidCountOfDistributionLevels

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
@Test
public void invalidCountOfDistributionLevels() {
	
	engine = new KPARiskAnalysisTool();
	engine.loadModel(convertStreamToString(
			KPAUnitTesting.class.getResourceAsStream("resources/valid/Timeliness.xdsl")));
	for (Chunk c : engine.queryModel(ModelSlice.INPUT_DATA)) {
		if ("VAverage_bug_fix_time__days_".equals(c.getId())) {
			Field f = engine.getField(c, FieldType.INPUT_VALUE);
			System.out.println("Read default distribution: " + f.getValue());
			List<Double> values = new ArrayList<Double>();
			values.add(0.42);
			values.add(0.22);
			Distribution distribution = new Distribution();
			distribution.setValues(values);
			f.setValue(distribution);
			this.exception.expect(ReasonerException.class);
			engine.setField(c, FieldType.INPUT_VALUE, f);
			break;
		}
	}
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:23,代码来源:KPAUnitTesting.java

示例5: distributionSumNotEqualTo1

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Test checks whether the exception is thrown for distribution sum > 1.0.
 */
@Test
public void distributionSumNotEqualTo1() {
	
	engine.loadModel(convertStreamToString(KPAUnitTesting.class.getResourceAsStream("resources/valid/Timeliness.xdsl")));
	
	Chunk chunk = new Chunk("VHour__When_the_commit_was_made", "Timeliness");
	Distribution distribution = new Distribution();
	List<Double> values = new ArrayList<>(0);
	values.add(0.5);
	values.add(0.4);
	values.add(0.3);
	distribution.setValues(values);
	Field field = new Field(DataType.DISTRIBUTION, distribution);
	
	this.exception.expect(ReasonerException.class);
	
	this.engine.setField(chunk, FieldType.INPUT_VALUE, field);
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:22,代码来源:KPAUnitTesting.java

示例6: runAnalysis

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
static Map<String, Map<String, Object>> runAnalysis(RiskAnalysisEngine riskAnalysisEngine)
{
    Map<String, Map<String, Object>> result = new HashMap<String, Map<String, Object>>();

    riskAnalysisEngine.runAnalysis(new String[0]);

    Iterable<Chunk> chunks = riskAnalysisEngine.queryModel(ModelSlice.OUTPUT_DATA);
    for (Chunk chunk : chunks) {
        Field field = riskAnalysisEngine.getField(chunk, FieldType.OUTPUT_VALUE);

        Map<String, Object> item = new HashMap<String, Object>();
        Field descriptionField = riskAnalysisEngine.getField(chunk, FieldType.DESCRIPTION);
        if (descriptionField != null) {
            item.put("DESCRIPTION", riskAnalysisEngine.getField(chunk, FieldType.DESCRIPTION).getValue());
        } else {
            item.put("DESCRIPTION", chunk.getId());
        }
        item.put("TYPE", field.getDataType().toString());
        item.put("VALUE", field.getValue());

        result.put(chunk.getId(), item);
    }

    return result;
}
 
开发者ID:rbenjacob,项目名称:riscoss-platform,代码行数:26,代码来源:RemoteRiskAnalyser.java

示例7: runAnalysis

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
static Map<String, Map<String, Object>> runAnalysis(RiskAnalysisEngine riskAnalysisEngine)
{
    Map<String, Map<String, Object>> result = new HashMap<String, Map<String, Object>>();

    riskAnalysisEngine.runAnalysis(new String[0]);

    Iterable<Chunk> chunks = riskAnalysisEngine.queryModel(ModelSlice.OUTPUT_DATA);
    for (Chunk chunk : chunks) {
        Field field = riskAnalysisEngine.getField(chunk, FieldType.OUTPUT_VALUE);

        Map<String, Object> item = new HashMap<String, Object>();
        Field descriptionField = riskAnalysisEngine.getField(chunk, FieldType.DESCRIPTION);
        if (descriptionField != null) {
            item.put("description", descriptionField.getValue());
        }
        Field labelField = riskAnalysisEngine.getField(chunk, FieldType.LABEL);
        if (labelField != null) {
            item.put("label", labelField.getValue());
        }
        item.put("type", field.getDataType().toString());
        item.put("value", field.getValue());

        result.put(chunk.getId(), item);
    }

    return result;
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:28,代码来源:RemoteRiskAnalyser.java

示例8: getChunksForNodeType

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Get chunk list for specific node type in the given BN.
 * @param bn BayesiaN network
 * @param nodeType node type
 * @return
 */
private Collection<Chunk> getChunksForNodeType(Network bn, String nodeType) {
	
	ArrayList<Chunk> chunks = new ArrayList<>();
	for(int hNode : bn.getAllNodes()) {
		String propVal = getUserPropertyValue(
				bn.getNodeUserProperties(hNode), NODE_TYPE_PROP_NAME);
		if(propVal != null && nodeType.toUpperCase().equals(propVal)) {
			Chunk chunk = new Chunk(bn.getNodeId(hNode), bn.getId());
			chunks.add(chunk);
		}
	}
	return chunks;
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:20,代码来源:KPARiskAnalysisTool.java

示例9: getInputModelSlice

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Retrieves the chunk list for <code>ModelSlice.INPUT_DATA</code> or empty list if no chunks.
 * @return chunk list
 */
private Iterable<Chunk> getInputModelSlice() {
	
	ArrayList<Chunk> chunks = new ArrayList<>();
	for(String bnId : this.networkMap.keySet()) {
		Network bn = this.networkMap.get(bnId);	
		// we get input chunks from indicator networks (tier 1), therefore those nodes
		// are marked as such (in KPA terminology: risk drivers)
		// we also need to get input chunks from Risk network (tier 2), therefore those 
		// nodes are also marked as such (in KPA terminology: contextual indicators)
		chunks.addAll(getChunksForNodeType(bn, NODE_TYPE_PROP_VALUE_INPUT));
	}
	return chunks;
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:18,代码来源:KPARiskAnalysisTool.java

示例10: queryModel

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
@Override
	public Iterable<Chunk> queryModel(ModelSlice slice) {
		
//		if(this.networkMap.keySet() == null || this.networkMap.keySet().isEmpty())
//			throw new ReasonerException("No model was loaded");
		switch(slice) {
		case INPUT_DATA:
			return getInputModelSlice();
		case OUTPUT_DATA:
			return getOutputModelSlice();
		default:
			throw new ReasonerException("Unsupported model-slice type");
		}
	}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:15,代码来源:KPARiskAnalysisTool.java

示例11: queryInputBeforeLoad

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
	 * Query before-load, or invalid type
	 */
	@Test
	public void queryInputBeforeLoad() {
		
//		this.exception.expect(ReasonerException.class);
		// should return empty collection (arrayList)
		engine = new KPARiskAnalysisTool();
		Iterable<Chunk> res = engine.queryModel(ModelSlice.INPUT_DATA);
		Assert.assertTrue(res instanceof ArrayList<?> && ((ArrayList<Chunk>)res).isEmpty());
	}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:13,代码来源:KPAUnitTesting.java

示例12: queryOutputBeforeLoad

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
@Test
	public void queryOutputBeforeLoad() {
		
//		this.exception.expect(ReasonerException.class);
		// should return empty collection (arrayList)
		engine = new KPARiskAnalysisTool();
		Iterable<Chunk> res = engine.queryModel(ModelSlice.OUTPUT_DATA);
		Assert.assertTrue(res instanceof ArrayList<?> && ((ArrayList<Chunk>)res).isEmpty());
	}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:10,代码来源:KPAUnitTesting.java

示例13: getQuestion

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Confirm a question is returned (not quite rigorous...)
 */
@Test
public void getQuestion() {
	
	engine = new KPARiskAnalysisTool();
	engine.loadModel(convertStreamToString(
			KPAUnitTesting.class.getResourceAsStream("resources/valid/Timeliness.xdsl")));
	Field f = engine.getField(new Chunk("VCommit_frequency___week", "Timeliness"), FieldType.QUESTION);
	Assert.assertTrue(f.getDataType() == DataType.STRING);
	Assert.assertTrue(f.getValue() != "");
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:14,代码来源:KPAUnitTesting.java

示例14: getFieldOfInvalidType

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
/**
 * Getting / setting fields of invalid type
 */
@Test
public void getFieldOfInvalidType() {
	
	this.exception.expect(ReasonerException.class);
	engine.getField(new Chunk(), FieldType.DESCRIPTION);
	this.exception.expect(ReasonerException.class);
	engine.getField(new Chunk(), FieldType.WEIGHT);		
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:12,代码来源:KPAUnitTesting.java

示例15: setFieldOfInvalidType

import eu.riscoss.reasoner.Chunk; //导入依赖的package包/类
@Test
public void setFieldOfInvalidType() {
	
	this.exception.expect(ReasonerException.class);
	Field field = new Field(DataType.EVIDENCE, null);
	engine.setField(new Chunk(), FieldType.INPUT_VALUE, field);	
}
 
开发者ID:RISCOSS,项目名称:riscoss-analyser,代码行数:8,代码来源:KPAUnitTesting.java


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