Stochastic Compliance Minimization with Trace Estimation

Description

When a load follows a distribution (magnitude, direction, or location), a single deterministic compliance value no longer captures the structure’s performance. TopOpt.jl provides differentiable functions that average compliance over many load scenarios, plus randomized estimators that approximate the average without solving every scenario.

The methods used here — exact and randomized evaluation of the mean compliance, of any scalar-valued function of the per-scenario compliances (e.g. a weighted sum of the mean and standard deviation), and the augmented-Lagrangian handling of a maximum-compliance constraint — are described in TarekRay2021 and its approximate counterpart TarekRay2022.

This tutorial covers:

  • MultiLoad and generate_scenarios for building load ensembles
  • MeanComplianceFun with the exact, SVD, Hutchinson-trace, and SVD-trace estimators
  • BlockComplianceFun for per-scenario compliance, used in a risk-averse (mean + standard deviation) objective and in a maximum-compliance-constrained problem solved with the augmented Lagrangian method
  • Choosing an estimator based on accuracy vs. cost

Setup

using TopOpt, LinearAlgebra, SparseArrays, Random, Statistics
using WGLMakie
WGLMakie.activate!(; resize_to=:parent)
using Bonito
if haskey(ENV, "QUARTO_PROJECT_DIR")
    Bonito.Page(exportable=true, offline=true)
else
    Bonito.browser_display()
end
display_app(app) = display(app)

WGLMakie.activate!(; resize_to=:parent) selects the browser renderer and fills the Quarto output column. Bonito.Page(exportable=true, offline=true) embeds the assets needed by visualize(...; static=true) in the Quarto output, so the visualization does not require a running Julia process.

A load ensemble

We model a cantilever whose tip is loaded by many random point loads drawn from a distribution of directions and magnitudes, spread over the interior nodes of the tip face. The load matrix F has one column per scenario.

Random.seed!(42)
E, ν = 1.0, 0.3
nels = (40, 20)
base = PointLoadCantilever(nels, (1.0, 1.0), E, ν, 1.0)
ndofs = length(FEASolver(DirectSolver, base).u)
nloads = 16

# Sample loads on the free tip only: a load applied anywhere else could sit on
# void material. The ensemble is spread over the interior of the tip (the
# corner nodes are excluded — point loads at re-entrant corners are
# singular), with each scenario drawing two random DOFs from those nodes.
grid = base.ch.dh.grid
tip_nodes = Int[]
for (cellind, faceind) in grid.facetsets["right"]
    cell = grid.cells[cellind]
    for n in collect(values(TopOpt.Ferrite.facets(cell)))[faceind]
        push!(tip_nodes, n)
    end
end
unique!(tip_nodes)
coords = grid.nodes
xmax = maximum(n -> coords[n].x[1], tip_nodes)
tip_nodes = sort!([n for n in tip_nodes if coords[n].x[1] == xmax]; by=n -> coords[n].x[2])
tip_nodes = tip_nodes[5:17]  # interior nodes of the tip (y ≈ 0.2–0.8)
tip_dofs = vcat([base.metadata.node_dofs[:, n] for n in tip_nodes]...)

F = spzeros(ndofs, nloads)
for i in 1:nloads
    dofs = tip_dofs[rand(1:length(tip_dofs), 2)]
    F[dofs, i] .= randn(2)
end
problem = MultiLoad(base, F)

solver = FEASolver(DirectSolver, problem; xmin=0.01, penalty=PowerPenaltyFun(3.0))

generate_scenarios builds a simpler ensemble: a single DOF loaded with perturbed magnitudes.

F_simple = generate_scenarios(tip_dofs[1], (ndofs, 8), 1.0)
println("generate_scenarios: $(size(F_simple, 2)) scenarios, $(nnz(F_simple)) non-zeros")
generate_scenarios: 8 scenarios, 8 non-zeros

Exact mean compliance (baseline)

MeanComplianceFun(problem, solver; method=:exact) solves every scenario and averages. The :exact_svd method compresses F with a thin SVD first, giving the same value from fewer solves when the scenarios are linearly dependent.

mc_exact = MeanComplianceFun(problem, solver; method=:exact)
mc_svd   = MeanComplianceFun(problem, solver; method=:exact_svd)

x = fill(0.5, length(solver.vars))
C_exact = mc_exact(PseudoDensities(x))
C_svd   = mc_svd(PseudoDensities(x))
println("exact     = $(C_exact)")
println("exact_svd = $(C_svd)  (rel. diff $(abs(C_exact - C_svd) / C_exact))")
exact     = 335.187005159037
exact_svd = 335.1870051590491  (rel. diff 3.5952482086152246e-14)

Hutchinson trace estimator

Instead of solving all nloads scenarios, the Hutchinson estimator probes with nv random Rademacher (±1) vectors:

\[ \mathbb{E}\,[v^\mathsf{T} F^\mathsf{T} K^{-1} F v] = \mathrm{tr}(F^\mathsf{T} K^{-1} F) \]

which is proportional to the mean compliance. nv is the number of probe vectors; the estimate converges at O(1/√nv) but costs only nv solves. The error of any single draw does not decrease monotonically with nv (successive runs redraw all probes), so compare runs with the same seed or judge by the expected rate.

for nv in (2, 4, 8, 16)
    mc = MeanComplianceFun(problem, solver; method=:trace, nv=nv, sample_once=false)
    est = mc(PseudoDensities(x))
    println("hutch nv=$(lpad(nv, 2)): $(round(est, digits=3))  (rel. err $(round(abs(est - C_exact) / C_exact, digits=3)))")
end
hutch nv= 2: 172.036  (rel. err 0.487)
hutch nv= 4: 441.043  (rel. err 0.316)
hutch nv= 8: 267.218  (rel. err 0.203)
hutch nv=16: 421.105  (rel. err 0.256)

With sample_once=false the probe vectors are redrawn on every call, so the estimate varies between calls; with sample_once=true (the default) they are drawn once at construction and held fixed, which keeps the objective and its gradient consistent during an optimization.

Hadamard (deterministic) estimator

Passing sample_method=:hadamard replaces the random probes with deterministic orthogonal Hadamard columns. The estimator is exact only when nv equals the number of load scenarios (the Hadamard columns then form a complete orthogonal basis); with fewer columns the estimate is biased toward the column span, so the constructor rejects nv < n_scenarios.

n_scenarios = size(problem.F, 2)
mc = MeanComplianceFun(
    problem, solver; method=:trace, nv=n_scenarios, sample_method=:hadamard
)
est = mc(PseudoDensities(x))
println("hadamard nv=$(n_scenarios): $(round(est, digits=3))  (rel. err $(round(abs(est - C_exact) / C_exact, digits=3)))")
hadamard nv=16: 335.187  (rel. err 0.0)

Per-scenario compliance: mean and standard deviation

BlockComplianceFun returns a vector of compliance values, one per scenario. This lets us form arbitrary statistics. Minimizing the mean alone is the standard robust formulation; adding a multiple of the standard deviation penalizes designs that perform unevenly across the load distribution.

bc = BlockComplianceFun(problem, solver; method=:exact)
V = 0.5
filter = DensityFilterFun(solver; rmin=2.0)
volfrac = VolumeFun(solver)

mean_only = x -> mean(bc(filter(PseudoDensities(x))))
mean_std  = x -> mean(bc(filter(PseudoDensities(x)))) + 0.25 * std(bc(filter(PseudoDensities(x))))
volconstr = x -> volfrac(filter(PseudoDensities(x))) - V

function run(obj, label; x0=nothing)
    model = Model(obj)
    addvar!(model, zeros(length(x)), ones(length(x)))
    add_ineq_constraint!(model, volconstr)
    r = optimize(model, MMA87(), x0 === nothing ? fill(V, length(x)) : x0;
        options=MMAOptions(; maxiter=300, tol=Tolerance(; kkt=1e-3, f=1e-4)))
    println("$label: obj = $(round(obj(r.minimizer), digits=3)), vol = $(round(volconstr(r.minimizer) + V, digits=3))")
    return r.minimizer
