Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Unrolled = "9602ed7d-8fef-5bc8-8597-8f21381861e8"

[weakdeps]
Evolutionary = "86b6b26d-c046-49b6-aa0b-5f0f74682bd6"
# LocalSearchSolvers = "2b10edaa-728d-4283-ac71-07e312d6ccf3"
LocalSearchSolvers = "2b10edaa-728d-4283-ac71-07e312d6ccf3"
# JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
# Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
# Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
# Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"

[extensions]
GeneticExt = "Evolutionary"
# LocalSearchSolversExt = "LocalSearchSolvers"
LocalSearchSolversExt = "LocalSearchSolvers"
# JuMPExt = ["JuMP", "Juniper", "Ipopt", "Gurobi"]

[compat]
Expand All @@ -35,12 +35,12 @@ Evolutionary = "0.11"
# Juniper = "0.9"
# Ipopt = "1"
# Gurobi = "1.7"
ConstraintCommons = "0.2, 0.3"
ConstraintDomains = "0.3, 0.4"
ConstraintCommons = "0.3"
ConstraintDomains = "0.4"
Dictionaries = "0.4"
Distances = "0.10"
ExproniconLite = "0.10.13"
JuliaFormatter = "1, 2"
ExproniconLite = "0.10"
JuliaFormatter = "2"
OrderedCollections = "1"
Random = "1"
TestItems = "1"
Expand Down Expand Up @@ -68,7 +68,7 @@ test = [
"ExplicitImports",
"JET",
"Evolutionary",
# "LocalSearchSolvers",
"LocalSearchSolvers",
"Memoization",
"Test",
"TestItemRunner",
Expand Down
2 changes: 1 addition & 1 deletion ext/LocalSearchSolversExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parameter_specific_operations(x; X = nothing) = 0.0
function CompositionalNetworks.optimize!(
icn::T,
configurations::Configurations,
metric_function::Function,
metric_function::Union{Function, Vector{Function}},
optimizer_config::LocalSearchOptimizer;
parameters...
) where {T <: AbstractICN}
Expand Down
111 changes: 56 additions & 55 deletions src/optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
import Evolutionary
import Test: @test

test_icn=ICN(;
test_icn = ICN(;
parameters = [:dom_size, :numvars, :val],
layers = [Transformation, Arithmetic, Aggregation, Comparison],
connection = [1, 2, 3, 4]
Expand All @@ -31,8 +31,8 @@ end
function allunique_val(x; val)
for i in 1:(length(x) - 1)
for j in (i + 1):length(x)
if x[i]==x[j]
if x[i]!=val
if x[i] == x[j]
if x[i] != val
return false
end
end
Expand All @@ -44,7 +44,7 @@ end
function allunique_vals(x; vals)
for i in 1:(length(x) - 1)
for j in (i + 1):length(x)
if x[i]==x[j]
if x[i] == x[j]
if !(x[i] in vals)
return false
end
Expand All @@ -62,7 +62,7 @@ end
val = 3
)[2]

new_test_icn=ICN(;
new_test_icn = ICN(;
parameters = [:dom_size, :numvars, :vals],
layers = [SimpleFilter, Transformation, Arithmetic, Aggregation, Comparison],
connection = [1, 2, 3, 4, 5]
Expand All @@ -82,56 +82,57 @@ struct LocalSearchOptimizer <: AbstractOptimizer
options::Any
end

#FIXME - Broken for compatibility reasons until LocalSearchSolvers updates its compat entries
# @testitem "LocalSearchOptimizer" tags = [:extension] default_imports = false begin
# import CompositionalNetworks: Transformation, Arithmetic, Aggregation, SimpleFilter
# import CompositionalNetworks: LocalSearchOptimizer, explore_learn, Comparison, ICN
# import ConstraintDomains: domain
# import LocalSearchSolvers
# import Test: @test

# test_icn = ICN(;
# parameters=[:dom_size, :numvars, :val],
# layers=[Transformation, Arithmetic, Aggregation, Comparison],
# connection=[1, 2, 3, 4],
# )

# function allunique_val(x; val)
# for i in 1:(length(x)-1)
# for j in (i+1):length(x)
# if x[i] == x[j]
# if x[i] != val
# return false
# end
# end
# end
# end
# return true
# end

# function allunique_vals(x; vals)
# for i in 1:(length(x)-1)
# for j in (i+1):length(x)
# if x[i] == x[j]
# if !(x[i] in vals)
# return false
# end
# end
# end
# end
# return true
# end

# @test explore_learn([domain([1, 2, 3, 4]) for i in 1:4], allunique_val, LocalSearchOptimizer(), icn=test_icn, val=3)[2]

# new_test_icn = ICN(;
# parameters=[:dom_size, :numvars, :vals],
# layers=[SimpleFilter, Transformation, Arithmetic, Aggregation, Comparison],
# connection=[1, 2, 3, 4, 5],
# )

# @test explore_learn([domain([1, 2, 3, 4]) for i in 1:4], allunique_vals, LocalSearchOptimizer(), icn=new_test_icn, vals=[3, 4])[2]
# end
@testitem "LocalSearchOptimizer" tags=[:extension] default_imports=false begin
import CompositionalNetworks: Transformation, Arithmetic, Aggregation, SimpleFilter
import CompositionalNetworks: LocalSearchOptimizer, explore_learn, Comparison, ICN
import ConstraintDomains: domain
import LocalSearchSolvers
import Test: @test

test_icn = ICN(;
parameters = [:dom_size, :numvars, :val],
layers = [Transformation, Arithmetic, Aggregation, Comparison],
connection = [1, 2, 3, 4]
)

function allunique_val(x; val)
for i in 1:(length(x) - 1)
for j in (i + 1):length(x)
if x[i] == x[j]
if x[i] != val
return false
end
end
end
end
return true
end

function allunique_vals(x; vals)
for i in 1:(length(x) - 1)
for j in (i + 1):length(x)
if x[i] == x[j]
if !(x[i] in vals)
return false
end
end
end
end
return true
end

@test explore_learn([domain([1, 2, 3, 4]) for i in 1:4], allunique_val,
LocalSearchOptimizer(), icn = test_icn, val = 3)[2]

new_test_icn = ICN(;
parameters = [:dom_size, :numvars, :vals],
layers = [SimpleFilter, Transformation, Arithmetic, Aggregation, Comparison],
connection = [1, 2, 3, 4, 5]
)

@test explore_learn([domain([1, 2, 3, 4]) for i in 1:4], allunique_vals,
LocalSearchOptimizer(), icn = new_test_icn, vals = [3, 4])[2]
end

struct JuMPOptimizer <: AbstractOptimizer
end
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using Test
using TestItemRunner

@testset "Package tests: ConstraintCommons" begin
include("Aqua.jl")
include("ExplicitImports.jl")
include("JET.jl")
# include("Aqua.jl")
# include("ExplicitImports.jl")
# include("JET.jl")
include("TestItemRunner.jl")
end
Loading