Skip to content
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

#87 - Better error messages #90

Merged
merged 4 commits into from
Jun 26, 2022
Merged

#87 - Better error messages #90

merged 4 commits into from
Jun 26, 2022

Conversation

schillic
Copy link
Member

Closes #87.

  • adds error messages when trying to use an algorithm that requires to load an external library (see example below)
    • The new require function is borrowed from LazySets and is planned to be outsourced to a Base package soon.
    • For the SOS algorithm I created a new file because the existing file uses macros and these do not go so well with Requires (there may be a way to avoid that, but 🤷).
    • For the MSE algorithm we use a type from the external library in the default argument of the struct. I defined an internal variable (_default_vector_MSE) holding that default algorithm, which is then overwritten when the package is loaded.
  • unexports the abstract types
  • fixes the polynomial example in the docs, which was forgotten in update sdp and polynomial interface #83
  • adds a plot of the example to the README
  • minor polishing
julia> using RangeEnclosures


# new: error messages

julia> enclose(x -> -x^3/6 + 5x, 1 .. 4, MooreSkelboeEnclosure())
ERROR: AssertionError: package 'IntervalOptimisation' not loaded (it is required for executing `enclose`)

julia> enclose(x -> -x^3/6 + 5x, 1 .. 4, SumOfSquaresEnclosure(backend=nothing))
ERROR: AssertionError: package 'SumOfSquares' not loaded (it is required for executing `enclose`)

julia> enclose(x -> -x^3/6 + 5x, 1 .. 4, TaylorModelsEnclosure())
ERROR: AssertionError: package 'TaylorModels' not loaded (it is required for executing `enclose`)


# after loading the packages, the behavior is as before

juli> using IntervalOptimisation, SumOfSquares, SDPA, DynamicPolynomials, TaylorModels

julia> enclose(x -> -x^3/6 + 5x, 1 .. 4, MooreSkelboeEnclosure())
[4.83299, 10.5448]

julia> backend = SDPA.Optimizer;
julia> @polyvar x;
julia> enclose(-x^3/6 + 5x, 1..4, SumOfSquaresEnclosure(; backend=backend))
[4.83333, 10.541]

julia> enclose(x -> -x^3/6 + 5x, 1 .. 4, TaylorModelsEnclosure())
[4.27083, 12.7084]

@lucaferranti
Copy link
Member

For the SOS algorithm I created a new file because the existing file uses macros and these do not go so well with Requires

what macros does it use? I think we got rid of @polyvar at some point?

@schillic
Copy link
Member Author

what macros does it use?

B = reduce(intersect, @set inf(domi) <= xi && xi <= sup(domi) for (xi, domi) in zip(x, dom))
# ============
# Upper bound
# ============
model = SOSModel(sose.backend, kwargs...)
@variable(model, γ) # JuMP decision variable
@constraint(model, p <= γ, domain=B, maxdegree=sose.order)
@objective(model, Min, γ)

@lucaferranti
Copy link
Member

right 😅

@schillic schillic merged commit 2db5fe1 into master Jun 26, 2022
@schillic schillic deleted the schillic/87 branch June 26, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HeapedVector not defined
3 participants