bitfixer.java

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

JAVA
58
字号
/* * BitFixer.java	1.1 04/10/05 * * Copyright 2004-2005 Positronic Software. * * */package positronic.satisfiability.elements; /** * An extension of the Problem class which implements a Boolean constraint. This * constraint is satisfied if and only if the IBooleanVariable x has a given * truth value. * * For example, when the Problem instance p defined by * * Problem p=new BitFixer(x,true); * * is satisfied, the following truth equation will be satisfied: * * x==true. * * Similarly, when the Problem instance p defined by * * Problem p=new BitFixer(x,false); * * is satisfied, the following truth equation will be satisfied: * * x==false. * * @author  Kerry Michael Soileau * ksoileau@yahoo.com * http://web.wt.net/~ksoileau/index.htm * @version 1.1, 04/10/05 * @see IBooleanVariable * @see IClause * @see Problem */public class BitFixer extends Problem implements IProblem{  private static final long serialVersionUID = 1L;  public BitFixer(IBooleanVariable x) throws Exception  {    this(x,x.getValue());  }  public BitFixer(IBooleanVariable x, boolean v) throws Exception  {    this.addClause(Clause.newClause());    if(v)      this.getClause(0).or(x);    else      this.getClause(0).orNot(x);  }}

⌨️ 快捷键说明

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