Boolean functions. More...
#include <boolfunction.h>
Public Member Functions | |
boolfunction (var _v, bool _negated=false) | |
Creates a boolfunction consisting of only one basic variable. | |
boolfunction (var _v1, var _v2, boolOperator _op, bool _negated=false) | |
Creates a boolfunction (v1 op v2). | |
boolfunction (boolfunction *_left, var _v2, boolOperator _op, bool _negated=false) | |
Creates a boolfunction (left op v2). | |
boolfunction (var _v1, boolfunction *_right, boolOperator _op, bool _negated=false) | |
Creates a boolfunction (v1 op right). | |
boolfunction (boolfunction *_left, boolfunction *_right, boolOperator _op, bool _negated=false) | |
Creates a boolfunction (left op right). | |
boolfunction * | copy () |
Creates a copy of the boolfunction and returns a pointer to that copy. | |
row | get_rLinear () const |
Returns the linearization row. | |
boolfunction * | get_left () const |
Returns a pointer to the left operand. | |
boolfunction * | get_right () const |
Returns a pointer to the right operand. | |
var | get_v () const |
Returns the variable v The basic variable v is only set if op is BASIC. | |
boolOperator | get_op () const |
Returns the operator of the boolfunction. | |
bool | is_negated () const |
Returns true if the boolfunction is negated. | |
void | negate () |
Negates the boolfunction. | |
void | add (boolOperator _op, var _v, bool negated=false) |
Adds v to the right-hand side of the boolfunction using operator op . | |
void | add (var _v, boolOperator _op, bool negated=false) |
Adds v to the left-hand side of the boolfunction using operator op . | |
void | add (boolfunction *_left, boolOperator _op, bool negated=false) |
Adds the boolfunction left to the left-hand side of the boolfunction using operator op . | |
void | add (boolOperator _op, boolfunction *_right, bool negated=false) |
Adds the boolfunction right to the right-hand side of the boolfunction using operator op . | |
var & | linearize (ILP_Problem &IP) |
Linearizes the boolfunction and creates the linearization variable which is stored in rLinear. | |
void | simplify () |
Simplifies the boolfunction. | |
bool | evaluate (solution &S) |
Evaluates the boolfunction based on Solution S . | |
std::string | get_originalTerm () |
Returns the original term stored by simplify . | |
std::string | toString () |
Converts the boolfunction to a string. | |
bool | isHomogeneous (boolOperator _op=BASIC) |
std::vector< var > | get_vars () |
Returns a vector of all contained variables in the boolfunction. | |
Friends | |
class | bool_inst |
The class boolfunction represents a Boolean function which is basically composed of a left and right operand and the associated operator. The two operands are also boolfunctions and therefore a boolfunction may also consist of only one basic variable.
Boolfunctions may only be used with pointers because of their tree structure.
Definition at line 17 of file boolfunction.h.
bool SCIL::boolfunction::isHomogeneous | ( | boolOperator | _op = BASIC |
) |
Returns true if every operator in the boolfunction is of the same type and is one of AND, OR, NAND or NOR
void SCIL::boolfunction::simplify | ( | ) |
Reformulates the boolfunction to a term without any negations, exclusive disjunctions and equivalences. The original term is stored as a string in the private attribute originalTerm.
Referenced by SCIL::ILP_Problem::add_boolfunction().