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

Merge remote-tracking branch 'origin/enh/warmstart' into enh/warmstart-0.6

# Conflicts:
#	src/OrbitDecomposition.jl
This commit is contained in:
kalmarek 2017-12-01 14:21:10 +01:00
commit 10808583e3
4 changed files with 23 additions and 18 deletions

View File

@ -3,14 +3,14 @@ using SCS
export Settings, OrbitData export Settings, OrbitData
immutable Settings immutable Settings{T<:AbstractMathProgSolver}
name::String name::String
N::Int N::Int
G::Group G::Group
S::Vector S::Vector
autS::Group autS::Group
radius::Int radius::Int
solver::SCSSolver solver::T
upper_bound::Float64 upper_bound::Float64
tol::Float64 tol::Float64
end end
@ -37,11 +37,13 @@ function OrbitData(sett::Settings)
splap² = similar(splap) splap² = similar(splap)
splap² = GroupRings.mul!(splap², splap, splap, pm); splap² = GroupRings.mul!(splap², splap, splap, pm);
# Uπs = load(joinpath(name, "U_pis.jld"), "Uπs");
Uπs = load(joinpath(prepath(sett), "U_pis.jld"), "Uπs") Uπs = load(joinpath(prepath(sett), "U_pis.jld"), "Uπs")
nzros = [i for i in 1:length(Uπs) if size(Uπs[i],2) !=0]
Uπs = Uπs[nzros]
Uπs = sparsify!.(Uπs, sett.tol, check=true, verbose=true) Uπs = sparsify!.(Uπs, sett.tol, check=true, verbose=true)
#dimensions of the corresponding πs: #dimensions of the corresponding πs:
dims = load(joinpath(prepath(sett), "U_pis.jld"), "dims") dims = load(joinpath(prepath(sett), "U_pis.jld"), "dims")[nzros]
m, P = init_model(size(Uπs,1), [size(U,2) for U in Uπs]); m, P = init_model(size(Uπs,1), [size(U,2) for U in Uπs]);

View File

@ -136,13 +136,8 @@ function perm_reps(S::Vector, autS::Group, radius::Int)
return perm_reps(autS, E) return perm_reps(autS, E)
end end
function reconstruct_sol{T<:GroupElem}(preps::Dict{T, Generic.perm}, function reconstruct_sol{T<:GroupElem, S<:Nemo.perm}(preps::Dict{T, S},
aUs::Vector, aPs::Vector, adims::Vector) Us::Vector, Ps::Vector, dims::Vector)
idx = [π for π in 1:length(aUs) if size(aUs[π], 2) != 0]
Us = aUs[idx]
Ps = aPs[idx]
dims = adims[idx];
l = length(Us) l = length(Us)
transfP = [dims[π].*Us[π]*Ps[π]*Us[π]' for π in 1:l] transfP = [dims[π].*Us[π]*Ps[π]*Us[π]' for π in 1:l]

View File

@ -22,6 +22,11 @@ end
Nemo.isone(p::GroupElem) = p == parent(p)() Nemo.isone(p::GroupElem) = p == parent(p)()
function Nemo.dim(χ::PropertyT.PermCharacter)
G = PermutationGroup(sum(χ.p))
return χ(G())
end
## NOTE: this works only for Z/2!!!! ## NOTE: this works only for Z/2!!!!
function (chi::DirectProdCharacter)(g::DirectProductGroupElem) function (chi::DirectProdCharacter)(g::DirectProductGroupElem)
return reduce(*, 1, ((-1)^isone(g.elts[j]) for j in 1:chi.i)) return reduce(*, 1, ((-1)^isone(g.elts[j]) for j in 1:chi.i))

View File

@ -137,16 +137,12 @@ function λandP(name::String)
end end
function λandP(name::String, SDP_problem::JuMP.Model, varλ, varP) function λandP(name::String, SDP_problem::JuMP.Model, varλ, varP)
if exists(joinpath(name, "solver.log"))
rm(joinpath(name, "solver.log"))
end
add_handler(solver_logger, add_handler(solver_logger,
DefaultHandler(joinpath(name, "solver_$(string(now())).log"), DefaultHandler(joinpath(name, "solver_$(string(now())).log"),
DefaultFormatter("{date}| {msg}")), DefaultFormatter("{date}| {msg}")),
"solver_log") "solver_log")
λ, P = compute_λandP(SDP_problem, varλ, varP) λ, P, warmstart = compute_λandP(SDP_problem, varλ, varP)
remove_handler(solver_logger, "solver_log") remove_handler(solver_logger, "solver_log")
@ -155,6 +151,8 @@ function λandP(name::String, SDP_problem::JuMP.Model, varλ, varP)
if λ > 0 if λ > 0
save(λ_fname, "λ", λ) save(λ_fname, "λ", λ)
save(P_fname, "P", P) save(P_fname, "P", P)
@show warmstart[1]
save(joinpath(name, "warmstart.jld"), "warmstart", warmstart)
else else
throw(ErrorException("Solver did not produce a valid solution!: λ = ")) throw(ErrorException("Solver did not produce a valid solution!: λ = "))
end end
@ -162,7 +160,7 @@ function λandP(name::String, SDP_problem::JuMP.Model, varλ, varP)
end end
function compute_λandP(m, varλ, varP) function compute_λandP(m, varλ, varP; warmstart=nothing)
λ = 0.0 λ = 0.0
P = nothing P = nothing
while λ == 0.0 while λ == 0.0
@ -170,11 +168,16 @@ function compute_λandP(m, varλ, varP)
solve_SDP(m) solve_SDP(m)
λ = JuMP.getvalue(varλ) λ = JuMP.getvalue(varλ)
P = JuMP.getvalue(varP) P = JuMP.getvalue(varP)
p_sol = m.internalModel.primal_sol
d_sol = m.internalModel.dual_sol
s = m.internalModel.slack
catch y catch y
warn(solver_logger, y) warn(solver_logger, y)
end end
end end
return λ, P return λ, P, (p_sol, d_sol, s)
end end
Kazhdan_from_sgap(λ,N) = sqrt(2*λ/N) Kazhdan_from_sgap(λ,N) = sqrt(2*λ/N)