-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SubBasis #61
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
- Coverage 85.93% 84.12% -1.82%
==========================================
Files 14 13 -1
Lines 761 781 +20
==========================================
+ Hits 654 657 +3
- Misses 107 124 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
k = findfirst(==(x), supp(b)) | ||
isnothing(k) && throw("x=$x is not supported on SubBasis") | ||
@info T I | ||
return convert(I, k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be convert(I, b.parent_basis[b.supporting_elts[x]])
because we store the indices
Base.IteratorSize(::Type{<:FixedBasis}) = Base.HasLength() | ||
Base.length(b::FixedBasis) = length(b.elts) | ||
struct SubBasis{T,I,V,B<:AbstractBasis{T,I}} <: FiniteSupportBasis{T,I} | ||
supporting_elts::V |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the list of indices of the parent_basis
. For DiracBasis
, since indices are the same as elements, it works as well
@blegat I was pondering this topic over and over; At the moment what we have is
We need to add/multiply
It seems that all of this can be achieved on the level of coefficients. |
Good question. I definitely need an |
@blegat, I'm not sure what do you mean by
Nowhere there do we form a product Here's some newly updated code that make use of import StarAlgebras as SA
let X = .... # AlgebraElement for a StarAlgebra of FPMonoid (infinite dimensional, DiracBasis)
A = parent(elts)
unit = one(A)
# compute somehow a set of elements from `basis(A)` where dual sos-problem for X makes sense.
linsupp, sizes = linear_supp(X, unit)
B = SA.FixedBasis(linsupp, SA.mstructure(SA.basis(A)))
# length(word(x)) corresponds to degree of polynomials
N = maximum(x -> sizes[length(FPMonoids.word(x))÷2], linsupp)
mt = let psd_basis = @view linsupp[1:N] # linsupp is ordered by word-length
# here we use DiracMStructure of `B` and `mt` is `Matrix{<:Integer}`
mt = [B[star(x)*y] for x in psd_basis, y in psd_basis]
end
model = JuMP.Model()
# y is a vector of variables in basis `B`!
y = @variable model y[1:length(B)]
@objective model Max dot(coeffs(X, B), y) # max dot(X, y)
@constraint model dot(coeffs(unit, B), y) == 1 # given a normalized `y`
let P = @view y[mt]
@constraint model P in PSDCone() # and mt defines a psd matrix
end
return model
end see also https://github.com/kalmarek/QuantumStuff.jl/blob/mk/new_fpmonoids/src/psd_problems.jl |
Thanks, I'll play around with while trying to update jump-dev/SumOfSquares.jl#375 |
@blegat