1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-14 14:15:28 +01:00

parametrize Settings over {Naive, Symmetrized}

This commit is contained in:
kalmarek 2018-09-16 18:00:21 +02:00
parent 592f0bf7a5
commit afe845e911

View File

@ -21,11 +21,11 @@ import MathProgBase.SolverInterface.AbstractMathProgSolver
struct Symmetrize end
struct Naive end
struct Settings{T} where T<:Union{Symmetrize, Naive}
struct Settings{T, GEl<:GroupElem}
name::String
G::Group
S::Vector{GroupElem}
S::Vector{GEl}
radius::Int
solver::AbstractMathProgSolver
@ -37,18 +37,18 @@ struct Settings{T} where T<:Union{Symmetrize, Naive}
function Settings(name::String,
G::Group, S::Vector{GEl}, r::Int,
sol::Sol, ub, tol, ws) where
{GEl<:GroupElem, Sol<:AbstractMathProgSolver}
return new{Naive}(name, G, S, r, sol, ub, tol, ws)
sol::Sol, ub, tol, ws) where {GEl<:GroupElem, Sol<:AbstractMathProgSolver}
return new{Naive, GEl}(name, G, S, r, sol, ub, tol, ws)
end
function Settings(name::String,
G::Group, S::Vector{GEl}, r::Int,
sol::Sol, ub, tol, ws, autS) where {Gr, GEl, Sol}
return new{Symmetrize}(name, G, S, r, sol, ub, tol, ws, autS)
sol::Sol, ub, tol, ws, autS) where {GEl<:GroupElem, Sol<:AbstractMathProgSolver}
return new{Symmetrize, GEl}(name, G, S, r, sol, ub, tol, ws, autS)
end
end
prefix(s::Settings{Naive}) = s.name
prefix(s::Settings{Symmetrize}) = "o"*s.name
suffix(s::Settings) = "$(s.upper_bound)"
@ -77,10 +77,12 @@ filename(prefix, s::Symbol) = filename(prefix, Val{s})
end
end
function check_property_T(sett::Settings{$T})
if exists(filename(prepath(sett),:pm)) &&
exists(filename(prepath(sett),))
function check_property_T(sett::Settings)
fp = PropertyT.fullpath(sett)
isdir(fp) || mkpath(fp)
if isfile(filename(sett,))
# cached
Δ = loadLaplacian(prepath(sett), parent(sett.S[1]))
else