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);
}
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));
}
}
}
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);
}
}
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());
}
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());
}
Aggregations