@@ -6,10 +6,10 @@ struct ExploreSettings
6
6
end
7
7
8
8
"""
9
- ExploreSettings(domains;
10
- complete_search_limit = 10^6,
11
- max_samplings = sum(domain_size, domains),
12
- search = :flexible,
9
+ ExploreSettings(domains;
10
+ complete_search_limit = 10^6,
11
+ max_samplings = sum(domain_size, domains),
12
+ search = :flexible,
13
13
solutions_limit = floor(Int, sqrt(max_samplings)))
14
14
15
15
Create an `ExploreSettings` object to configure the exploration of a search space composed of a collection of domains.
@@ -26,10 +26,10 @@ Create an `ExploreSettings` object to configure the exploration of a search spac
26
26
"""
27
27
function ExploreSettings (
28
28
domains;
29
- complete_search_limit = 10 ^ 6 ,
30
- max_samplings = sum (domain_size, domains; init = 0 ),
31
- search = :flexible ,
32
- solutions_limit = floor (Int, sqrt (max_samplings)),
29
+ complete_search_limit= 10 ^ 6 ,
30
+ max_samplings= sum (domain_size, domains; init= 0 ),
31
+ search= :flexible ,
32
+ solutions_limit= floor (Int, sqrt (max_samplings)),
33
33
)
34
34
return ExploreSettings (complete_search_limit, max_samplings, search, solutions_limit)
35
35
end
@@ -54,8 +54,8 @@ mutable struct Explorer{F1<:Function,D<:AbstractDomain,F2<:Union{Function,Nothin
54
54
function Explorer (
55
55
concepts,
56
56
domains,
57
- objective = nothing ;
58
- settings = ExploreSettings (domains),
57
+ objective= nothing ;
58
+ settings= ExploreSettings (domains),
59
59
)
60
60
F1 = isempty (concepts) ? Function : Union{map (c -> typeof (c[1 ]), concepts)... }
61
61
D = isempty (domains) ? AbstractDomain : Union{map (typeof, domains)... }
@@ -76,7 +76,7 @@ function Explorer()
76
76
end
77
77
78
78
function Base. push! (explorer:: Explorer , concept:: Tuple{Function,Vector{Int}} )
79
- max_key = maximum (keys (explorer. concepts); init = 0 )
79
+ max_key = maximum (keys (explorer. concepts); init= 0 )
80
80
explorer. concepts[max_key+ 1 ] = concept
81
81
return max_key + 1
82
82
end
@@ -87,7 +87,7 @@ function delete_concept!(explorer::Explorer, key::Int)
87
87
end
88
88
89
89
function Base. push! (explorer:: Explorer , domain:: AbstractDomain )
90
- max_key = maximum (keys (explorer. domains); init = 0 )
90
+ max_key = maximum (keys (explorer. domains); init= 0 )
91
91
explorer. domains[max_key+ 1 ] = domain
92
92
return max_key + 1
93
93
end
99
99
100
100
set! (explorer:: Explorer , objective:: Function ) = explorer. objective = objective
101
101
102
- function update_exploration! (explorer, f, c, search = explorer. settings. search)
102
+ function update_exploration! (explorer, f, c, search= explorer. settings. search)
103
103
solutions = explorer. state. solutions
104
104
non_sltns = explorer. state. non_solutions
105
105
obj = explorer. objective
124
124
125
125
Internals of the `explore` function. Behavior is automatically adjusted on the kind of exploration: `:flexible`, `:complete`, `:partial`.
126
126
"""
127
- function _explore! (explorer, f, :: Val{:partial} )
127
+ function _explore! (explorer, f, :: Val{:partial} ; )
128
128
sl = explorer. settings. solutions_limit
129
129
ms = explorer. settings. max_samplings
130
130
@@ -174,13 +174,23 @@ Search (a part of) a search space and return a pair of vectors of configurations
174
174
# Returns
175
175
- A tuple of sets: `(solutions, non_solutions)`.
176
176
"""
177
- function explore (domains, concept; settings = ExploreSettings (domains), parameters... )
177
+ function explore (domains, concept; settings= ExploreSettings (domains), parameters... )
178
178
f = x -> concept (x; parameters... )
179
179
explorer = Explorer ([(f, Vector {Int} ())], domains; settings)
180
180
explore! (explorer)
181
181
return explorer. state. solutions, explorer. state. non_solutions
182
182
end
183
183
184
+ function _check! (explorer, configurations)
185
+ g =
186
+ x -> all ([
187
+ f (isempty (vars) ? x : @view x[vars]) for
188
+ (f, vars) in explorer. concepts |> values
189
+ ])
190
+ foreach (c -> update_exploration! (explorer, g, c, :complete ), configurations)
191
+ return nothing
192
+ end
193
+
184
194
# # SECTION - Test Items
185
195
@testitem " Exploration" tags = [:exploration ] begin
186
196
domains = [domain ([1 , 2 , 3 , 4 ]) for i = 1 : 4 ]
0 commit comments