Search in sources :

Example 1 with Evaluator

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))));
}
Also used : RealValue(jkind.lustre.values.RealValue) BoolExpr(jkind.lustre.BoolExpr) IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) Evaluator(edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator) RealExpr(jkind.lustre.RealExpr)

Example 2 with Evaluator

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;
    }
}
Also used : BoolExpr(jkind.lustre.BoolExpr) SimulationFrameResults(edu.uah.rsesc.aadlsimulator.agree.sim.SimulationFrameResults) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) Expr(jkind.lustre.Expr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayList(java.util.ArrayList) SimulationProperty(edu.uah.rsesc.aadlsimulator.agree.SimulationProperty) EvaluationException(edu.uah.rsesc.aadlsimulator.agree.eval.EvaluationException) Evaluator(edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator)

Example 3 with Evaluator

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);
}
Also used : BoolExpr(jkind.lustre.BoolExpr) IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) Evaluator(edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator)

Example 4 with Evaluator

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)));
}
Also used : IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) IntegerValue(jkind.lustre.values.IntegerValue) IntExpr(jkind.lustre.IntExpr) Evaluator(edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator)

Example 5 with Evaluator

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)));
}
Also used : LustreToAstVisitor(jkind.lustre.parsing.LustreToAstVisitor) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) LustreParser(jkind.lustre.parsing.LustreParser) ANTLRFileStream(org.antlr.v4.runtime.ANTLRFileStream) Program(jkind.lustre.Program) IdExpr(jkind.lustre.IdExpr) LustreLexer(jkind.lustre.parsing.LustreLexer) Evaluator(edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator)

Aggregations

Evaluator (edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator)5 IdExpr (jkind.lustre.IdExpr)5 BinaryExpr (jkind.lustre.BinaryExpr)4 BoolExpr (jkind.lustre.BoolExpr)3 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)1 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)1 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)1 SimulationProperty (edu.uah.rsesc.aadlsimulator.agree.SimulationProperty)1 EvaluationException (edu.uah.rsesc.aadlsimulator.agree.eval.EvaluationException)1 SimulationFrameResults (edu.uah.rsesc.aadlsimulator.agree.sim.SimulationFrameResults)1 ArrayList (java.util.ArrayList)1 Expr (jkind.lustre.Expr)1 IntExpr (jkind.lustre.IntExpr)1 Program (jkind.lustre.Program)1 RealExpr (jkind.lustre.RealExpr)1 LustreLexer (jkind.lustre.parsing.LustreLexer)1 LustreParser (jkind.lustre.parsing.LustreParser)1 LustreToAstVisitor (jkind.lustre.parsing.LustreToAstVisitor)1 IntegerValue (jkind.lustre.values.IntegerValue)1 RealValue (jkind.lustre.values.RealValue)1