mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-12-25 02:15:29 +01:00
rework addconstraints! with progress printing
This commit is contained in:
parent
db55927729
commit
8a6707eddd
@ -127,24 +127,30 @@ function constrLHS(m::JuMP.Model, cnstr, Us, Ust, dims, vars, eps=100*eps(1.0))
|
||||
return @expression(m, sum(vecdot(M[π], vars[π]) for π in 1:endof(Us)))
|
||||
end
|
||||
|
||||
function addconstraints!(m::JuMP.Model, data::OrbitData, l::Int=length(data.laplacian); var::Symbol = :λ)
|
||||
λ = m[var]
|
||||
Ust = [U' for U in data.Us]
|
||||
for t in 1:l
|
||||
# lhs = constrLHS(m, data, t)
|
||||
lhs = constrLHS(m, data.cnstr[t], data.Us, Ust, data.dims, data.Ps)
|
||||
function addconstraints!(m::JuMP.Model, data::OrbitData, l::Int=length(data.laplacian); var::Symbol=:λ)
|
||||
λ = m[var]
|
||||
Ust = [U' for U in data.Us]
|
||||
idx = [π for π in 1:endof(data.Us) if size(data.Us[π],2) != 0]
|
||||
|
||||
d, d² = data.laplacian[t], data.laplacianSq[t]
|
||||
if lhs == zero(lhs)
|
||||
if d == 0 && d² == 0
|
||||
info("Detected empty constraint")
|
||||
continue
|
||||
else
|
||||
warn("Adding unsatisfiable constraint!")
|
||||
end
|
||||
end
|
||||
JuMP.@constraint(m, lhs == d² - λ*d)
|
||||
end
|
||||
for t in 1:l
|
||||
if t % 100 == 0
|
||||
print(t, ", ")
|
||||
end
|
||||
# lhs = constrLHS(m, data, t)
|
||||
lhs = constrLHS(m, data.cnstr[t], data.Us[idx], Ust[idx], data.dims[idx], data.Ps[idx])
|
||||
|
||||
d, d² = data.laplacian[t], data.laplacianSq[t]
|
||||
# if lhs == zero(lhs)
|
||||
# if d == 0 && d² == 0
|
||||
# info("Detected empty constraint")
|
||||
# continue
|
||||
# else
|
||||
# warn("Adding unsatisfiable constraint!")
|
||||
# end
|
||||
# end
|
||||
JuMP.@constraint(m, lhs == d² - λ*d)
|
||||
end
|
||||
println("")
|
||||
end
|
||||
|
||||
function init_model(Uπs)
|
||||
|
Loading…
Reference in New Issue
Block a user