end
x_mean = run(mean_only, "mean only      ")
x_meanstd = run(mean_std, "mean + 0.25 std"; x0=x_mean)
[ Info:   iter       obj      Δobj  violation  kkt_residual  
[ Info:      0   3.4e+02       Inf   0.0e+00   1.7e+01
[ Info:      1   2.5e+02   8.5e+01   0.0e+00   4.2e+01
[ Info:      2   1.9e+02   6.2e+01   0.0e+00   1.3e+01
[ Info:      3   1.6e+02   2.9e+01   0.0e+00   6.3e+00
[ Info:      4   1.5e+02   1.3e+01   0.0e+00   2.7e+00
[ Info:      5   1.4e+02   7.3e+00   0.0e+00   1.7e+00
[ Info:      6   1.3e+02   5.3e+00   0.0e+00   1.2e+00
[ Info:      7   1.3e+02   4.0e+00   0.0e+00   9.6e-01
[ Info:      8   1.3e+02   4.0e+00   0.0e+00   1.0e+00
[ Info:      9   1.2e+02   4.3e+00   0.0e+00   1.0e+00
[ Info:     10   1.2e+02   4.9e+00   0.0e+00   1.3e+00
[ Info:     11   1.1e+02   5.4e+00   0.0e+00   1.3e+00
[ Info:     12   1.1e+02   4.3e+00   0.0e+00   9.4e-01
[ Info:     13   1.0e+02   3.3e+00   0.0e+00   7.1e-01
[ Info:     14   1.0e+02   2.6e+00   0.0e+00   5.4e-01
[ Info:     15   1.0e+02   1.7e+00   0.0e+00   3.4e-01
[ Info:     16   9.9e+01   1.0e+00   0.0e+00   2.5e-01
[ Info:     17   9.8e+01   6.9e-01   0.0e+00   2.0e-01
[ Info:     18   9.8e+01   4.4e-01   0.0e+00   1.9e-01
[ Info:     19   9.8e+01   2.8e-01   0.0e+00   1.4e-01
[ Info:     20   9.7e+01   1.9e-01   0.0e+00   1.3e-01
[ Info:     21   9.7e+01   1.2e-01   0.0e+00   9.5e-02
[ Info:     22   9.7e+01   8.6e-02   0.0e+00   8.6e-02
[ Info:     23   9.7e+01   6.0e-02   0.0e+00   6.9e-02
[ Info:     24   9.7e+01   4.5e-02   0.0e+00   6.4e-02
[ Info:     25   9.7e+01   4.1e-02   0.0e+00   3.6e-02
[ Info:     26   9.7e+01   2.5e-02   0.0e+00   3.1e-02
[ Info:     27   9.7e+01   1.9e-02   0.0e+00   3.0e-02
[ Info:     28   9.7e+01   1.9e-02   0.0e+00   3.2e-02
[ Info:     29   9.7e+01   2.3e-02   0.0e+00   3.6e-02
[ Info:     30   9.7e+01   3.0e-02   0.0e+00   2.4e-02
[ Info:     31   9.7e+01   2.1e-02   0.0e+00   2.4e-02
[ Info:     32   9.7e+01   1.6e-02   0.0e+00   2.5e-02
[ Info:     33   9.7e+01   1.2e-02   0.0e+00   2.2e-02
[ Info:     34   9.7e+01   1.2e-02   0.0e+00   2.1e-02
[ Info:     35   9.7e+01   1.1e-02   0.0e+00   1.9e-02
[ Info:     36   9.7e+01   1.0e-02   0.0e+00   1.8e-02
[ Info:     37   9.7e+01   1.0e-02   0.0e+00   1.6e-02
[ Info:     38   9.7e+01   7.9e-03   0.0e+00   1.4e-02
[ Info:     39   9.7e+01   7.0e-03   0.0e+00   1.2e-02
[ Info:     40   9.7e+01   7.0e-03   0.0e+00   1.7e-02
[ Info:     41   9.7e+01   7.8e-03   0.0e+00   2.3e-02
[ Info:     42   9.7e+01   8.3e-03   0.0e+00   2.8e-02
[ Info:     43   9.7e+01   7.4e-03   0.0e+00   3.1e-02
[ Info:     44   9.7e+01   7.0e-03   0.0e+00   2.4e-02
[ Info:     45   9.7e+01   5.2e-03   0.0e+00   1.6e-02
[ Info:     46   9.7e+01   3.8e-03   0.0e+00   9.9e-03
[ Info:     47   9.7e+01   2.4e-03   0.0e+00   8.2e-03
[ Info:     48   9.7e+01   1.6e-03   0.0e+00   8.0e-03
[ Info:     49   9.7e+01   1.4e-03   0.0e+00   7.9e-03
[ Info:     50   9.7e+01   1.3e-03   0.0e+00   7.8e-03
[ Info:     51   9.7e+01   1.2e-03   0.0e+00   7.8e-03
[ Info:     52   9.7e+01   1.2e-03   0.0e+00   7.8e-03
[ Info:     53   9.7e+01   1.1e-03   0.0e+00   7.9e-03
[ Info:     54   9.7e+01   7.7e-04   0.0e+00   4.2e-03
[ Info:     55   9.7e+01   4.7e-04   0.0e+00   4.4e-03
[ Info:     56   9.7e+01   3.9e-04   0.0e+00   4.3e-03
[ Info:     57   9.7e+01   4.0e-04   0.0e+00   4.0e-03
[ Info:     58   9.7e+01   4.3e-04   0.0e+00   3.7e-03
[ Info:     59   9.7e+01   4.6e-04   0.0e+00   3.2e-03
[ Info:     60   9.7e+01   4.8e-04   0.0e+00   2.8e-03
[ Info:     61   9.7e+01   5.2e-04   0.0e+00   3.3e-03
[ Info:     62   9.7e+01   5.8e-04   0.0e+00   4.0e-03
[ Info:     63   9.7e+01   6.8e-04   0.0e+00   4.7e-03
[ Info:     64   9.7e+01   8.3e-04   0.0e+00   5.7e-03
[ Info:     65   9.7e+01   1.1e-03   0.0e+00   6.7e-03
[ Info:     66   9.7e+01   1.4e-03   0.0e+00   8.0e-03
[ Info:     67   9.7e+01   1.9e-03   0.0e+00   9.5e-03
[ Info:     68   9.7e+01   2.6e-03   0.0e+00   1.1e-02
[ Info:     69   9.7e+01   3.6e-03   0.0e+00   1.3e-02
[ Info:     70   9.7e+01   5.0e-03   0.0e+00   1.6e-02
[ Info:     71   9.7e+01   6.4e-03   0.0e+00   1.7e-02
[ Info:     72   9.7e+01   6.1e-03   0.0e+00   1.8e-02
[ Info:     73   9.7e+01   5.5e-03   0.0e+00   1.7e-02
[ Info:     74   9.7e+01   3.3e-03   0.0e+00   9.4e-03
[ Info:     75   9.7e+01   1.0e-03   0.0e+00   2.8e-03
[ Info:     76   9.7e+01   2.3e-04   0.0e+00   1.9e-03
[ Info:     77   9.7e+01   1.1e-04   0.0e+00   1.6e-03
[ Info:     78   9.7e+01   7.5e-05   0.0e+00   1.5e-03
[ Info:     79   9.7e+01   5.9e-05   0.0e+00   1.4e-03
[ Info:     80   9.7e+01   5.7e-05   0.0e+00   1.4e-03
[ Info:     81   9.7e+01   4.6e-05   0.0e+00   1.3e-03
[ Info:     82   9.7e+01   4.2e-05   0.0e+00   1.2e-03
[ Info:     83   9.7e+01   3.5e-05   0.0e+00   1.2e-03
[ Info:     84   9.7e+01   3.1e-05   0.0e+00   1.1e-03
[ Info:     85   9.7e+01   2.7e-05   0.0e+00   1.1e-03
[ Info:     86   9.7e+01   1.8e-05   0.0e+00   1.0e-03
mean only      : obj = 96.742, vol = 0.5
[ Info:   iter       obj      Δobj  violation  kkt_residual  
[ Info:      0   1.3e+02       Inf   0.0e+00   4.8e-01
[ Info:      1   1.3e+02   1.9e-03   0.0e+00   4.3e-02
[ Info:      2   1.3e+02   2.3e-03   0.0e+00   4.0e-02
[ Info:      3   1.3e+02   2.2e-03   0.0e+00   3.8e-02
[ Info:      4   1.3e+02   2.3e-03   0.0e+00   3.5e-02
[ Info:      5   1.3e+02   2.3e-03   0.0e+00   3.3e-02
[ Info:      6   1.3e+02   2.3e-03   0.0e+00   3.0e-02
[ Info:      7   1.3e+02   2.3e-03   0.0e+00   2.7e-02
[ Info:      8   1.3e+02   2.3e-03   0.0e+00   2.5e-02
[ Info:      9   1.3e+02   2.3e-03   0.0e+00   2.2e-02
[ Info:     10   1.3e+02   2.3e-03   0.0e+00   1.9e-02
[ Info:     11   1.3e+02   2.1e-03   0.0e+00   1.7e-02
[ Info:     12   1.3e+02   2.1e-03   0.0e+00   1.5e-02
[ Info:     13   1.3e+02   2.1e-03   0.0e+00   1.3e-02
[ Info:     14   1.3e+02   2.1e-03   0.0e+00   1.1e-02
[ Info:     15   1.3e+02   2.0e-03   0.0e+00   1.0e-02
[ Info:     16   1.3e+02   1.8e-03   0.0e+00   9.5e-03
[ Info:     17   1.3e+02   1.5e-03   0.0e+00   9.0e-03
[ Info:     18   1.3e+02   9.7e-04   0.0e+00   8.3e-03
[ Info:     19   1.3e+02   6.8e-04   0.0e+00   7.1e-03
[ Info:     20   1.3e+02   4.7e-04   0.0e+00   5.7e-03
[ Info:     21   1.3e+02   3.2e-04   0.0e+00   4.5e-03
[ Info:     22   1.3e+02   2.3e-04   0.0e+00   3.6e-03
[ Info:     23   1.3e+02   1.6e-04   0.0e+00   3.1e-03
[ Info:     24   1.3e+02   1.1e-04   0.0e+00   2.6e-03
[ Info:     25   1.3e+02   7.4e-05   0.0e+00   2.2e-03
[ Info:     26   1.3e+02   5.0e-05   0.0e+00   1.8e-03
[ Info:     27   1.3e+02   3.6e-05   0.0e+00   1.5e-03
[ Info:     28   1.3e+02   2.4e-05   0.0e+00   1.3e-03
[ Info:     29   1.3e+02   1.8e-05   0.0e+00   1.1e-03
[ Info:     30   1.3e+02   1.1e-05   0.0e+00   9.1e-04
mean + 0.25 std: obj = 127.156, vol = 0.5
800-element Vector{Float64}:
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 ⋮
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

Verification: loaded-node support and connectivity

The load ensemble acts on the interior of the tip, so a valid design must keep material under every node that actually carries a load and form a single connected structure:

node2cells = Dict{Int,Vector{Int}}()
for (ci, cell) in enumerate(grid.cells)
    for n in cell.nodes
        push!(get!(() -> Int[], node2cells, n), ci)
    end
end
loaded_nodes = unique((d - 1) ÷ 2 + 1 for d in reduce(vcat, [findall(!iszero, F[:, i]) for i in 1:nloads]))
# Each loaded node must be supported: at least one adjacent cell is solid.
node_support(topo) = minimum(maximum(topo[node2cells[n]] for n in loaded_nodes))

function connectivity(topo)
    solid = findall(topo .> 0.5)
    isempty(solid) && return (0, 0)
    parent = collect(1:length(solid))
    function root(i)
        while parent[i] != i
            parent[i] = parent[parent[i]]
            i = parent[i]
        end
        return i
    end
    edges = Dict{Tuple{Int,Int},Vector{Int}}()
    for (i, c) in enumerate(solid)
        cell = grid.cells[c]
        for e in 1:4
            a, b = minmax(cell.nodes[e], cell.nodes[mod1(e + 1, 4)])
            push!(get!(() -> Int[], edges, (a, b)), i)
        end
    end
    for v in values(edges), i in 1:length(v), j in (i + 1):length(v)
        ra, rb = root(v[i]), root(v[j])
        parent[ra] = rb
    end
    counts = Dict{Int,Int}()
    for i in eachindex(solid)
        r = root(i)
        counts[r] = get(counts, r, 0) + 1
    end
    return maximum(values(counts)), length(counts)
end

for (name, x) in (("mean only      ", x_mean), ("mean + 0.25 std", x_meanstd))
    topo = collect(filter(PseudoDensities(x)).x)
    largest, ncomp = connectivity(topo)
    println("$name: connected = $(ncomp == 1), minimum loaded-node support = $(round(node_support(topo), digits=3))")
end
mean only      : connected = true, minimum loaded-node support = 1.0
mean + 0.25 std: connected = true, minimum loaded-node support = 1.0

The designs keep every loaded node supported by solid material and each material region is one connected component, so the plots below are not missing load-bearing material or floating islands.

Maximum compliance constraint via augmented Lagrangian

A robust design can instead bound the worst-case compliance: minimize the volume subject to C_i ≤ C_t for every scenario. Following TarekRay2021 (§4), this is solved with the augmented Lagrangian method, where the per-scenario compliances from BlockComplianceFun enter the augmented Lagrangian function

\[ L(\bm{x}; \bm\lambda, r) = V(\bm{x}) + \sum_i \left[\lambda_i (C_i - C_t) + r\,\max(C_i - C_t, 0)^2\right]. \]

Each subproblem minimizes this function over the box 0 ≤ x ≤ 1, then the multipliers and penalty are updated (λ ← λ + ρ·c, ρ ← γρ). The compliance threshold C_t is calibrated from the solid design’s worst-case compliance. NonconvexAugLagLab provides this method as a built-in solver: the per-scenario vector constraint folds into the augmented Lagrangian and the multiplier/penalty loop runs automatically.

using NonconvexAugLagLab
volf = x -> volfrac(filter(PseudoDensities(x)))
Cfun = x -> bc(filter(PseudoDensities(x)))
C_t = 2.0 * maximum(Cfun(ones(length(solver.vars))))
model = Model(volf)
addvar!(model, zeros(length(solver.vars)), ones(length(solver.vars)))
add_ineq_constraint!(model, x -> Cfun(x) ./ C_t .- 1)
x_al = optimize(
    model,
    NonconvexAugLagLab.AugLagAlg(),
    x_mean;  # warm start from the mean-only design
    options=NonconvexAugLagLab.AugLagOptions(;
        max_iter=40,
        sub_options=(; max_iter=300, tol=1e-6, linesearch=:trustregion),
    ),
).minimizer
C = Cfun(x_al)
println("max-compliance design: volume = $(round(volf(x_al), digits=3)), max C = $(round(maximum(C), digits=1)), C_t = $(round(C_t, digits=1)), max C / C_t = $(round(maximum(C) / C_t, digits=5))")

topo_al = collect(filter(PseudoDensities(x_al)).x)
largest_al, ncomp_al = connectivity(topo_al)
println("max-compliance design: connected = $(ncomp_al == 1), minimum loaded-node support = $(round(node_support(topo_al), digits=3))")
max-compliance design: volume = 0.515, max C = 447.9, C_t = 447.9, max C / C_t = 1.0
max-compliance design: connected = true, minimum loaded-node support = 0.988

Visualize the designs

The figures show the designs with every load of the ensemble drawn as an arrow: the scenario matrix F is aggregated into per-node load vectors and passed to visualize as cloaddict.

load_vecs = Dict{Int,Vector{Float64}}()
for i in 1:nloads
    for dof in findall(!iszero, F[:, i])
        node = (dof - 1) ÷ 2 + 1
        comp = isodd(dof) ? 1 : 2
        v = get!(() -> zeros(2), load_vecs, node)
        v[comp] += F[dof, i]
    end
end
cloaddict = Dict(n => [v[1], v[2], 0.0] for (n, v) in load_vecs)
fig1 = visualize(problem.problem; static=true, topology=filter(PseudoDensities(x_mean)).x, cloaddict=cloaddict)
display_app(fig1)
undeformed mesh
load arrows
support arrows
Figure 1: Robust design minimizing mean compliance over random tip loads
fig2 = visualize(problem.problem; static=true, topology=filter(PseudoDensities(x_meanstd)).x, cloaddict=cloaddict)
display_app(fig2)
undeformed mesh
load arrows
support arrows
Figure 2: Design minimizing mean + 0.25·std, trading a bit of average stiffness for consistency across the load distribution
fig3 = visualize(problem.problem; static=true, topology=filter(PseudoDensities(x_al)).x, cloaddict=cloaddict)
display_app(fig3)
undeformed mesh
load arrows
support arrows
Figure 3: Minimum-volume design subject to a maximum-compliance bound (augmented Lagrangian)

Practical guidance

  • Exact (:exact, :exact_svd): use when the number of scenarios is small (≤ a few dozen) or the scenarios are strongly correlated. :exact_svd is the better default — it gives the same answer with fewer solves.
  • Hutchinson (:trace): use for large ensembles where solving every scenario is prohibitive. Accuracy improves with nv, but so does cost.
  • Hadamard (:trace with sample_method=:hadamard): deterministic and smoother than Hutchinson; nv must equal the number of scenarios for an unbiased estimate.
  • BlockComplianceFun exposes the per-scenario values, so it is the tool for statistics beyond the mean (standard deviation, CVaR-style combinations) and for the maximum-compliance constraint handled by the augmented Lagrangian method.

References

  • TarekRay2021: Tarek, M. & Ray, T. (2021). Robust and stochastic compliance-based topology optimization with finitely many loading scenarios. Structural and Multidisciplinary Optimization. DOI: 10.1007/s00158-021-03022-x.
  • TarekRay2022: Tarek, M. & Ray, T. (2022). Approximation schemes for stochastic compliance-based topology optimization with many loading scenarios. Structural and Multidisciplinary Optimization. DOI: 10.1007/s00158-022-03221-0.