diff --git a/Project.toml b/Project.toml index e03923a..4204ceb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CompositionalNetworks" uuid = "4b67e4b5-442d-4ef5-b760-3f5df3a57537" authors = ["Jean-François Baffier"] -version = "0.3.2" +version = "0.3.3" [deps] ConstraintDomains = "5800fd60-8556-4464-8d61-84ebf7a0bedb" @@ -17,15 +17,15 @@ ThreadSafeDicts = "4239201d-c60e-5e0a-9702-85d713665ba7" Unrolled = "9602ed7d-8fef-5bc8-8597-8f21381861e8" [compat] -ConstraintDomains = "0.3" +ConstraintDomains = "0.3.1" Dictionaries = "0.3" Distances = "0.10" Evolutionary = "0.11" -JuliaFormatter = "0.22" +JuliaFormatter = "0.22, 1" Memoization = "0.1" OrderedCollections = "1" ThreadPools = "2" -ThreadSafeDicts = "0.0.6" +ThreadSafeDicts = "0.1" Unrolled = "0.1" julia = "1.6" diff --git a/src/CompositionalNetworks.jl b/src/CompositionalNetworks.jl index c84c66c..7119258 100644 --- a/src/CompositionalNetworks.jl +++ b/src/CompositionalNetworks.jl @@ -23,7 +23,6 @@ export compose export compose_to_file! export composition export composition_to_file! -export explore export explore_learn_compose export hamming export lazy @@ -55,7 +54,6 @@ include("composition.jl") # Genetic Algorithm and learning include("genetic.jl") -include("explore.jl") include("learn.jl") end diff --git a/src/explore.jl b/src/explore.jl deleted file mode 100644 index bc5a0de..0000000 --- a/src/explore.jl +++ /dev/null @@ -1,56 +0,0 @@ -""" - explore(domains, concept, param = nothing; search_limit = 1000, solutions_limit = 100) - -Search (a part of) a search space and returns a pair of vector of configurations: `(solutions, non_solutions)`. If the search space size is over `search_limit`, then both `solutions` and `non_solutions` are limited to `solutions_limit`. - -Beware that if the density of the solutions in the search space is low, `solutions_limit` needs to be reduced. This process will be automatic in the future (simple reinforcement learning). - -# Arguments: -- `domains`: a collection of domains -- `concept`: the concept of the targeted constraint -- `param`: an optional parameter of the constraint -- `sol_number`: the required number of solutions (half of the number of configurations), default to `100` -""" -function explore( - domains, - concept, - param=nothing; - search=:flexible, - complete_search_limit=10^6, - max_samplings=sum(domain_size, domains), - solutions_limit=floor(Int, sqrt(max_samplings)), -) - if search == :flexible - search = sum(domain_size, domains) < complete_search_limit ? :complete : :partial - end - return explore(Val(search), domains, concept, param, solutions_limit, max_samplings) -end - -function explore(::Val{:partial}, domains, concept, param, solutions_limit, max_samplings) - solutions = Set{Vector{Int}}() - non_sltns = Set{Vector{Int}}() - - f = isnothing(param) ? ((x; param = p) -> concept(x)) : concept - - for _ in 1:max_samplings - length(solutions) ≥ solutions_limit && length(non_sltns) ≥ solutions_limit && break - config = map(rand, domains) - c = f(config; param) ? solutions : non_sltns - length(c) < solutions_limit && push!(c, config) - end - return solutions, non_sltns -end - -function explore(::Val{:complete}, domains, concept, param, ::Int, ::Int) - solutions = Set{Vector{Int}}() - non_sltns = Set{Vector{Int}}() - - f = isnothing(param) ? ((x; param = p) -> concept(x)) : concept - - configurations = Base.Iterators.product(map(d -> get_domain(d), domains)...) - foreach( - c -> (cv = collect(c); push!(f(cv; param) ? solutions : non_sltns, cv)), - configurations, - ) - return solutions, non_sltns -end