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

Add Design of Experiments #93

Merged
merged 40 commits into from
Jul 14, 2023
Merged

Conversation

mlsuh
Copy link
Collaborator

@mlsuh mlsuh commented Jan 6, 2023

Adds a number of design of experiments to use with the ResponseSurface.

  • TwoLevelFactorial
  • FullFactorial
  • FractionalFactorial
  • CentralComposite
  • BoxBehnken

The documentation and demo files include an example where the Himmelblau function is approximated.

@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Patch coverage: 98.02% and project coverage change: -0.15 ⚠️

Comparison is base (d603f94) 98.83% compared to head (84ae7df) 98.68%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
- Coverage   98.83%   98.68%   -0.15%     
==========================================
  Files          22       23       +1     
  Lines         684      835     +151     
==========================================
+ Hits          676      824     +148     
- Misses          8       11       +3     
Impacted Files Coverage Δ
src/UncertaintyQuantification.jl 100.00% <ø> (ø)
src/simulations/doe.jl 98.01% <98.01%> (ø)
src/models/responsesurface.jl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@FriesischScott
Copy link
Owner

Please move the doe.jl into the simulations subfolder.

@mlsuh
Copy link
Collaborator Author

mlsuh commented May 2, 2023

FractionalFactorial and BoxBehnken are now implemented. Can be tested by (un)commenting and manipulating the respective lines of code in ...demo/metamodels/responsesurface.jl

mlsuh added 2 commits May 25, 2023 12:53
implemented Central Composite(inscribed and face centered)
added tests for Central Composite
@FriesischScott FriesischScott added the feature New feature or feature request label Jun 1, 2023
doe
will now also work with non-uniform RandomVariables
@FriesischScott FriesischScott changed the title design of experiments Add Design of Experiments Jun 22, 2023
@FriesischScott FriesischScott marked this pull request as ready for review June 22, 2023 15:15
@FriesischScott
Copy link
Owner

It turns out the mapping through standard normal space etc. is not the way to go. With the design of experiments we just want to cover the input space and don't care about the exact distributions. So we are going to do the following:

For finite bounds we just scale and shift the values between the bounds of the distribution. For example, for a Uniform(-1, 1) the values [0.0, 0.5, 1.0] would become[-1, 0.0, 1.0]. For infinite bounds we add another property to all the designs σ::Integer=1. In the transformation we will use + or - σ times the standard deviation of the rv as the bounds.

This way, no mappings through the cdf are performed and there is no risk of inf or nan values.

@mlsuh Can you adapt the sample function to behave like this?

Copy link
Owner

@FriesischScott FriesischScott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests don't pass.

return vcat(two_lvl_points, axial_points)
end

function doe_samples(_::PlackettBurman, rvs::Int)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit work in progress functions.

return reduce(vcat, bounds.(jd.marginals, σ))
end

function sample(inputs::Array{<:UQInput}, design::AbstractDesignOfExperiments, σ::Int=1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sigma should be a parameter of the individual structs of the designs, not the sample function.

end

function bounds(r::RandomVariable, σ::Int)
ub = support(r.dist).ub
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ub = maximum(rv)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ub = isinf(ub) ? ub : std(rv) * sigma

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about ub = isinf(maximum(rv)) ? std(rv) * sigma : maximum(rv)?
So, one line and no refactoring of ub but with tradeoff of extra call of maximum(rv).

lb = -std(r.dist) * σ
end

return [ub lb]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return [lb ub]

@FriesischScott
Copy link
Owner

Nice work @mlsuh!

@FriesischScott FriesischScott merged commit 966c832 into FriesischScott:master Jul 14, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants