mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2025-01-04 20:50:30 +01:00
streamline constraints generation
and make it a bit less dependent on the ordering of elements in basis
This commit is contained in:
parent
d1a58d3890
commit
66f10612de
@ -156,12 +156,8 @@ function constraints(
|
|||||||
mstr::StarAlgebras.MultiplicativeStructure;
|
mstr::StarAlgebras.MultiplicativeStructure;
|
||||||
augmented = false,
|
augmented = false,
|
||||||
)
|
)
|
||||||
cnstrs = _constraints(
|
id = basis[one(first(basis))]
|
||||||
mstr;
|
cnstrs = _constraints(mstr; augmented = augmented, id = mstr[id, id])
|
||||||
augmented = augmented,
|
|
||||||
num_constraints = length(basis),
|
|
||||||
id = basis[one(first(basis))],
|
|
||||||
)
|
|
||||||
|
|
||||||
return Dict(
|
return Dict(
|
||||||
basis[i] => ConstraintMatrix(c, size(mstr)..., 1) for
|
basis[i] => ConstraintMatrix(c, size(mstr)..., 1) for
|
||||||
@ -172,11 +168,11 @@ end
|
|||||||
function _constraints(
|
function _constraints(
|
||||||
mstr::StarAlgebras.MultiplicativeStructure;
|
mstr::StarAlgebras.MultiplicativeStructure;
|
||||||
augmented::Bool = false,
|
augmented::Bool = false,
|
||||||
num_constraints = maximum(mstr),
|
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
cnstrs = [signed(eltype(mstr))[] for _ in 1:num_constraints]
|
cnstrs = [signed(eltype(mstr))[] for _ in 1:maximum(mstr)]
|
||||||
LI = LinearIndices(size(mstr))
|
LI = LinearIndices(size(mstr))
|
||||||
|
id_ = mstr[id, id]
|
||||||
|
|
||||||
for ci in CartesianIndices(size(mstr))
|
for ci in CartesianIndices(size(mstr))
|
||||||
k = LI[ci]
|
k = LI[ci]
|
||||||
@ -185,8 +181,8 @@ function _constraints(
|
|||||||
push!(cnstrs[a_star_b], k)
|
push!(cnstrs[a_star_b], k)
|
||||||
if augmented
|
if augmented
|
||||||
# (1-a)'(1-b) = 1 - a' - b + a'b
|
# (1-a)'(1-b) = 1 - a' - b + a'b
|
||||||
push!(cnstrs[id], k)
|
push!(cnstrs[id_], k)
|
||||||
a_star, b = mstr[-i, id], j
|
a_star, b = mstr[-i, id], mstr[j, id]
|
||||||
push!(cnstrs[a_star], -k)
|
push!(cnstrs[a_star], -k)
|
||||||
push!(cnstrs[b], -k)
|
push!(cnstrs[b], -k)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user