savi.alg.weighsat3
Class WeightedFormula

java.lang.Object
  extended by savi.alg.sat3.Formula
      extended by savi.alg.weighsat3.WeightedFormula

public class WeightedFormula
extends Formula

Class representing boolean formula with weights.


Field Summary
protected  int totalWeight
          sum of all weights
protected  int[] varWeights
          list of weights
 
Fields inherited from class savi.alg.sat3.Formula
clauses, varsCount
 
Constructor Summary
WeightedFormula(java.io.BufferedReader br)
          Creates a new instance of WeightedFormula, read content from stream.
WeightedFormula(int countClauses, int varsCount)
          Creates a new instance of WeightedFormula, create random formula with weights
 
Method Summary
 WeightedFormula clone()
          Create a copy of this object.
 int[] getWeights()
          Return list of weights
 double percentualWeight(boolean[] vars)
          Return fraction between weight of variables in state true and summary (total) weight
protected  void readFromStream(java.io.BufferedReader br)
          Read submission from stream.
 int satisfyWeight(boolean[] vars)
          Return weight of variables in state true.
 int totalWeight()
          Return total (summary) weight.
 
Methods inherited from class savi.alg.sat3.Formula
clausesCount, countSatisfactClauses, getClauses, isSatisfact, percentualSatisfact, reduceNumberOfClauses, varsCount
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

varWeights

protected int[] varWeights
list of weights


totalWeight

protected int totalWeight
sum of all weights

Constructor Detail

WeightedFormula

public WeightedFormula(int countClauses,
                       int varsCount)
Creates a new instance of WeightedFormula, create random formula with weights

Parameters:
countClauses - number of clauses
varsCount - number of variables

WeightedFormula

public WeightedFormula(java.io.BufferedReader br)
                throws WrongInputFormulaData
Creates a new instance of WeightedFormula, read content from stream.

Parameters:
br - input stream with buffered readed
Throws:
WrongInputFormulaData - signals syntax error
Method Detail

percentualWeight

public double percentualWeight(boolean[] vars)
Return fraction between weight of variables in state true and summary (total) weight

Parameters:
vars - variables assignment
Returns:
percentual weight

satisfyWeight

public int satisfyWeight(boolean[] vars)
Return weight of variables in state true.

Parameters:
vars - list of variables
Returns:
weight

totalWeight

public int totalWeight()
Return total (summary) weight.

Returns:
total weight

getWeights

public int[] getWeights()
Return list of weights

Returns:
list of weights

readFromStream

protected void readFromStream(java.io.BufferedReader br)
                       throws WrongInputFormulaData
Read submission from stream.

Overrides:
readFromStream in class Formula
Parameters:
br - input stream with buffered readed
Throws:
WrongInputFormulaData - signals syntax error

clone

public WeightedFormula clone()
Create a copy of this object.

Overrides:
clone in class Formula
Returns:
a copy of this object