certificate.java

来自「Java版的SAT求解器」· Java 代码 · 共 79 行

JAVA
79
字号
/* * Certificate.java	2.0 05/04/19 * * Copyright 2004-2005 Positronic Software. * * */ /** * A class which represents a certificate. A certificate is a mapping of a set * of BooleanVariables into {true,false}. A certificate is used to represent a * solution of a satisfiability problem. * * @author  Kerry Michael Soileau * <blockquote><pre> * ksoileau@yahoo.com * http://web.wt.net/~ksoileau/index.htm * </pre></blockquote> * @version 2.0, 05/04/19 * @see ICertificate * @see HashMap * @see IBooleanVariable * @see Iterator * @see BooleanLiteralException * @see List */package positronic.satisfiability.elements;import positronic.satisfiability.exceptions.BooleanLiteralException;import positronic.util.ArrayListSet;public class Certificate implements ICertificate{  private ArrayListSet booleanLiterals;  public void add(IBooleanVariable x, boolean val) throws BooleanLiteralException  {  	this.getBooleanLiterals().add(BooleanLiteral.getBooleanLiteral(x,!val));  }  public boolean containsBooleanVariable(IBooleanVariable x) throws BooleanLiteralException  {    if(!(x instanceof IBooleanVariable))      return false;    return this.getBooleanLiterals().contains(x);  }  public ArrayListSet getBooleanLiterals() throws BooleanLiteralException  {  	if(this.booleanLiterals==null)  		this.booleanLiterals=new ArrayListSet();    return this.booleanLiterals;  }  public boolean getValue(IBooleanVariable x) throws BooleanLiteralException  {    if(!this.containsBooleanVariable(x))      return false; //default if IBooleanVariable x is not in Certificate    int ind=this.getBooleanLiterals().indexOf(x);    return !((IBooleanLiteral)this.getBooleanLiterals().get(ind)).isBarred();  }  public void setBooleanLiterals(ArrayListSet booleanLiterals)  {    this.booleanLiterals = booleanLiterals;  }  public String toString()  {    try    {      return this.getBooleanLiterals().toString();    }    catch(BooleanLiteralException err)    {      return null;    }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?