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

cz.cvut.felk.cig.jcop.problem.sat.Formula Maven / Gradle / Ivy

The newest version!
/*
 * Copyright © 2010 by Ondrej Skalicka. All Rights Reserved
 */

package cz.cvut.felk.cig.jcop.problem.sat;

import cz.cvut.felk.cig.jcop.problem.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * Formula of {@link SAT} problem.
 * 

* Formula consists of {@link Clause clauses}. * * @author Ondrej Skalicka */ public class Formula { /** * List of all clauses in this formula */ protected List clauses; /** * Creates new empty (eg. without clauses) formula */ public Formula() { this.clauses = new ArrayList(); } /** * Adds clause to formula * * @param clause clause to be added */ public void addClause(Clause clause) { this.clauses.add(clause); } /** * Checks if formula evaluates to true. *

* Formula evaluates to true iff all its clauses evaluates to true. * * @param configuration configuration for which to evaluate * @return formula evaluations */ public boolean isTrue(Configuration configuration) { for (Clause clause : this.clauses) { if (!clause.isTrue(configuration)) return false; } return true; } /** * Returns list of all clauses in current formula * * @return list of clauses in formula */ public List getClauses() { return clauses; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy