-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ICN and doc update (prepare the beta release) (#9)
* Deleted Manifest from git and added it to .gitignore * Script to compute error from ICN in /learn * Added learning script and results * temp save * temp save * Moved learning folder. Updated param and dom_size kwarg * Added new icn results and learning script * improved doc * Correct wrong meta info * Updated learned errors
- Loading branch information
Showing
18 changed files
with
152 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[deps] | ||
CompositionalNetworks = "4b67e4b5-442d-4ef5-b760-3f5df3a57537" | ||
ConstraintDomains = "5800fd60-8556-4464-8d61-84ebf7a0bedb" | ||
Constraints = "30f324ab-b02d-43f0-b619-e131c61659f7" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ConstraintDomains.jl | ||
|
||
Currently only discrete domains are supported using the following function. | ||
|
||
```@docs | ||
ConstraintDomains.domain | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# CompositionalNetworks.jl | ||
|
||
```@contents | ||
Pages = ["public.md"] | ||
Depth = 5 | ||
``` | ||
|
||
`CompositionalNetworks.jl`, a Julia package for Interpretable Compositional Networks (ICN), a variant of neural networks, allowing the user to get interpretable results, unlike regular artificial neural networks. | ||
|
||
The current state of our ICN focuses on the composition of error functions for `LocalSearchSolvers.jl`, but produces results independently of it and export it to either/both Julia functions or/and human readable output. | ||
|
||
### How does it work? | ||
|
||
The package comes with a basic ICN for learning global constraints. The ICN is composed of 4 layers: `transformation`, `arithmetic`, `aggregation`, and `comparison`. Each contains several operations that can be composed in various ways. | ||
Given a `concept` (a predicate over the variables' domains), a metric (`hamming` by default), and the variables' domains, we learn the binary weights of the ICN. | ||
|
||
## Installation | ||
|
||
```julia | ||
] add CompositionalNetworks | ||
``` | ||
|
||
As the package is in a beta version, some changes in the syntax and features are likely to occur. However, those changes should be minimal between minor versions. Please update with caution. | ||
|
||
## Quickstart | ||
|
||
```julia | ||
# 4 variables in 1:4 | ||
doms = [domain([1,2,3,4]) for i in 1:4] | ||
|
||
# allunique concept (that is used to define the :all_different constraint) | ||
err = explore_learn_compose(allunique, domains=doms) | ||
# > interpretation: identity ∘ count_positive ∘ sum ∘ count_eq_left | ||
|
||
# test our new error function | ||
@assert err([1,2,3,3], dom_size = 4) > 0.0 | ||
|
||
# export an all_different function to file "current/path/test_dummy.jl" | ||
compose_to_file!(icn, "all_different", "test_dummy.jl") | ||
``` | ||
|
||
The output file should produces a function that can be used as follows (assuming the maximum domain size is `7`) | ||
|
||
```julia | ||
import CompositionalNetworks | ||
|
||
all_different([1,2,3,4,5,6,7]; dom_size = 7) | ||
# > 0.0 (which means true, no errors) | ||
``` | ||
|
||
Please see `JuliaConstraints/Constraints.jl/learn.jl` for an extensive example of ICN learning and compositions. | ||
|
||
## Public interface | ||
|
||
```@autodocs | ||
Modules = [CompositionalNetworks] | ||
Private = false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Internal | ||
|
||
```@contents | ||
Pages = ["internal.md"] | ||
Depth = 5 | ||
``` | ||
|
||
```@autodocs | ||
Modules = [Constraints] | ||
Public = false | ||
``` |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Public | ||
|
||
```@contents | ||
Pages = ["public.md"] | ||
Depth = 5 | ||
``` | ||
|
||
```@autodocs | ||
Modules = [Constraints] | ||
Private = false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function _icn_all_different(x; param=nothing, dom_size) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_eq_left]) |> CompositionalNetworks._ar_prod |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_eq_right]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function _icn_all_equal(x; param=nothing, dom_size) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_identity]) |> CompositionalNetworks._ar_prod |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_euclidian(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_identity]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_euclidian(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function _icn_all_equal_param(x; param=nothing, dom_size) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_g_param]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_sum |> (y -> CompositionalNetworks._co_vars_minus_val(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
fill(x, 5) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_val_minus_param, CompositionalNetworks._tr_count_g_param, CompositionalNetworks._tr_count_l_right, CompositionalNetworks._tr_count_lesser, CompositionalNetworks._tr_count_eq]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function _icn_dist_different(x; param=nothing, dom_size) | ||
fill(x, 4) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_l_right, CompositionalNetworks._tr_count_lesser, CompositionalNetworks._tr_count_greater, CompositionalNetworks._tr_count_eq_left]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_vars_minus_val(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
fill(x, 4) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_l_left, CompositionalNetworks._tr_count_lesser, CompositionalNetworks._tr_count_greater, CompositionalNetworks._tr_count_eq_right]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_abs_diff_val_vars(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function _icn_eq(x; param=nothing, dom_size) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_greater]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_sum |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_lesser]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_sum |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function _icn_ordered(x; param=nothing, dom_size) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_count_l_right]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
fill(x, 1) .|> map(f -> (y -> f(y; param=param)), [CompositionalNetworks._tr_contiguous_vals_minus]) |> CompositionalNetworks._ar_sum |> CompositionalNetworks._ag_count_positive |> (y -> CompositionalNetworks._co_identity(y; param=param, dom_size=dom_size, nvars=length(x))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters