use of edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator in project AGREE by loonwerks.
the class Main method testReal.
private static void testReal() throws IOException {
System.out.println("=============Real Test=============");
final Evaluator baseEvaluator = createEvaluator(INPUT_DIRECTORY + "symb_test_real.lus");
final Evaluator evaluator = new Evaluator(baseEvaluator, Arrays.asList(new BinaryExpr(new IdExpr("__SIM_PE___ASSUME0"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("__SIM_PE___ASSUME1"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("__SIM_PE__TOP__ss__TILDE__0__DOT____GUARANTEE0"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("__SIM_PE__TOP__ss__TILDE__0__DOT____GUARANTEE1"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("in1"), BinaryOp.EQUAL, new RealExpr(BigDecimal.valueOf(60))), new BinaryExpr(new IdExpr("in2"), BinaryOp.EQUAL, new RealExpr(BigDecimal.valueOf(10)))));
testValue("in1", evaluator, new RealValue(BigFraction.valueOf(BigDecimal.valueOf(60))));
testValue("in2", evaluator, new RealValue(BigFraction.valueOf(BigDecimal.valueOf(10))));
testValue("out1", evaluator, new RealValue(BigFraction.valueOf(BigDecimal.valueOf(30))));
testValue("out2", evaluator, new RealValue(BigFraction.valueOf(BigDecimal.valueOf(20))));
}
use of edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator 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.eval.Evaluator in project AGREE by loonwerks.
the class Main method testBoolean.
private static void testBoolean() throws IOException {
System.out.println("=============Boolean Test=============");
final Evaluator baseEvaluator = createEvaluator(INPUT_DIRECTORY + "symb_test_bool.lus");
final Evaluator evaluator = new Evaluator(baseEvaluator, Arrays.asList(new BinaryExpr(new IdExpr("__SIM_PE__TOP__ss__TILDE__0__DOT____GUARANTEE0"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("__SIM_PE__TOP__ss__TILDE__0__DOT____GUARANTEE1"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("in1"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("in2"), BinaryOp.EQUAL, new BoolExpr(true))));
testValue("in1", evaluator, BooleanValue.TRUE);
testValue("in2", evaluator, BooleanValue.TRUE);
testValue("out1", evaluator, BooleanValue.TRUE);
testValue("out2", evaluator, BooleanValue.TRUE);
}
use of edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator in project AGREE by loonwerks.
the class Main method testInteger.
private static void testInteger() throws IOException {
System.out.println("=============Integer Test=============");
final Evaluator baseEvaluator = createEvaluator(INPUT_DIRECTORY + "symb_test_int.lus");
final Evaluator evaluator = new Evaluator(baseEvaluator, Arrays.asList(new BinaryExpr(new IdExpr("in1"), BinaryOp.EQUAL, new IntExpr(BigInteger.valueOf(-10))), new BinaryExpr(new IdExpr("in2"), BinaryOp.EQUAL, new IntExpr(BigInteger.valueOf(10)))));
testValue("in1", evaluator, new IntegerValue(BigInteger.valueOf(-10)));
testValue("in2", evaluator, new IntegerValue(BigInteger.valueOf(10)));
testValue("out1", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("out2", evaluator, new IntegerValue(BigInteger.valueOf(-15)));
testValue("ss__a1[0]", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("ss__a1[1]", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("ss__a1[2]", evaluator, new IntegerValue(BigInteger.valueOf(-20)));
testValue("ss__a2[0]", evaluator, new IntegerValue(BigInteger.valueOf(10)));
testValue("ss__a2[1]", evaluator, new IntegerValue(BigInteger.valueOf(20)));
testValue("ss__a2[2]", evaluator, new IntegerValue(BigInteger.valueOf(30)));
testValue("ss__a3[0]", evaluator, new IntegerValue(BigInteger.valueOf(42)));
testValue("ss__a3[1]", evaluator, new IntegerValue(BigInteger.valueOf(88)));
testValue("ss__a3[2]", evaluator, new IntegerValue(BigInteger.valueOf(-20)));
testValue("ss__r1.x", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("ss__r1.y", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("ss__r1.z", evaluator, new IntegerValue(BigInteger.valueOf(42)));
testValue("ss__r2.x", evaluator, new IntegerValue(BigInteger.valueOf(10)));
testValue("ss__r2.y", evaluator, new IntegerValue(BigInteger.valueOf(20)));
testValue("ss__r2.z", evaluator, new IntegerValue(BigInteger.valueOf(30)));
testValue("ss__r3.x", evaluator, new IntegerValue(BigInteger.valueOf(42)));
testValue("ss__r3.y", evaluator, new IntegerValue(BigInteger.valueOf(88)));
testValue("ss__r3.z", evaluator, new IntegerValue(BigInteger.valueOf(42)));
testValue("ss__ra1[0].x", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("ss__ra1[0].y", evaluator, new IntegerValue(BigInteger.valueOf(-5)));
testValue("ss__ra1[0].z", evaluator, new IntegerValue(BigInteger.valueOf(42)));
testValue("ss__ra1[1].x", evaluator, new IntegerValue(BigInteger.valueOf(10)));
testValue("ss__ra1[1].y", evaluator, new IntegerValue(BigInteger.valueOf(20)));
testValue("ss__ra1[1].z", evaluator, new IntegerValue(BigInteger.valueOf(30)));
}
use of edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator in project AGREE by loonwerks.
the class Main method createEvaluator.
private static Evaluator createEvaluator(final String lustreFilepath) throws IOException {
final LustreLexer lexer = new LustreLexer(new ANTLRFileStream(lustreFilepath));
final CommonTokenStream tokens = new CommonTokenStream(lexer);
final LustreParser parser = new LustreParser(tokens);
final Program program = new LustreToAstVisitor().program(parser.program());
final Evaluator evaluator = new Evaluator(program);
return new Evaluator(evaluator, Collections.singleton(new IdExpr(CreateSimulationGuarantee.SIMULATION_ASSERTIONS_ID)));
}
Aggregations