Skip to content

Update docs #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/layer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
return ind
end

"""
generate_exclusive_operation(max_op_number)
Generates the operations (weigths) of a layer with exclusive operations.

Check warning on line 77 in src/layer.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"weigths" should be "weights".
"""
function generate_exclusive_operation(max_op_number)
op = rand(1:max_op_number)
return as_bitvector(op, max_op_number)
Expand Down
48 changes: 47 additions & 1 deletion src/layers/transformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,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})
Expand Down
Loading