Search in sources :

Example 1 with SimulationFrameResults

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;
    }
}
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 2 with SimulationFrameResults

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;
        }
    }
}
Also used : SimulationFrameResults(edu.uah.rsesc.aadlsimulator.agree.sim.SimulationFrameResults) BooleanValue(jkind.lustre.values.BooleanValue) TupleValue(jkind.lustre.values.TupleValue) IntegerValue(jkind.lustre.values.IntegerValue) BooleanValue(jkind.lustre.values.BooleanValue) RealValue(jkind.lustre.values.RealValue) RecordValue(jkind.lustre.values.RecordValue) Value(jkind.lustre.values.Value) EnumValue(jkind.lustre.values.EnumValue) ArrayValue(jkind.lustre.values.ArrayValue)

Aggregations

SimulationFrameResults (edu.uah.rsesc.aadlsimulator.agree.sim.SimulationFrameResults)2 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 Evaluator (edu.uah.rsesc.aadlsimulator.agree.eval.Evaluator)1 ArrayList (java.util.ArrayList)1 BinaryExpr (jkind.lustre.BinaryExpr)1 BoolExpr (jkind.lustre.BoolExpr)1 Expr (jkind.lustre.Expr)1 IdExpr (jkind.lustre.IdExpr)1 ArrayValue (jkind.lustre.values.ArrayValue)1 BooleanValue (jkind.lustre.values.BooleanValue)1 EnumValue (jkind.lustre.values.EnumValue)1 IntegerValue (jkind.lustre.values.IntegerValue)1 RealValue (jkind.lustre.values.RealValue)1 RecordValue (jkind.lustre.values.RecordValue)1 TupleValue (jkind.lustre.values.TupleValue)1 Value (jkind.lustre.values.Value)1