From b08dbeed01c6f2516fc4884a074f76bf750a6103 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Mon, 25 Mar 2024 15:34:03 +0900 Subject: [PATCH 1/2] Fix docstring --- src/layer.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/layer.jl b/src/layer.jl index 223c2e3..d694e0b 100644 --- a/src/layer.jl +++ b/src/layer.jl @@ -60,8 +60,7 @@ is_viable(layer::Layer, w) = exclu(layer) ? as_int(w) < length(layer) : any(w) """ generate_inclusive_operations(predicate, bits) - generate_exclusive_operation(max_op_number) -Generates the operations (weigths) of a layer with inclusive/exclusive operations. +Generates the operations (weigths) of a layer with inclusive operations. """ function generate_inclusive_operations(predicate, bits) ind = falses(bits) @@ -72,6 +71,10 @@ function generate_inclusive_operations(predicate, bits) return ind end +""" + generate_exclusive_operation(max_op_number) +Generates the operations (weigths) of a layer with exclusive operations. +""" function generate_exclusive_operation(max_op_number) op = rand(1:max_op_number) return as_bitvector(op, max_op_number) From af603c090c0f4e84b0f52c70915000125c54e59d Mon Sep 17 00:00:00 2001 From: Azzaare Date: Mon, 25 Mar 2024 19:52:50 +0900 Subject: [PATCH 2/2] Add make transformation doc --- src/layers/transformation.jl | 48 +++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/layers/transformation.jl b/src/layers/transformation.jl index 2d4e837..6ffe393 100644 --- a/src/layers/transformation.jl +++ b/src/layers/transformation.jl @@ -212,7 +212,53 @@ end # Generating vetorized versions lazy(tr_contiguous_vals_minus, tr_contiguous_vals_minus_rev) -# Parametric layers +""" + 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 +```julia +# 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) +``` +""" make_transformations(param::Symbol) = make_transformations(Val(param)) function make_transformations(::Val{:none})