use of edu.uah.rsesc.aadlsimulator.agree.sim.SimulationFrameResults in project AGREE by loonwerks.
the class AGREESimulationState method createEvaluator.
private Evaluator createEvaluator(final Collection<Expr> constraints, final Set<SimulationProperty> disabledProperties) {
try {
final SimulationFrameResults lastFrameResults = frameInfos.size() == 0 ? null : frameInfos.get(frameInfos.size() - 1).getFrameResults();
final List<Expr> assertions = new ArrayList<Expr>();
FrameAssertionHelper.addNextFrameAssertions(simulationProgram, lastFrameResults, assertions);
assertions.addAll(constraints);
// Add assertions for property enablement variables
for (final SimulationProperty simProp : simulationProgram.getSimulationProperties()) {
if (simProp.getEnablementVariableId() != null) {
assertions.add(new BinaryExpr(new IdExpr(simProp.getEnablementVariableId()), BinaryOp.EQUAL, new BoolExpr(disabledProperties.contains(simProp) ? false : true)));
}
}
// Create the new evaluator
return new Evaluator(baseEvaluator, assertions);
} catch (EvaluationException ex) {
return null;
}
}
use of edu.uah.rsesc.aadlsimulator.agree.sim.SimulationFrameResults in project AGREE by loonwerks.
the class AGREESimulationState method getPropertyStatus.
@Override
public AGREEPropertyStatus getPropertyStatus(final Object property) {
if (frameInfos.size() == 0) {
return AGREEPropertyStatus.INITIAL_STEP;
}
// Handle care where counterexample is not returned. Simulation is halted.
final SimulationFrameResults frameResults = frameInfos.get(frameInfos.size() - 1).getFrameResults();
if (frameResults.getDisabledProperties().contains(property)) {
return AGREEPropertyStatus.DISABLED;
}
if (frameResults.hasCounterexample()) {
for (final String propLustreId : asProperty(property).getLustreIds()) {
final Value value = frameResults.getValue(propLustreId);
if (!(value instanceof BooleanValue)) {
throw new RuntimeException("Value is not a boolean value");
}
final boolean propertyValue = ((BooleanValue) value).value;
if (!propertyValue) {
return AGREEPropertyStatus.UNSATISFIED_WARNING;
}
}
return AGREEPropertyStatus.SATISFIED;
} else {
if (frameResults.hasInductiveValidityCore()) {
for (final String propLustreId : asProperty(property).getLustreIds()) {
if (frameResults.isInInductiveValidityCore(propLustreId)) {
return AGREEPropertyStatus.UNSATISFIED_ERROR;
}
}
return AGREEPropertyStatus.HALTED_NOT_IN_SET_OF_SUPPORT;
} else {
return AGREEPropertyStatus.HALTED_SET_OF_SUPPORT_UNAVAILABLE;
}
}
}
Aggregations