Transformations Layer
Some text to describe the transformation layer within usual ICNs.
The implementation of the transformation relies heavily on the use of the lazy function (make a ref, open an issue to make @lazy
macro in front of each transformation).
List of transformations
List the possible parameters and how it affects the transformations.
Non-parametric
CompositionalNetworks.tr_identity Function
tr_identity(i, x)
tr_identity(x)
tr_identity(x, X::AbstractVector)
Identity function. Already defined in Julia as identity
, specialized for vectors. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_eq Function
tr_count_eq(i, x)
tr_count_eq(x)
tr_count_eq(x, X::AbstractVector)
Count the number of elements equal to x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_eq_right Function
tr_count_eq_right(i, x)
tr_count_eq_right(x)
tr_count_eq_right(x, X::AbstractVector)
Count the number of elements to the right of and equal to x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_eq_left Function
tr_count_eq_left(i, x)
tr_count_eq_left(x)
tr_count_eq_left(x, X::AbstractVector)
Count the number of elements to the left of and equal to x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_greater Function
tr_count_greater(i, x)
tr_count_greater(x)
tr_count_greater(x, X::AbstractVector)
Count the number of elements greater than x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_lesser Function
tr_count_lesser(i, x)
tr_count_lesser(x)
tr_count_lesser(x, X::AbstractVector)
Count the number of elements lesser than x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_g_left Function
tr_count_g_left(i, x)
tr_count_g_left(x)
tr_count_g_left(x, X::AbstractVector)
Count the number of elements to the left of and greater than x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_g_right Function
tr_count_g_right(i, x)
tr_count_g_right(x)
tr_count_g_right(x, X::AbstractVector)
Count the number of elements to the right of and greater than x[i]
. Extended method to vector with sig (x)
are generated.
CompositionalNetworks.tr_count_l_right Function
tr_count_l_right(i, x)
tr_count_l_right(x)
tr_count_l_right(x, X::AbstractVector)
Count the number of elements to the right of and lesser than x[i]
. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_contiguous_vars_minus Function
tr_contiguous_vars_minus(i, x)
tr_contiguous_vars_minus(x)
tr_contiguous_vars_minus(x, X::AbstractVector)
Return the difference x[i] - x[i + 1]
if positive, 0.0
otherwise. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_contiguous_vars_minus_rev Function
tr_contiguous_vars_minus_rev(i, x)
tr_contiguous_vars_minus_rev(x)
tr_contiguous_vars_minus_rev(x, X::AbstractVector)
Return the difference x[i + 1] - x[i]
if positive, 0.0
otherwise. Extended method to vector with sig (x)
are generated. When X
is provided, the result is computed without allocations.
Param: :val
CompositionalNetworks.tr_count_eq_val Function
tr_count_eq_val(i, x; val)
tr_count_eq_val(x; val)
tr_count_eq_val(x, X::AbstractVector; val)
Count the number of elements equal to x[i] + val
. Extended method to vector with sig (x, val)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_l_val Function
tr_count_l_val(i, x; val)
tr_count_l_val(x; val)
tr_count_l_val(x, X::AbstractVector; val)
Count the number of elements lesser than x[i] + val
. Extended method to vector with sig (x, val)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_g_val Function
tr_count_g_val(i, x; val)
tr_count_g_val(x; val)
tr_count_g_val(x, X::AbstractVector; val)
Count the number of elements greater than x[i] + val
. Extended method to vector with sig (x, val)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_count_bounding_val Function
tr_count_bounding_val(i, x; val)
tr_count_bounding_val(x; val)
tr_count_bounding_val(x, X::AbstractVector; val)
Count the number of elements bounded (not strictly) by x[i]
and x[i] + val
. An extended method to vector with sig (x, val)
is generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_var_minus_val Function
tr_var_minus_val(i, x; val)
tr_var_minus_val(x; val)
tr_var_minus_val(x, X::AbstractVector; val)
Return the difference x[i] - val
if positive, 0.0
otherwise. Extended method to vector with sig (x, val)
are generated. When X
is provided, the result is computed without allocations.
CompositionalNetworks.tr_val_minus_var Function
tr_val_minus_var(i, x; val)
tr_val_minus_var(x; val)
tr_val_minus_var(x, X::AbstractVector; val)
Return the difference val - x[i]
if positive, 0.0
otherwise. Extended method to vector with sig (x, val)
are generated. When X
is provided, the result is computed without allocations.
Layer generation
CompositionalNetworks.make_transformations Function
make_transformations(param::Symbol)
Generates a dictionary of transformation functions based on the specified parameterization. This function facilitates the creation of parametric layers for constraint transformations, allowing for flexible and dynamic constraint manipulation according to the needs of different constraint programming models.
Parameters
param::Symbol
: Specifies the type of transformations to generate. It can be:none
for basic transformations that do not depend on external parameters, or:val
for transformations that operate with respect to a specific value parameter.
Returns
LittleDict{Symbol, Function}
: A dictionary mapping transformation names (Symbol
) to their corresponding functions (Function
). The functions encapsulate various types of transformations, such as counting, comparison, and contiguous value processing.
Transformation Types
When
param
is:none
, the following transformations are available::identity
: No transformation is applied.:count_eq
,:count_eq_left
,:count_eq_right
: Count equalities under different conditions.:count_greater
,:count_lesser
: Count values greater or lesser than a threshold.:count_g_left
,:count_l_left
,:count_g_right
,:count_l_right
: Count values with greater or lesser comparisons from different directions.:contiguous_vals_minus
,:contiguous_vals_minus_rev
: Process contiguous values with subtraction in normal and reverse order.
When
param
is:val
, the transformations relate to operations involving a parameter value::count_eq_param
,:count_l_param
,:count_g_param
: Count equalities or comparisons against a parameter value.:count_bounding_param
: Count values bounding a parameter value.:val_minus_param
,:param_minus_val
: Subtract a parameter value from values or vice versa.
The function delegates to a version that uses Val(param)
for dispatch, ensuring compile-time selection of the appropriate transformation set.
Examples
# Get basic transformations
basic_transforms = make_transformations(:none)
# Apply an identity transformation
identity_result = basic_transforms[:identity](data)
# Get value-based transformations
val_transforms = make_transformations(:val)
# Apply a count equal to parameter transformation
count_eq_param_result = val_transforms[:count_eq_param](data, param)
CompositionalNetworks.transformation_layer Function
transformation_layer(param = Vector{Symbol}())
Generate the layer of transformations functions of the ICN. Iff param
value is non empty, also includes all the related parametric transformations.