cnf::VariableSet Class Reference

Represents a mathematical variable set; is used to associate a unique code to a given number of literals described intuitively by 2 or 3 indices. More...

#include <variableset.h>

List of all members.

Public Member Functions

 VariableSet (unsigned int, unsigned int)
 Constructor for 2D literals (x_ij).
 VariableSet (unsigned int, unsigned int, unsigned int)
 Constructor for 3D literals (x_ijk).
void addVars (unsigned int, unsigned int)
 Adds a new subset of variables to this instance.
void addVars (unsigned int, unsigned int, unsigned int)
 Adds a new subset of variables to this instance.
unsigned int getVarCode (unsigned int, unsigned int, unsigned int)
 Returns the code of the 2D variable designed by the coordinates given as argument in the l_th subset.
unsigned int getVarCode (unsigned int, unsigned int, unsigned int, unsigned int)
 Returns the code of the 3D variable designed by the coordinates given as argument.
bool getVarValue (unsigned int, unsigned int, unsigned int)
 Returns the value of the variable described by the given 2D coordinates.
bool getVarValue (unsigned int, unsigned int, unsigned int, unsigned int)
 Returns the value of the variable described by the given 3D coordinates.
unsigned int getCard ()
 Returns the total number of variables in this set.
void parseDimacs (std::istream *)
 Parses a dimacs results formatted stream and assigns its variables accordingly.

Private Attributes

std::vector< std::vector
< unsigned int > > 
dim
 The dimensions of the matrices to which the variables correspond. Each std::vector< unsigned int> corresponds to one subset of variables.
std::vector< unsigned int > sizes
 Contains the length of the std::vector used by each variables subset. It allows a faster computation of the index in varValue of a given literal from its coordinates.
std::vector< bool > varValue
 Contains the value of each variable in the set; is initialized so as to contain only "false".

Detailed Description

Represents a mathematical variable set; is used to associate a unique code to a given number of literals described intuitively by 2 or 3 indices.

In order for formula to be written in DIMACS files and to be manipulated by Clause and Formula instance, they must have a unique integer valued code. This class ensures the corresponds between the code and the coordinates of a variable.

Definition at line 25 of file variableset.h.


Constructor & Destructor Documentation

VariableSet::VariableSet ( unsigned int  i,
unsigned int  j 
)

Constructor for 2D literals (x_ij).

Initializes the VariableSet instance by creating a varValue std::vector attribute of the correct size and filling it with zeros.

Parameters:
iFirst dimension describing the literals.
jThe second dimension.

Definition at line 18 of file variableset.cpp.

VariableSet::VariableSet ( unsigned int  i,
unsigned int  j,
unsigned int  k 
)

Constructor for 3D literals (x_ijk).

Initializes the VariableSet instance by creating a varValue std::vector attribute of the correct size and filling it with zeros.

Parameters:
iFirst dimension describing the literals.
jThe second dimension.
kThe third one.

Definition at line 24 of file variableset.cpp.


Member Function Documentation

void VariableSet::addVars ( unsigned int  i,
unsigned int  j 
)

Adds a new subset of variables to this instance.

Their coordinates are indepedents from any other subset.

Parameters:
iFirst coordinate.
jFirst coordinate.

Definition at line 30 of file variableset.cpp.

void VariableSet::addVars ( unsigned int  i,
unsigned int  j,
unsigned int  k 
)

Adds a new subset of variables to this instance.

Their coordinates are indepedents from any other subset.

Parameters:
iFirst coordinate.
jFirst coordinate.
kFirst coordinate.

Definition at line 43 of file variableset.cpp.

unsigned int VariableSet::getCard ( )

Returns the total number of variables in this set.

Returns:
The cardinal of the set of the variables.

Definition at line 157 of file variableset.cpp.

unsigned int VariableSet::getVarCode ( unsigned int  s,
unsigned int  i,
unsigned int  j,
unsigned int  k 
)

Returns the code of the 3D variable designed by the coordinates given as argument.

Parameters:
ssubset index
iFirst coordinate.
jSecond coordinate.
kThird one.
Returns:
The code of x_ijk

Definition at line 84 of file variableset.cpp.

unsigned int VariableSet::getVarCode ( unsigned int  s,
unsigned int  i,
unsigned int  j 
)

Returns the code of the 2D variable designed by the coordinates given as argument in the l_th subset.

Parameters:
ssubset index
iFirst coordinate.
jSecond coordinate.
Returns:
The code of x_ij

Definition at line 57 of file variableset.cpp.

bool VariableSet::getVarValue ( unsigned int  s,
unsigned int  i,
unsigned int  j,
unsigned int  k 
)

Returns the value of the variable described by the given 3D coordinates.

Parameters:
ssubset index
iFirst coordinate.
jSecond coordinate.
kThird one.
Returns:
The value of x_ijk.

Definition at line 121 of file variableset.cpp.

bool VariableSet::getVarValue ( unsigned int  s,
unsigned int  i,
unsigned int  j 
)

Returns the value of the variable described by the given 2D coordinates.

Parameters:
ssubset index
iFirst coordinate.
jSecond coordinate.
Returns:
The value of x_ij.

Definition at line 115 of file variableset.cpp.

void VariableSet::parseDimacs ( std::istream *  input)

Parses a dimacs results formatted stream and assigns its variables accordingly.

Any previous assignment is erased, in particular that of the construction.

Parameters:
inputThe input stream to the file to parse.

Definition at line 127 of file variableset.cpp.


Member Data Documentation

std::vector< std::vector<unsigned int> > cnf::VariableSet::dim [private]

The dimensions of the matrices to which the variables correspond. Each std::vector< unsigned int> corresponds to one subset of variables.

There can be as many dimensions as necessary in each subset. For instance, if "x" variables are in a 3x3 matrix and "y" variables in a 2x4 one, then it should hold that dim = [ [3,3], [2,4] ].

Definition at line 38 of file variableset.h.

std::vector<unsigned int> cnf::VariableSet::sizes [private]

Contains the length of the std::vector used by each variables subset. It allows a faster computation of the index in varValue of a given literal from its coordinates.

Definition at line 46 of file variableset.h.

std::vector<bool> cnf::VariableSet::varValue [private]

Contains the value of each variable in the set; is initialized so as to contain only "false".

Definition at line 52 of file variableset.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Defines