/cli_example.py (6cd17c9e68ac9734b1881157c553856bd2e034de) (2084 bytes) (mode 100644) (type blob)
#!/usr/bin/env python
# coding: utf-8
import numpy as np
import scipy.stats as stats
from wellmet.samplebox import SampleBox
from wellmet import f_models
# 1. Set up probability distribution
# Standard Gaussian variables, 2D
#f = f_models.SNorm(2)
# Just normal variables
f = f_models.Norm(mean=[-1, 0], std=[2, 1])
# Independent non-Gaussian variables
#f = f_models.UnCorD((stats.gumbel_r, stats.uniform))
# Correlated:
# Nataf model with correlations of the respective _Gaussian_ marginals
#f = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]])
# 2. Define LSF function
def my_problem(input_sample):
# get real (physical) space coordinates
# X is a numpy array with shape (nsim, ndim)
# the algorithm normally sends (1, ndim) sample
X = input_sample.R
# LSF
g = X[:, 0] - X[:, 1] + 3
# we should return an instance of SampleBox class
# it stores coordinates along with LSF calculation result
# with kind of signature
return SampleBox(input_sample, g, "my_problem")
# 3. Prepare storage
# no need to store anything
#sample_box = SampleBox(f)
# keep samples and estimations continiously stored
from wellmet import reader
sample_box = reader.Reader("meow_problem", f)
# 4. Setup the algorithm
from wellmet.dicebox.circumtri import CirQTri
import quadpy
scheme = quadpy.tn.stroud_tn_3_6b(sample_box.nvar)
convex_hull_degree = 5 # degreee of Grundmann-Möller cubature scheme
q = 1 # should be > 0. Greater values slightly enforces exploration
screening_rate = 0 # 10 means to sacrifice every tenth sample for screening
box = CirQTri(sample_box, scheme, convex_hull_degree, q, screening_rate)
# 5. Here we go!
for i in range(20):
# ask where to sample the next point
# next_node is an f_model instance
next_node = box()
# call LSF
new_sample = my_problem(next_node)
# put calculation result to the box
box.add_sample(new_sample)
print(box.get_pf_estimation())
sensitivities_results = box.Tri.perform_sensitivity_analysis()
print(sensitivities_results.sensitivities)
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
26 |
aed04ad7c97da717e759111aa8dd7cd48768647f |
.gitignore |
100644 |
blob |
1093 |
263306d87c51114b1320be2ee3277ea0bff99b1f |
LICENSE |
100644 |
blob |
5165 |
c9a2ecc2110771d29b800aee6152fd3a3d239e80 |
README.md |
100644 |
blob |
2084 |
6cd17c9e68ac9734b1881157c553856bd2e034de |
cli_example.py |
100644 |
blob |
1257 |
52ad8257fd62a3dc12f8d08eaf73a7cfb5d392b8 |
gui_example.py |
100644 |
blob |
81 |
fed528d4a7a148fd0bf0b0198a6461f8c91b87e9 |
pyproject.toml |
100644 |
blob |
795 |
7f9286ab2094e7dddfb6e1c5e49396fa7d79e67c |
setup.cfg |
100644 |
blob |
54 |
ee2a480d94ead7579fdddabda39a672e31b90ced |
setup.py |
040000 |
tree |
- |
c71333f92448098d44613a5de568eb3f3788abbe |
wellmet |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/WellMet
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/WellMet
Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/WellMet
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main