Skip to content

Commit 27764d1

Browse files
Pipeline ideas
1 parent 697a43b commit 27764d1

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ authors = ["LucasMSpereira"]
44
version = "0.1.0"
55

66
[deps]
7+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
78
ImplicitDifferentiation = "57b37032-215b-411a-8a7c-41a003a55207"
89
TopOpt = "53a1e1a5-51bb-58a9-8a02-02056cc81109"
10+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
911

1012
[compat]
1113
julia = "1"

src/Uncertainty.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module Uncertainty
22

3-
# Write your package code here.
4-
3+
struct RandomFunction
4+
field
55
end
6+
7+
end

test/runtests.jl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
using Uncertainty
2-
using Test
1+
using Uncertainty, Test, ImplicitDifferentiation, Zygote, TopOpt, ChainRulesCore
32

43
@testset "Uncertainty.jl" begin
5-
# Write your tests here.
6-
end
4+
## 1) ImplicitDifferentiation.jl -> ensure differentiability
5+
zero_gradient(x, y) = 2(y - x) # place-holders from ImplicitDifferentiation.jl docs
6+
implicit = ImplicitFunction(???, zero_gradient)
7+
x = rand(3)
8+
implicit(x)
9+
Zygote.jacobian(implicit, x)[1]
10+
## 2) solve optimization -> linear approximation around p0 (MPP)
11+
# ???
12+
## linear approximation around p0 and base distribution of parameters -> RandomFunction struct
13+
E_p(f(x; p)) = f(x; p = p0) + df(x; p = p0)/dp * mu_p - df(x; p = p0)/dp * p0
14+
p ~ MvNormal(mu_p, cov_p)
15+
mu(x) = f(x; p = p0(x)) + df(x; p = p0(x))/dp * mu_p - df(x; p = p0(x))/dp * p0
16+
cov(x) = (df(x; p = p0)/dp) * cov_p * (df(x; p = p0)/dp)'
17+
f(x; p) ~ MvNormal(mu(x), cov(x))
18+
rf = RandomFunction(f, MvNormal(zeros(3), I(3)), method = FORM(RIA(g)))
19+
## RandomFunction struct -> mean and cov functions
20+
function obj(x)
21+
dist = rf(x)
22+
mean(dist) + 2 * std(dist)
23+
end
24+
## obj(x) to be used in actual application (e.g. TO)
25+
# TopOpt.jl code
26+
end

0 commit comments

Comments
 (0)