Skip to content

Commit 9c623ff

Browse files
authored
Merge pull request #65 from JuliaConstraints/dev
Update docs from dev
2 parents f8f37fd + daecdf7 commit 9c623ff

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/layer.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ function generate_inclusive_operations(predicate, bits)
7272
return ind
7373
end
7474

75+
"""
76+
generate_exclusive_operation(max_op_number)
77+
Generates the operations (weigths) of a layer with exclusive operations.
78+
"""
7579
function generate_exclusive_operation(max_op_number)
7680
op = rand(1:max_op_number)
7781
return as_bitvector(op, max_op_number)

src/layers/transformation.jl

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,53 @@ end
213213
# Generating vetorized versions
214214
lazy(tr_contiguous_vals_minus, tr_contiguous_vals_minus_rev)
215215

216-
# Parametric layers
216+
"""
217+
make_transformations(param::Symbol)
218+
219+
Generates a dictionary of transformation functions based on the specified parameterization.
220+
This function facilitates the creation of parametric layers for constraint transformations,
221+
allowing for flexible and dynamic constraint manipulation according to the needs of different
222+
constraint programming models.
223+
224+
## Parameters
225+
- `param::Symbol`: Specifies the type of transformations to generate. It can be `:none` for
226+
basic transformations that do not depend on external parameters, or `:val` for transformations that operate with respect to a specific value parameter.
227+
228+
## Returns
229+
- `LittleDict{Symbol, Function}`: A dictionary mapping transformation names (`Symbol`) to
230+
their corresponding functions (`Function`). The functions encapsulate various types of
231+
transformations, such as counting, comparison, and contiguous value processing.
232+
233+
## Transformation Types
234+
- When `param` is `:none`, the following transformations are available:
235+
- `:identity`: No transformation is applied.
236+
- `:count_eq`, `:count_eq_left`, `:count_eq_right`: Count equalities under different conditions.
237+
- `:count_greater`, `:count_lesser`: Count values greater or lesser than a threshold.
238+
- `:count_g_left`, `:count_l_left`, `:count_g_right`, `:count_l_right`: Count values with greater or lesser comparisons from different directions.
239+
- `:contiguous_vals_minus`, `:contiguous_vals_minus_rev`: Process contiguous values with subtraction in normal and reverse order.
240+
241+
- When `param` is `:val`, the transformations relate to operations involving a parameter value:
242+
- `:count_eq_param`, `:count_l_param`, `:count_g_param`: Count equalities or comparisons against a parameter value.
243+
- `:count_bounding_param`: Count values bounding a parameter value.
244+
- `:val_minus_param`, `:param_minus_val`: Subtract a parameter value from values or vice versa.
245+
246+
The function delegates to a version that uses `Val(param)` for dispatch, ensuring compile-time selection of the appropriate transformation set.
247+
248+
## Examples
249+
```julia
250+
# Get basic transformations
251+
basic_transforms = make_transformations(:none)
252+
253+
# Apply an identity transformation
254+
identity_result = basic_transforms[:identity](data)
255+
256+
# Get value-based transformations
257+
val_transforms = make_transformations(:val)
258+
259+
# Apply a count equal to parameter transformation
260+
count_eq_param_result = val_transforms[:count_eq_param](data, param)
261+
```
262+
"""
217263
make_transformations(param::Symbol) = make_transformations(Val(param))
218264

219265
function make_transformations(::Val{:none})

0 commit comments

Comments
 (0)