-
Notifications
You must be signed in to change notification settings - Fork 24
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
Integrate polynomial over specified domain #267
Comments
Here's something that appears to work to some extent. I'm completely unfamiliar with this ecosystem of types, so I might not use the correct functions and types everywhere. function integrate(p::Polynomial{C, T}, x::PolyVar{C}, l, u) where {C, T}
# grlex order preserved
i = something(findfirst(isequal(x), DynamicPolynomials._vars(p)), 0)
S = typeof(zero(T) * 0)
Z = copy.(p.x.Z)
a = Vector{S}(undef, length(Z))
for j in 1:length(Z)
Z[j][i] += 1
a[j] = p.a[j] / Z[j][i]
end
intpoly = Polynomial(a, MonomialVector(DynamicPolynomials._vars(p), Z))
subs(intpoly, x=>u) - subs(intpoly, x=>l)
end My remaining problem is that I'd like to use the integral of a polynomial as a cost function for optimization (maximize the area under a Lyapunov function) and I just can't figure out how to express this yet |
You can find here code to integrate a multivariate polynomial over a hyperrectangle or arbitrary polytope: https://github.com/blegat/SetProg.jl/blob/master/src/L1_heuristic.jl |
Thanks for the link and the clever trick :) The problem I had with having the integral of the polynomial as the objective could be worked around by this trivial trick # @objective(model, Max, ∫J) # What I would like to do
@variable(model, t)
@objective(model, Max, t)
@constraint(model, ∫J == t) it seems JuMP needs to be taught how to have a polynomial as objective? |
With SumOfSquares, the decision variables are the JuMP variables that you create with |
I'm looking for functionality akin to
integrate(poly, x, lb, ub)
i.e., to express the integral
$$\int_{l}^{u} p(x) dx$$ where $p(x)$ is a polynomial. Similar to YALMIP
int
Scanning through the docs, I can't find this available. Is this supported by some of the polynomial packages that are supported by SumOfSquares.jl?
The text was updated successfully, but these errors were encountered: