use Settings type to pass arguments

This commit is contained in:
kalmar 2017-06-08 21:35:27 +02:00
parent e868312a2a
commit 2859602639
3 changed files with 26 additions and 10 deletions

View File

@ -102,7 +102,9 @@ function main()
solver = SCS.SCSSolver(eps=tol, max_iters=iterations, verbose=true, linearsolver=SCS.Indirect)
orbit_check_propertyT(logger, dirname, G, S, AutS, solver, upper_bound)
sett = Settings(dirname, N, G, S, AutS, radius, solver, upper_bound, tol)
orbit_check_propertyT(logger, sett)
end
main()

View File

@ -20,6 +20,18 @@ immutable ProblemData{T}
dims::Vector{Int}
end
immutable Settings
name::String
N::Int
G::Group
S::Vector
AutS::Group
radius::Int
solver::SCSSolver
upper_bound::Float64
tol::Float64
end
function sparsify!{T}(U::AbstractArray{T}, eps=eps(T))
# n = rank(U)
U[abs.(U) .< eps] = zero(T)
@ -151,20 +163,20 @@ function init_orbit_data{T<:Nemo.GroupElem}(logger, name::String, G::Nemo.Group,
return 0
end
function orbit_check_propertyT(logger, dirname, G, S, AutS, solver, upper_bound)
function orbit_check_propertyT(logger, sett::Settings)
init_orbit_data(logger, dirname, G, S, AutS; radius=2)
init_orbit_data(logger, sett, radius=sett.radius)
Δ = PropertyT.ΔandSDPconstraints(name, G)[1]
Δ = float(PropertyT.ΔandSDPconstraints(sett.name, sett.G)[1])
fnames = PropertyT.λSDPfilenames(dirname)
fnames = PropertyT.λSDPfilenames(sett.name)
if all(isfile.(fnames))
λ, P = PropertyT.λandP(dirname)
λ, P = PropertyT.λandP(sett.name)
else
info(logger, "Creating SDP problem...")
SDP_problem, orb_data = create_SDP_problem(dirname, upper_bound=upper_bound)
JuMP.setsolver(SDP_problem, solver)
SDP_problem, orb_data = create_SDP_problem(sett.name, upper_bound=sett.upper_bound)
JuMP.setsolver(SDP_problem, sett.solver)
λ, P = λandP(SDP_problem, orb_data)
end
@ -174,7 +186,7 @@ function orbit_check_propertyT(logger, dirname, G, S, AutS, solver, upper_bound)
info(PropertyT.logger, "minimum(P) = $(minimum(P))")
if λ > 0
sgap = PropertyT.check_distance_to_positive_cone(Δ, λ, P, tol=tol, rational=false, len=2*radius)
sgap = PropertyT.check_distance_to_positive_cone(Δ, λ, P, tol=sett.tol, rational=false, len=2*sett.radius)
if isa(sgap, Interval)
sgap = sgap.lo
end

View File

@ -139,7 +139,9 @@ function main()
solver = SCS.SCSSolver(eps=tol, max_iters=iterations, verbose=true, linearsolver=SCS.Indirect)
orbit_check_propertyT(logger, dirname, G, S, AutS, solver, upper_bound)
sett = Settings(dirname, N, G, S, AutS, radius, solver, upper_bound, tol)
orbit_check_propertyT(logger, sett)
end
main()