5. Class AuxVarManager

5.1. Constructor

AuxVarManager(free_var: int)

The Auxiliary Variable Manager, returns fresh variables to the encoder. Therefore it is initialized with the first fresh variable free_var. Hence it is assumed that all variables in the original constraints are smaller than this first fresh variable.

>>> from pypblib import pblib
>>> aux_var = pblib.AuxVarManager(5)

5.3. Methods details

get_variable() → int

Returns the first free variable if all variables between 1 and the biggest variable are been used. Otherwise returns an unused variable between 1 and the biggest used variable. From that moment the returned variable is considered as used.

Warning

As you can see in the next example, in the case of unused variables between 1 and the biggest variable, the returned variable could be random.

>>> from pypblib import pblib
>>> aux = pblib.AuxVarManager(10)
>>> aux.get_variable()
10
>>> aux.get_variable()
11
>>> aux.free_variables([1, 3, 5, 7, 9])
>>> aux.get_variable()
9
>>> aux.get_variable()
1
>>> aux.get_variable()
3
free_variable(var: int)

Frees an used variable to refill the gap later on.

>>> from pypblib import pblib
>>> aux = pblib.AuxVarManager(9)
>>> aux.free_variable(3)
>>> aux.get_variable()
3
free_variables(vars: [int])

Frees the used variables specified in the list.

>>> from pypblib import pblib
>>> aux = pblib.AuxVarManager(10)
>>> aux.free_variables([1, 3, 5, 7, 9])
>>> aux.get_variable()
9
>>> aux.get_variable()
1
free_range_variables(var_start: int, var_end: int)

Frees the range of used variables between the specified start and end. Both limits are included.

>>> from pypblib import pblib
>>> aux = pblib.AuxVarManager(10)
>>> aux.free_range_variables(3, 5)
>>> aux.get_variable()
5
>>> aux.get_variable()
4
>>> aux.get_variable()
3
>>> aux.get_variable()
10
get_biggest_returned_auxvar() → int

Returns the biggest used variable. Hence every variable between this (including) number and free_var (probably) occurs in some clause database.

>>> from pypblib import pblib
>>> aux_var = pblib.AuxVarManager(5)
>>> print(aux_var.get_biggest_returned_auxvar())
4
reset_aux_var_to(first_free_var: int)

Resets the first free variable with the specified integer.

>>> from pypblib import pblib
>>> aux = pblib.AuxVarManager(10)
>>> aux.get_biggest_returned_auxvar()
9
>>> aux.reset_aux_var_to(20)
>>> aux.get_biggest_returned_auxvar()
19