All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.uu.cs.ape.models.sltlxStruc.SLTLxDisjunction Maven / Gradle / Ivy

Go to download

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.Collection;
import java.util.HashSet;
import java.util.Set;

import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;

/**
 * Structure used to model disjunction of terms in SLTLx.
 * 
 * @author Vedran Kasalica
 *
 */
public class SLTLxDisjunction extends SLTLxFormula {

	private Set disjointFacts;

	public SLTLxDisjunction(SLTLxFormula arg1, SLTLxFormula arg2) {
		super();
		this.disjointFacts = new HashSet<>();
		if (arg1 != null)
			this.disjointFacts.add(arg1);
		if (arg2 != null)
			this.disjointFacts.add(arg2);
	}

	public SLTLxDisjunction(Collection conjunctedFacts) {
		super();
		this.disjointFacts = new HashSet<>();
		conjunctedFacts.forEach(fact -> {
			if (fact != null)
				this.disjointFacts.add(fact);
		});
	}

	@Override
	public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
			SATSynthesisEngine synthesisEngine) {
		/* Implement disjunction over an empty set rule. */
		if (disjointFacts.isEmpty()) {
			return SLTLxAtom.getFalse().getCNFEncoding(stateNo, variableMapping, synthesisEngine);
		}

		Set> allClauses = new HashSet<>();

		/*
		 * Disjoint the collection of clauses that encode each of the disjoint elements.
		 */
		for (SLTLxFormula formula : disjointFacts) {
			allClauses.add(formula.getCNFEncoding(stateNo, variableMapping, synthesisEngine));
		}
		return CNFClause.disjoinClausesCollection(allClauses);
	}

	@Override
	public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
			SATSynthesisEngine synthesisEngine) {
		/* Implement disjunction over an empty set rule. */
		if (disjointFacts.isEmpty()) {
			return SLTLxAtom.getTrue().getCNFEncoding(stateNo, variableMapping, synthesisEngine);
		}

		Set> allClauses = new HashSet<>();

		/*
		 * Conjunct the collection of clauses that encode negations of each of the
		 * disjoint elements.
		 */
		for (SLTLxFormula formula : disjointFacts) {
			allClauses.add(formula.getNegatedCNFEncoding(stateNo, variableMapping, synthesisEngine));
		}
		return CNFClause.conjunctClausesCollection(allClauses);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy