Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/CanonicalMoments/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
RecurrenceRelationships = "807425ed-42ea-44d6-a357-6771516d7b2c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLPublic = "431bcebd-1456-4ced-9d72-93c2757fff0b"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[weakdeps]
Expand Down Expand Up @@ -38,6 +39,7 @@ Random = "1.10"
RecurrenceRelationships = "0.2"
Reexport = "1.2.2"
SafeTestsets = "0.1"
SciMLPublic = "1"
SpecialFunctions = "2"
StaticArrays = "1"
Statistics = "1.10"
Expand Down
12 changes: 9 additions & 3 deletions lib/CanonicalMoments/src/CanonicalMoments.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module CanonicalMoments

using Polynomials, LinearAlgebra, RecurrenceRelationships, Reexport
using Polynomials: Polynomials, AbstractPolynomial, Polynomial, coeffs
using LinearAlgebra: LinearAlgebra, SymTridiagonal
using RecurrenceRelationships: forwardrecurrence
using Reexport: @reexport
using SciMLPublic: @public

@reexport using DiscreteMeasures

import Base: isapprox, inv, denominator, numerator
import Base: isapprox, denominator, numerator
import Statistics: mean
import LinearAlgebra: issymmetric
import DiscreteMeasures: support, weights
import Polynomials: denominator, numerator

function DEFAULT_ROOT_SOLVER(C, args...; kwargs...)
return if length(C) == 3 # 2nd order
Expand Down Expand Up @@ -47,6 +50,9 @@ export StieltjesTransform, denominator, numerator
include("measure_transform_algs.jl")
export PolyRootsSupportAlg, EigvalSupportAlg
export LinearSolveWeightAlg, PolyWeightAlg, EigvecWeightAlg
# Documented supertypes of the support/weight algorithms; part of the public API
# (used as the `support_alg`/`weight_alg` field types downstream) but not exported.
@public AbstractSupportAlg, AbstractWeightAlg

include("measure_transforms.jl")
export DiscreteMeasureTransform1
Expand Down
2 changes: 2 additions & 0 deletions lib/CanonicalMoments/test/qa/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CanonicalMoments = "58d2c334-1a3c-4862-bb37-9012b9e58a38"
DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
Expand All @@ -14,5 +15,6 @@ Aqua = "0.8"
CanonicalMoments = "0.1"
DiscreteMeasures = "0.1"
JET = "0.9, 0.10, 0.11"
SciMLTesting = "1.7"
Test = "1"
julia = "1.10"
22 changes: 11 additions & 11 deletions lib/CanonicalMoments/test/qa/qa.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using CanonicalMoments
using Aqua
using JET
using Test
using SciMLTesting, CanonicalMoments, JET, Test

@testset "Aqua" begin
Aqua.test_all(CanonicalMoments)
end

@testset "JET" begin
JET.test_package(CanonicalMoments; target_defined_modules = true)
end
run_qa(
CanonicalMoments;
explicit_imports = true,
ei_kwargs = (;
# `@reexport using DiscreteMeasures` necessarily brings the `DiscreteMeasures`
# module name (and its `DiscreteMeasure` export, used here) implicitly; the
# re-export is intentional, so these are not implicit-imports to clean up.
no_implicit_imports = (; ignore = (:DiscreteMeasures, :DiscreteMeasure)),
),
)
2 changes: 2 additions & 0 deletions lib/DiscreteMeasures/test/qa/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
Expand All @@ -11,5 +12,6 @@ DiscreteMeasures = {path = "../.."}
Aqua = "0.8"
DiscreteMeasures = "0.1"
JET = "0.9, 0.10, 0.11"
SciMLTesting = "1.7"
Test = "1"
julia = "1.10"
13 changes: 2 additions & 11 deletions lib/DiscreteMeasures/test/qa/qa.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
using DiscreteMeasures
using Aqua
using JET
using Test
using SciMLTesting, DiscreteMeasures, JET, Test

@testset "Aqua" begin
Aqua.test_all(DiscreteMeasures)
end

@testset "JET" begin
JET.test_package(DiscreteMeasures; target_defined_modules = true)
end
run_qa(DiscreteMeasures; explicit_imports = true)
6 changes: 4 additions & 2 deletions lib/OUQBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Avinash Subramanian (JuliaHub), Benjamin Chung (JuliaHub), Adam Gerl
version = "0.1.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
CanonicalMoments = "58d2c334-1a3c-4862-bb37-9012b9e58a38"
DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
Expand All @@ -12,15 +13,16 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PolynomialRoots = "3a141323-8675-5d76-9d11-e1df1406c778"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"

[compat]
julia = "1.10"
ADTypes = "1"
CanonicalMoments = "0.1"
DiscreteMeasures = "0.1"
DomainSets = "0.7.15"
Expand All @@ -31,13 +33,13 @@ Optimization = "5"
OptimizationBBO = "0.4"
OrderedCollections = "1.7.0"
Pkg = "1.10"
PolynomialRoots = "1"
Polynomials = "4.0.13"
Reexport = "1.2.2"
SciMLBase = "2.153"
SafeTestsets = "0.1"
SymbolicUtils = "3"
Symbolics = "6.39.1"
TermInterface = "2"
Test = "1.10"

[sources]
Expand Down
28 changes: 19 additions & 9 deletions lib/OUQBase/src/OUQBase.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
module OUQBase
using ModelingToolkit, Symbolics
using OrderedCollections
using DiscreteMeasures
using Optimization, JuMP
using SymbolicUtils

import Symbolics: BasicSymbolic
using CanonicalMoments
using ModelingToolkit: ModelingToolkit, @named, OptimizationSystem, get_variables,
getbounds, parameters, structural_simplify, unknowns
using Symbolics: Symbolics, Equation, Inequality, Num, wrap
using SymbolicUtils: SymbolicUtils, BasicSymbolic, @rule, substitute
using SymbolicUtils.Rewriters: Chain
using TermInterface: arguments
using OrderedCollections: OrderedCollections, OrderedDict
using DiscreteMeasures: DiscreteMeasures, DiscreteMeasure, ProductDiscreteMeasure,
expectation, support, weights
# `Optimization` is kept loaded (it provides the solver machinery used downstream);
# only its module binding is needed at this layer.
using Optimization: Optimization
using JuMP: JuMP, @constraint, @objective, @variable, set_lower_bound, set_name,
set_upper_bound
using SciMLBase: SciMLBase, OptimizationFunction, OptimizationProblem
using ADTypes: AbstractADType

using CanonicalMoments: CanonicalMoments, DiscreteMeasureTransform1
import CanonicalMoments: RawMomentSequence

using Reexport
using Reexport: @reexport
# User should not have to depend on CanonicalMoments to use OUQBase.
@reexport using CanonicalMoments:
PolyRootsSupportAlg, PolyWeightAlg, EigvalSupportAlg, EigvecWeightAlg
Expand Down
2 changes: 0 additions & 2 deletions lib/OUQBase/src/interface.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using SciMLBase

macro random_variables(block)
lines = block isa Expr && block.head === :block ? block.args : [block]
Base.remove_linenums!(block)
Expand Down
4 changes: 2 additions & 2 deletions lib/OUQBase/src/operators.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Symbolics: Operator, Term, Num, symtype, value
using SymbolicUtils
import Symbolics: Operator, value
import SymbolicUtils: Term, symtype

struct 𝔼_ <: Operator end

Expand Down
13 changes: 1 addition & 12 deletions lib/OUQBase/src/reduction_transformations/canonical_moments.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
using CanonicalMoments
using OrderedCollections
using ModelingToolkit

import SymbolicUtils.Rewriters: Chain
import Symbolics: wrap
import CanonicalMoments: RawMomentSequence

using SciMLBase


function get_raw_moment_order(equation::Union{Equation, Inequality}, random_var::Num)
remove_expectation_rule = @rule 𝔼(~f) => ~f
extract_moment_rule = @rule ^(~base, ~exponent) => ~exponent
Expand Down Expand Up @@ -271,7 +260,7 @@ function construct_optimization_problem(
(rand_var_vec) ->
substitute(~f, Dict(constituent_random_variables .=> rand_var_vec))
# QN: Will variables always be passed in right order? Should be correct since this order is preserved in getting the induced_discrete_measure.
ouq_obj_f = simplify(obj_expression; rewriter = extract_f_rule)
ouq_obj_f = Symbolics.simplify(obj_expression; rewriter = extract_f_rule)
else
error("Objective is not a ProbabilityObjective or ExpectationObjective")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ function construct_optimization_problem(
oracle_or_symbolic::Symbolic;
kwargs...,
)
@debug "Objective: $objective.objective"
objective = ouq_sys.objective
@debug "Objective: $(objective._obj)"
extract_condition_rule = @rule ℙ(~condition) => ~condition
condition = Symbolics.simplify(objective._obj; rewriter = extract_condition_rule)
_discrete_measure_map =
Expand Down
2 changes: 2 additions & 0 deletions lib/OUQBase/test/qa/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CanonicalMoments = "58d2c334-1a3c-4862-bb37-9012b9e58a38"
DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
OUQBase = "01930cae-99d2-7439-8f4f-ace2ece9f1b9"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
Expand All @@ -17,5 +18,6 @@ CanonicalMoments = "0.1"
DiscreteMeasures = "0.1"
JET = "0.9, 0.10, 0.11"
OUQBase = "0.1"
SciMLTesting = "1.7"
Test = "1"
julia = "1.10"
44 changes: 33 additions & 11 deletions lib/OUQBase/test/qa/qa.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
using OUQBase
using Aqua
using JET
using Test
using SciMLTesting, OUQBase, JET, Test

@testset "Aqua" begin
Aqua.test_all(OUQBase)
end

@testset "JET" begin
JET.test_package(OUQBase; target_defined_modules = true)
end
run_qa(
OUQBase;
explicit_imports = true,
# piracies: OUQBase defines `CanonicalMoments.RawMomentSequence(::Symbolics.Num, ...)`,
# owning neither the type nor the arg types; resolving it is a design change.
aqua_broken = (:piracies,), # SciML/OptimalUncertaintyQuantification.jl#33
ei_kwargs = (;
# Explicit imports of names that are non-public in the upstream majors OUQBase
# actually resolves. OUQBase's [compat] caps SciMLBase 2.x / Symbolics 6.x /
# SymbolicUtils 3.x / ModelingToolkit 9.x, where these are not `public`-declared
# (the public declarations only landed in later majors that [compat] excludes;
# verified against the registered releases on Julia 1.12: Symbolics 6.58.0 /
# SymbolicUtils 3.32.0).
# :BasicSymbolic/:Term/:symtype - SymbolicUtils
# :Operator/:value - Symbolics
all_explicit_imports_are_public = (;
ignore = (:BasicSymbolic, :Operator, :Term, :symtype, :value),
),
# Non-public qualified accesses into upstream packages; still non-public in the
# resolved upstream majors:
# :BasicSymbolic/:isbinop/:promote_symtype - SymbolicUtils
# :evaluate/:geq/:leq - Symbolics
# :getdefault - ModelingToolkit
# :NoAD/:NullParameters - SciMLBase
all_qualified_accesses_are_public = (;
ignore = (
:BasicSymbolic, :NoAD, :NullParameters, :evaluate, :geq, :getdefault,
:isbinop, :leq, :promote_symtype,
),
),
),
)
2 changes: 1 addition & 1 deletion src/OptimalUncertaintyQuantification.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module OptimalUncertaintyQuantification

using Reexport
using Reexport: @reexport
@reexport using OUQBase

end # module
2 changes: 2 additions & 0 deletions test/qa/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DiscreteMeasures = "7766d772-2108-41ee-a4bd-11c51440a39b"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
OUQBase = "01930cae-99d2-7439-8f4f-ace2ece9f1b9"
OptimalUncertaintyQuantification = "91ab1271-1799-4997-981e-07ad84422b0d"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
Expand All @@ -20,5 +21,6 @@ DiscreteMeasures = "0.1"
JET = "0.9, 0.10, 0.11"
OUQBase = "0.1"
OptimalUncertaintyQuantification = "0.1"
SciMLTesting = "1.7"
Test = "1"
julia = "1.10"
22 changes: 11 additions & 11 deletions test/qa/qa.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using OptimalUncertaintyQuantification
using Aqua
using JET
using Test
using SciMLTesting, OptimalUncertaintyQuantification, JET, Test

@testset "Aqua" begin
Aqua.test_all(OptimalUncertaintyQuantification)
end

@testset "JET" begin
JET.test_package(OptimalUncertaintyQuantification; target_defined_modules = true)
end
run_qa(
OptimalUncertaintyQuantification;
explicit_imports = true,
ei_kwargs = (;
# `@reexport using OUQBase` necessarily brings the `OUQBase` module name into
# scope; that re-export is the umbrella package's whole purpose, so the module
# name is not a genuine implicit-import to clean up.
no_implicit_imports = (; ignore = (:OUQBase,)),
),
)
Loading