1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-26 17:05:27 +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
immutable Settings
immutable Settings{T<:AbstractMathProgSolver}
name::String
N::Int
G::Group
S::Vector
autS::Group
radius::Int
solver::SCSSolver
solver::T
upper_bound::Float64
tol::Float64
end
@ -37,11 +37,13 @@ function OrbitData(sett::Settings)
splap² = similar(splap)
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")
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)
#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]);

View File

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

View File

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