Search in sources :

Example 41 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class EvaluateFormulaCommand method processResult.

@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
    PrologTerm term = bindings.get(EVALUATE_RESULT_VARIABLE);
    value = EvalResult.getEvalResult(term);
}
Also used : PrologTerm(de.prob.prolog.term.PrologTerm)

Example 42 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class EvaluateRegisteredFormulasCommand method processResult.

@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
    PrologTerm terms = bindings.get(RESULTS_VARIABLE);
    if (terms instanceof ListPrologTerm) {
        ListPrologTerm lpt = BindingGenerator.getList(terms);
        for (int i = 0; i < lpt.size(); i++) {
            PrologTerm pt = lpt.get(i);
            IEvalElement key = formulas.get(i);
            results.put(key, EvalResult.getEvalResult(pt));
        }
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) IEvalElement(de.prob.animator.domainobjects.IEvalElement) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm)

Example 43 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class ExecuteUntilCommand method processResult.

@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
    ListPrologTerm trace = BindingGenerator.getList(bindings.get(TRACE_VARIABLE));
    result = bindings.get(RESULT_VARIABLE);
    for (PrologTerm term : trace) {
        CompoundPrologTerm t = BindingGenerator.getCompoundTerm(term, 4);
        Transition operation = Transition.createTransitionFromCompoundPrologTerm(statespace, t);
        resultTrace.add(operation);
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Transition(de.prob.statespace.Transition) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm)

Example 44 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class GetStateBasedErrorsCommandTest method testProcessResult.

@Test
public void testProcessResult() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get("Errors")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("error", new CompoundPrologTerm("foo"), new CompoundPrologTerm("bar"), new CompoundPrologTerm("baz"))));
    GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
    command.processResult(map);
    Collection<StateError> coll = command.getResult();
    StateError se = coll.iterator().next();
    assertEquals("foo", se.getEvent());
    assertEquals("bar", se.getShortDescription());
    assertEquals("baz", se.getLongDescription());
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) StateError(de.prob.animator.domainobjects.StateError) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Example 45 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class GetStateBasedErrorsCommandTest method testWriteCommand.

@Test
public void testWriteCommand() {
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("42");
    command.writeCommand(prologTermOutput);
    prologTermOutput.fullstop().flush();
    Collection<PrologTerm> sentences = prologTermOutput.getSentences();
    PrologTerm next = sentences.iterator().next();
    assertNotNull(next);
    assertTrue(next instanceof CompoundPrologTerm);
    CompoundPrologTerm t = (CompoundPrologTerm) next;
    assertEquals("get_state_errors", t.getFunctor());
    assertEquals(2, t.getArity());
    PrologTerm argument = t.getArgument(1);
    assertTrue(argument.isNumber());
    PrologTerm argument2 = t.getArgument(2);
    assertTrue(argument2.isVariable());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Aggregations

PrologTerm (de.prob.prolog.term.PrologTerm)103 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)86 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)85 Test (org.junit.Test)64 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)11 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)10 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)8 Transition (de.prob.statespace.Transition)5 IEvalElement (de.prob.animator.domainobjects.IEvalElement)4 ArrayList (java.util.ArrayList)4 CheckBooleanPropertyCommand (de.prob.animator.command.CheckBooleanPropertyCommand)3 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)3 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)2 LtlParseException (de.be4.ltl.core.parser.LtlParseException)2 ClassicalB (de.prob.animator.domainobjects.ClassicalB)2 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 StateError (de.prob.animator.domainobjects.StateError)2