mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-12-25 02:15:29 +01:00
Cleanup of the check_propertyT function
This commit is contained in:
parent
a180025dc0
commit
f487c4635c
@ -46,13 +46,21 @@ function ΔandSDPconstraints(name::String)
|
|||||||
return Δ, sdp_constraints
|
return Δ, sdp_constraints
|
||||||
end
|
end
|
||||||
|
|
||||||
function ΔandSDPconstraints(name::String, generating_set::Function)
|
function ΔandSDPconstraints(name::String, generating_set::Function, radius::Int)
|
||||||
pm_fname, Δ_fname = pmΔfilenames(name)
|
try
|
||||||
S, ID = generating_set()
|
return ΔandSDPconstraints(name)
|
||||||
Δ, sdp_constraints = Main.ΔandSDPconstraints(ID, S)
|
catch err
|
||||||
save(pm_fname, "pm", Δ.product_matrix)
|
if isa(err, ArgumentError)
|
||||||
save(Δ_fname, "Δ", Δ.coefficients)
|
pm_fname, Δ_fname = pmΔfilenames(name)
|
||||||
return Δ, sdp_constraints
|
S, Id = generating_set()
|
||||||
|
Δ, sdp_constraints = Main.ΔandSDPconstraints(Id, S, radius)
|
||||||
|
save(pm_fname, "pm", Δ.product_matrix)
|
||||||
|
save(Δ_fname, "Δ", Δ.coefficients)
|
||||||
|
return Δ, sdp_constraints
|
||||||
|
else
|
||||||
|
error(logger, err)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function κandA(name::String)
|
function κandA(name::String)
|
||||||
@ -78,14 +86,43 @@ function timed_msg(t)
|
|||||||
return "took: $elapsed s, allocated: $bytes_alloc bytes ($(gc_diff.poolalloc) allocations)."
|
return "took: $elapsed s, allocated: $bytes_alloc bytes ($(gc_diff.poolalloc) allocations)."
|
||||||
end
|
end
|
||||||
|
|
||||||
function κandA(name::String, sdp_constraints, Δ::GroupAlgebraElement, solver::AbstractMathProgSolver; upper_bound=Inf)
|
|
||||||
if isfile("$name/solver.log")
|
function κandA(name::String, opts...)
|
||||||
rm("$name/solver.log")
|
try
|
||||||
|
return κandA(name)
|
||||||
|
catch err
|
||||||
|
if isa(err, ArgumentError)
|
||||||
|
if isfile("$name/solver.log")
|
||||||
|
rm("$name/solver.log")
|
||||||
|
end
|
||||||
|
|
||||||
|
add_handler(solver_logger, DefaultHandler("./$name/solver.log", DefaultFormatter("{date}| {msg}")), "solver_log")
|
||||||
|
|
||||||
|
info(logger, "Creating SDP problem...")
|
||||||
|
|
||||||
|
return compute_κandA(opts...)
|
||||||
|
|
||||||
|
remove_handler(solver_logger, "solver_log")
|
||||||
|
|
||||||
|
κ_fname, A_fname = κSDPfilenames(name)
|
||||||
|
|
||||||
|
if κ > 0
|
||||||
|
save(κ_fname, "κ", κ)
|
||||||
|
save(A_fname, "A", A)
|
||||||
|
else
|
||||||
|
throw(ErrorException("Solver $solver did not produce a valid solution!: κ = $κ"))
|
||||||
|
end
|
||||||
|
return κ, A
|
||||||
|
|
||||||
|
else
|
||||||
|
# throw(err)
|
||||||
|
error(logger, err)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
add_handler(solver_logger, DefaultHandler("./$name/solver.log", DefaultFormatter("{date}| {msg}")), "solver_log")
|
function compute_κandA(sdp_constraints, Δ::GroupAlgebraElement, solver::AbstractMathProgSolver; upper_bound=Inf)
|
||||||
|
|
||||||
info(logger, "Creating SDP problem...")
|
|
||||||
t = @timed SDP_problem = create_SDP_problem(sdp_constraints, Δ; upper_bound=upper_bound)
|
t = @timed SDP_problem = create_SDP_problem(sdp_constraints, Δ; upper_bound=upper_bound)
|
||||||
info(logger, timed_msg(t))
|
info(logger, timed_msg(t))
|
||||||
|
|
||||||
@ -98,16 +135,6 @@ function κandA(name::String, sdp_constraints, Δ::GroupAlgebraElement, solver::
|
|||||||
warn(solver_logger, y)
|
warn(solver_logger, y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_handler(solver_logger, "solver_log")
|
|
||||||
|
|
||||||
κ_fname, A_fname = κSDPfilenames(name)
|
|
||||||
if κ > 0
|
|
||||||
save(κ_fname, "κ", κ)
|
|
||||||
save(A_fname, "A", A)
|
|
||||||
else
|
|
||||||
throw(ErrorException("Solver $solver did not produce a valid solution!: κ = $κ"))
|
|
||||||
end
|
|
||||||
return κ, A
|
return κ, A
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -124,30 +151,14 @@ function check_property_T(name::String, generating_set::Function,
|
|||||||
info(logger, "Precision: $tol")
|
info(logger, "Precision: $tol")
|
||||||
info(logger, "Upper bound: $upper_bound")
|
info(logger, "Upper bound: $upper_bound")
|
||||||
|
|
||||||
Δ, sdp_constraints = try
|
Δ, sdp_constraints = ΔandSDPconstraints(name, generating_set, radius)
|
||||||
ΔandSDPconstraints(name)
|
|
||||||
catch err
|
|
||||||
if isa(err, ArgumentError)
|
|
||||||
ΔandSDPconstraints(name, generating_set)
|
|
||||||
else
|
|
||||||
error(logger, err)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
S = countnz(Δ.coefficients) - 1
|
S = countnz(Δ.coefficients) - 1
|
||||||
info(logger, "|S| = $S")
|
info(logger, "|S| = $S")
|
||||||
info(logger, "length(Δ) = $(length(Δ))")
|
info(logger, "length(Δ) = $(length(Δ))")
|
||||||
info(logger, "size(Δ.product_matrix) = $(size(Δ.product_matrix))")
|
info(logger, "size(Δ.product_matrix) = $(size(Δ.product_matrix))")
|
||||||
|
|
||||||
κ, A = try
|
κ, A = κandA(name, sdp_constraints, Δ, solver; upper_bound=upper_bound)
|
||||||
κandA(name)
|
|
||||||
catch err
|
|
||||||
if isa(err, ArgumentError)
|
|
||||||
κandA(name, sdp_constraints, Δ, solver; upper_bound=upper_bound)
|
|
||||||
else
|
|
||||||
# throw(err)
|
|
||||||
error(logger, err)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
info(logger, "κ = $κ")
|
info(logger, "κ = $κ")
|
||||||
info(logger, "sum(A) = $(sum(A))")
|
info(logger, "sum(A) = $(sum(A))")
|
||||||
|
Loading…
Reference in New Issue
Block a user