nl.uu.cs.ape.models.sltlxStruc.SLTLxNextOp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of APE Show documentation
Show all versions of APE Show documentation
APE is a command line tool and an API for the automated exploration of possible computational pipelines (workflows) from large collections of computational tools.
The newest version!
package nl.uu.cs.ape.models.sltlxStruc;
import java.util.HashSet;
import java.util.Set;
import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;
/**
* Structure used to model Next operation (<Op>) modal statement in SLTLx.
*
* @author Vedran Kasalica
*
*/
public class SLTLxNextOp extends SLTLxFormula {
private SLTLxFormula operation;
private SLTLxFormula formula;
public SLTLxNextOp(SLTLxFormula operation, SLTLxFormula formula) {
super();
this.operation = operation;
this.formula = formula;
}
@Override
public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
SATSynthesisEngine synthesisEngine) {
if (synthesisEngine.getSolutionSize() <= stateNo) {
return SLTLxAtom.getFalse().getCNFEncoding(stateNo, variableMapping, synthesisEngine);
}
Set> allClauses = new HashSet<>();
/*
* Conjunct the collection of clauses that encode the operation and the formula
*/
allClauses.add(operation.getCNFEncoding(stateNo, variableMapping, synthesisEngine));
allClauses.add(formula.getCNFEncoding(stateNo + 1, variableMapping, synthesisEngine));
return CNFClause.conjunctClausesCollection(allClauses);
}
@Override
public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
SATSynthesisEngine synthesisEngine) {
if (synthesisEngine.getSolutionSize() <= stateNo) {
return SLTLxAtom.getTrue().getCNFEncoding(stateNo, variableMapping, synthesisEngine);
}
Set> allClauses = new HashSet<>();
/*
* Disjunction the collection of clauses that encode the negation of the
* operation and of the formula
*/
allClauses.add(operation.getNegatedCNFEncoding(stateNo, variableMapping, synthesisEngine));
allClauses.add(formula.getNegatedCNFEncoding(stateNo + 1, variableMapping, synthesisEngine));
return CNFClause.disjoinClausesCollection(allClauses);
}
}