CompositionalNetworks.ICNType
ICN(; nvars, dom_size, param, transformation, arithmetic, aggregation, comparison)

Construct an Interpretable Compositional Network, with the following arguments:

  • nvars: number of variable in the constraint
  • dom_size: maximum domain size of any variable in the constraint
  • param: optional parameter (default to nothing)
  • transformation: a transformation layer (optional)
  • arithmetic: a arithmetic layer (optional)
  • aggregation: a aggregation layer (optional)
  • comparison: a comparison layer (optional)
CompositionalNetworks.LayerType
Layer

A structure to store a LittleDict of operations that can be selected during the learning phase of an ICN. If the layer is exclusive, only one operation can be selected at a time.

Base.lengthMethod
length(layer)

Return the number of operations in a layer.

Base.lengthMethod
Base.length(icn)

Return the total number of operations of an ICN.

CompositionalNetworks.arithmetic_layerMethod
arithmetic_layer()

Generate the layer of arithmetic operations of the ICN. The operations are mutually exclusive, that is only one will be selected.

CompositionalNetworks.codeFunction
code(c::Composition, lang=:maths; name="composition")

Access the code of a composition c in a given language lang. The name of the generated method is optional.

CompositionalNetworks.comparison_layerFunction
comparison_layer(param = false)

Generate the layer of transformations functions of the ICN. Iff param value is set, also includes all the parametric comparison with that value. The operations are mutually exclusive, that is only one will be selected.

CompositionalNetworks.composeFunction
compose(icn, weigths=nothing)

Return a function composed by some of the operations of a given ICN. Can be applied to any vector of variables. If weigths are given, will assign to icn.

CompositionalNetworks.compose_to_file!Method
compose_to_file!(concept, name, path; domains, param = nothing, language = :Julia, search = :complete, global_iter = 10, local_iter = 100, metric = hamming, popSize = 200)

Explore, learn and compose a function and write it to a file.

Arguments:

  • concept: the concept to learn
  • name: the name to give to the constraint
  • path: path of the output file

Keywords arguments:

  • domains: domains that defines the search space
  • param: an optional paramater of the constraint
  • language: the language to export to, default to :julia
  • search: either :partial or :complete search
  • global_iter: number of learning iteration
  • local_iter: number of generation in the genetic algorithm
  • metric: the metric to measure the distance between a configuration and known solutions
  • popSize: size of the population in the genetic algorithm
CompositionalNetworks.explore_learn_composeMethod
explore_learn_compose(concept; domains, param = nothing, search = :complete, global_iter = 10, local_iter = 100, metric = hamming, popSize = 200, action = :composition)

Explore a search space, learn a composition from an ICN, and compose an error function.

Arguments:

  • concept: the concept of the targeted constraint
  • domains: domains of the variables that define the training space
  • param: an optional parameter of the constraint
  • search: either flexible,:partial or :complete search. Flexible search will use search_limit and solutions_limit to determine if the search space needs to be partially or completely explored
  • global_iter: number of learning iteration
  • local_iter: number of generation in the genetic algorithm
  • metric: the metric to measure the distance between a configuration and known solutions
  • popSize: size of the population in the genetic algorithm
  • action: either :symbols to have a description of the composition or :composition to have the composed function itself
CompositionalNetworks.hammingMethod
hamming(x, X)

Compute the hamming distance of x over a collection of solutions X, i.e. the minimal number of variables to switch in xto reach a solution.

CompositionalNetworks.is_viableMethod
is_viable(layer, w)
is_viable(icn)
is_viable(icn, w)

Assert if a pair of layer/icn and weigths compose a viable pattern. If no weigths are given with an icn, it will check the current internal value.

CompositionalNetworks.lazyMethod
lazy(funcs::Function...)

Generate methods extended to a vector instead of one of its components. A function f should have the following signature: f(i::Int, x::V).

CompositionalNetworks.lazy_paramMethod
lazy_param(funcs::Function...)

Generate methods extended to a vector instead of one of its components. A function f should have the following signature: f(i::Int, x::V; param).

CompositionalNetworks.learn_composeMethod
learn_compose(;
    nvars, dom_size, param=nothing, icn=ICN(nvars, dom_size, param),
    X, X_sols, global_iter=100, local_iter=100, metric=hamming, popSize=200
)

Create an ICN, optimize it, and return its composition.

CompositionalNetworks.map_tr!Method
map_tr!(f, x, X, param)

Return an anonymous function that applies f to all elements of x and store the result in X, with a parameter param (which is set to nothing for function with no parameter).

CompositionalNetworks.regularizationMethod
regularization(icn)

Return the regularization value of an ICN weigths, which is proportional to the normalized number of operations selected in the icn layers.

CompositionalNetworks.tr_contiguous_vals_minusMethod
tr_contiguous_vals_minus(i, x)
tr_contiguous_vals_minus(x)
tr_contiguous_vals_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_vals_minus_revMethod
tr_contiguous_vals_minus_rev(i, x)
tr_contiguous_vals_minus_rev(x)
tr_contiguous_vals_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.

CompositionalNetworks.tr_count_bounding_paramMethod
tr_count_bounding_param(i, x; param)
tr_count_bounding_param(x; param)
tr_count_bounding_param(x, X::AbstractVector; param)

Count the number of elements bounded (not strictly) by x[i] and x[i] + param. An extended method to vector with sig (x, param) is generated. When X is provided, the result is computed without allocations.

CompositionalNetworks.tr_count_eqMethod
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_leftMethod
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_eq_paramMethod
tr_count_eq_param(i, x; param)
tr_count_eq_param(x; param)
tr_count_eq_param(x, X::AbstractVector; param)

Count the number of elements equal to x[i] + param. Extended method to vector with sig (x, param) are generated. When X is provided, the result is computed without allocations.

CompositionalNetworks.tr_count_eq_rightMethod
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_g_leftMethod
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_paramMethod
tr_count_g_param(i, x; param)
tr_count_g_param(x; param)
tr_count_g_param(x, X::AbstractVector; param)

Count the number of elements greater than x[i] + param. Extended method to vector with sig (x, param) are generated. When X is provided, the result is computed without allocations.

CompositionalNetworks.tr_count_g_rightMethod
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_greaterMethod
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_l_leftMethod
tr_count_l_left(i, x)
tr_count_l_left(x)
tr_count_l_left(x, X::AbstractVector)

Count the number of elements to the left 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_count_l_paramMethod
tr_count_l_param(i, x; param)
tr_count_l_param(x; param)
tr_count_l_param(x, X::AbstractVector; param)

Count the number of elements lesser than x[i] + param. Extended method to vector with sig (x, param) are generated. When X is provided, the result is computed without allocations.

CompositionalNetworks.tr_count_l_rightMethod
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_count_lesserMethod
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_identityMethod
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_param_minus_valMethod
tr_param_minus_val(i, x; param)
tr_param_minus_val(x; param)
tr_param_minus_val(x, X::AbstractVector; param)

Return the difference param - x[i] if positive, 0.0 otherwise. Extended method to vector with sig (x, param) are generated. When X is provided, the result is computed without allocations.

CompositionalNetworks.tr_val_minus_paramMethod
tr_val_minus_param(i, x; param)
tr_val_minus_param(x; param)
tr_val_minus_param(x, X::AbstractVector; param)

Return the difference x[i] - param if positive, 0.0 otherwise. Extended method to vector with sig (x, param) are generated. When X is provided, the result is computed without allocations.

CompositionalNetworks.transformation_layerFunction
transformation_layer(param = false)

Generate the layer of transformations functions of the ICN. Iff param value is true, also includes all the parametric transformations.