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

43 improvement of sensitivity analysis #48

Merged
merged 159 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from 118 commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
6f0ecf1
add FAST method from SALib
HvanderStok Sep 16, 2022
41b56af
add PAWN method from SALib
HvanderStok Sep 16, 2022
edaa51f
add option to get verbose results from SenAnalyzer.run(verbose=True)
HvanderStok Sep 16, 2022
4a0ba36
update SenAnalyzer
HvanderStok Sep 19, 2022
2adcd57
Fix show_plot for single calibration class
HvanderStok Sep 19, 2022
ade8ba5
scale tuner-parameter for senitivity analysis
HvanderStok Sep 21, 2022
8459efc
bug fix
HvanderStok Sep 21, 2022
d3ea293
show plot of validation
HvanderStok Sep 22, 2022
668c77f
return verbose information from validation
HvanderStok Sep 22, 2022
7ab2a5b
plot of sobol
HvanderStok Sep 25, 2022
3d1e629
bug fix
HvanderStok Sep 26, 2022
fae2761
fast fix plot sobol results
HvanderStok Sep 26, 2022
eb8f488
bug fix
HvanderStok Sep 26, 2022
34df807
return parameter values with intersection
HvanderStok Oct 17, 2022
b043bf1
bug fix
HvanderStok Oct 17, 2022
072cf20
test return samples and and statisical measurs of sensitivity analysis
HvanderStok Oct 17, 2022
fe4feee
update requirements
HvanderStok Dec 28, 2022
8c234f6
clean up
HvanderStok Dec 29, 2022
6a419d3
fix Morris default num_levels
HvanderStok Dec 29, 2022
d83814c
sobol: new sampler and fix analysis_variables
HvanderStok Dec 30, 2022
b6fed3e
add plot function
HvanderStok Jan 2, 2023
18ce3b8
fix result dataframe for sobol second order
HvanderStok Jan 3, 2023
f95c3f1
result dataframe index structur
HvanderStok Jan 3, 2023
7883732
plotting of first and total order analysis variables
HvanderStok Jan 5, 2023
52953f1
clean up
HvanderStok Jan 5, 2023
c2445c3
plotting of second order results of sobol
HvanderStok Jan 6, 2023
ec2f83f
plot second order for single parameter
HvanderStok Jan 6, 2023
1574af7
temp: time stamps for comparison
HvanderStok Jan 11, 2023
444089f
Split eval difference form sample simulation
HvanderStok Jan 11, 2023
0a0cdd0
clean up
HvanderStok Jan 11, 2023
e61da2d
save stat_meas of samples for each cal_class
HvanderStok Jan 11, 2023
d910d1a
Merge branch '43-2-Improvement-of-sensitivity_analysis_memory' into 4…
HvanderStok Jan 11, 2023
436baee
structured saving of all results
HvanderStok Jan 23, 2023
ef0db94
loading simulation files
HvanderStok Jan 24, 2023
68173e4
add use_first_sim
HvanderStok Jan 24, 2023
fb9eea9
mp for loading and evaluation of simulation files
HvanderStok Jan 25, 2023
2de3c52
clean up
HvanderStok Jan 25, 2023
c4c8f8b
create an info.txt for saved samples
HvanderStok Jan 26, 2023
e58d7a3
fix plot_second_order
HvanderStok Jan 26, 2023
8e83780
fix plot_second_order
HvanderStok Jan 26, 2023
8d8efba
clean up
HvanderStok Jan 26, 2023
f7c97d9
fix gitignore testzone
HvanderStok Jan 26, 2023
1d6c749
update requirements
HvanderStok Jan 26, 2023
3131665
fix repuirements
HvanderStok Jan 26, 2023
442c5f9
add verbose return value on failed sim
HvanderStok Jan 26, 2023
2cf540f
check number of sim files befor loading
HvanderStok Jan 26, 2023
736db7a
throw warning for info_samples
HvanderStok Jan 26, 2023
fb05bf1
change test for new sen result structur
HvanderStok Jan 26, 2023
0177c3e
update example for new sen result structur
HvanderStok Jan 26, 2023
8795d6c
add info.txt samples for all methods
HvanderStok Jan 27, 2023
0912417
clean up
HvanderStok Jan 27, 2023
a3b75fd
plot specific classes and goals
HvanderStok Feb 1, 2023
ef75867
update plot functions
HvanderStok Feb 1, 2023
b7ea4d8
update sensitivity example
HvanderStok Feb 1, 2023
111e4ac
create verbose sensitivity example
HvanderStok Feb 1, 2023
a37f9a0
remove option to choose single analysis variable
HvanderStok Feb 2, 2023
9503a3a
option to specify result file data type
HvanderStok Feb 2, 2023
bfc4ef5
ctreate example for DymolaAPI
HvanderStok Feb 2, 2023
0e68e78
update .gitignore
HvanderStok Feb 2, 2023
eb2a34f
check index
HvanderStok Feb 3, 2023
6d8ea9f
update requirements
HvanderStok Feb 10, 2023
d2ff9a6
option to specify data format for simulation files
HvanderStok Feb 10, 2023
b39c420
heatmap for S2 results
HvanderStok Feb 14, 2023
dc3cf81
add save for reporduction
HvanderStok Feb 23, 2023
7a96c8f
verbose sensitivity example
HvanderStok Feb 27, 2023
4f3970a
add use_suffix to plot functions
HvanderStok Feb 27, 2023
b06cfb1
sensitivity example with dymola api
HvanderStok Feb 27, 2023
93adbd3
clean up
HvanderStok Feb 27, 2023
2d85202
remove info_samples
HvanderStok Feb 27, 2023
28f9fcd
fix plot heatmaps single goal
HvanderStok Feb 27, 2023
4a5ed9b
clean up
HvanderStok Feb 27, 2023
75bb560
test sensitivity analysis
HvanderStok Feb 27, 2023
50ba2ca
select by threshold for verbose analysis
HvanderStok Feb 28, 2023
6094409
test secelct by threshold verbose
HvanderStok Feb 28, 2023
1ec27bb
update example with verbose selection of tuner
HvanderStok Feb 28, 2023
462a2c0
Merge branch '46-Update-unit-tests-to-new-python-versions' into 43-Im…
HvanderStok Feb 28, 2023
9f90af5
update requirements for ci tests
HvanderStok Feb 28, 2023
d4e32b5
test: mock os.getlogin
HvanderStok Feb 28, 2023
ed7c003
test: import os
HvanderStok Feb 28, 2023
1306acf
chore(examples): Automatic commit of example files in Markdown and Ju…
Feb 28, 2023
3b97e63
increas pylint
HvanderStok Feb 28, 2023
5a3cccd
Merge remote-tracking branch 'origin/43-Improvement-of-sensitivity-an…
HvanderStok Feb 28, 2023
993ddba
increas pylint
HvanderStok Mar 2, 2023
0728438
increas pylint
HvanderStok Mar 2, 2023
7653842
ci: test new python version 39
HvanderStok Mar 14, 2023
25ce692
clean up
HvanderStok Mar 17, 2023
097b975
update ci
HvanderStok Mar 21, 2023
ec38a64
fix ci
HvanderStok Mar 21, 2023
0664081
ci: remove ref 18-add-example-file-converter
HvanderStok Mar 21, 2023
0d44938
increas version
HvanderStok Mar 21, 2023
e63da38
Merge branch 'master' into 43-Improvement-of-sensitivity-analysis
HvanderStok Mar 31, 2023
cec93bd
update changelog
HvanderStok Mar 31, 2023
a521de2
update documentation of sensitivity classes
HvanderStok Mar 31, 2023
77beca8
move load_files into run function; fix typos
HvanderStok Nov 23, 2023
251efff
working time dependent sensitvity for single core and no saved files
HvanderStok Nov 30, 2023
c8a5ec9
Merge remote-tracking branch 'origin/master' into 43-Improvement-of-s…
Nov 30, 2023
9c35c5c
update run_time_dependent for sobol second order
Nov 30, 2023
5ea734d
start working on loading files in run_time_dependent
HvanderStok Dec 5, 2023
22a330a
Merge branch '43-Improvement-of-sensitivity-analysis' of https://gith…
HvanderStok Dec 5, 2023
e776540
fix load_files for run_time_dependent
HvanderStok Dec 6, 2023
d9a6f73
add save results to run_time_dependent
Dec 6, 2023
880497f
test time and memory usage
Dec 6, 2023
a087232
first implementation of mp for run_time_dependent load_files=True
Dec 6, 2023
4948d79
add function _load_tsteps
Dec 13, 2023
5526e4f
working time dependent sensitivity for all cases
HvanderStok Dec 20, 2023
ec9392e
Merge remote-tracking branch 'origin/master' into 43-Improvement-of-s…
HvanderStok Dec 20, 2023
203516c
add simple plot function for time dependent sen results
HvanderStok Dec 21, 2023
f133f97
add verbose plotting for single parameter
HvanderStok Dec 21, 2023
5f3b5b4
Add documentation for plot functions
HvanderStok Dec 22, 2023
31ba15d
clean up
HvanderStok Jan 3, 2024
35c055a
update examples
HvanderStok Jan 3, 2024
3d65d66
fix bug
HvanderStok Jan 3, 2024
78f6d86
add tests for time dependent sensitivity
HvanderStok Jan 3, 2024
900fbc0
fix bug for older python version
HvanderStok Jan 4, 2024
a6b6825
update ci and changelog
HvanderStok Jan 4, 2024
a2e6eb8
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 4, 2024
b07b78c
clean up and documentation
HvanderStok Jan 4, 2024
e36807c
Merge remote-tracking branch 'origin/43-Improvement-of-sensitivity-an…
HvanderStok Jan 4, 2024
fc27836
chore: minor text adjustments and adding todos of review for example
FWuellhorst Jan 8, 2024
aa53390
fix typo
HvanderStok Jan 10, 2024
4939d7a
update functions _save and _conv_local_results
HvanderStok Jan 10, 2024
95936f9
minor update docstring
HvanderStok Jan 10, 2024
9ac4f91
restructure sensitivity plotting function into own module
HvanderStok Jan 10, 2024
187fb96
remove **kwargs from plot fuctions
HvanderStok Jan 10, 2024
462ccd2
fix bug
HvanderStok Jan 10, 2024
e8f1e04
test ci pylint
HvanderStok Jan 10, 2024
0ed5675
test ci pylint
HvanderStok Jan 10, 2024
e4fbe52
update plot function layout and titles
HvanderStok Jan 10, 2024
ac3f442
use pylintrc from ebcpy
HvanderStok Jan 10, 2024
80373c4
add trimming of parameter names from visulaizer to plotting function
HvanderStok Jan 17, 2024
222dac8
increas pylint
HvanderStok Jan 17, 2024
37c7a29
add new examples to converter
HvanderStok Jan 17, 2024
06ba540
add plotting INFO messages
HvanderStok Jan 17, 2024
19ec78e
increas pylint
HvanderStok Jan 17, 2024
501b424
increas pylint
HvanderStok Jan 17, 2024
95edb86
fix typos in file names
HvanderStok Jan 17, 2024
0be6fb1
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 17, 2024
9fa8bac
update example README
HvanderStok Jan 17, 2024
7828021
Merge remote-tracking branch 'origin/43-Improvement-of-sensitivity-an…
HvanderStok Jan 17, 2024
dee2a36
update documentation
HvanderStok Jan 17, 2024
993492f
update links in README
HvanderStok Jan 17, 2024
5d0bd15
update links in README
HvanderStok Jan 17, 2024
130a1bc
update example
HvanderStok Jan 17, 2024
6a42f16
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 17, 2024
4868075
fix example file converter
HvanderStok Jan 18, 2024
e81b7e3
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 18, 2024
c02e1cb
update example for jupyter notebook
HvanderStok Jan 18, 2024
70ff8e6
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 18, 2024
fc90ad6
add logger info of finished sensitivity analysis
HvanderStok Jan 19, 2024
cda3f83
ignore some warnings in example
HvanderStok Jan 19, 2024
ab52990
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 19, 2024
d99ee10
update example
HvanderStok Jan 19, 2024
3dd833e
Merge branch '43-Improvement-of-sensitivity-analysis' of https://gith…
HvanderStok Jan 19, 2024
00c7160
update dymola sensitivity example
HvanderStok Jan 19, 2024
d0a35d2
update example
HvanderStok Jan 19, 2024
358e119
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 19, 2024
d2b4c17
rename verbose sensitivity examples
HvanderStok Jan 26, 2024
2562d7b
rename verbose sensitivity examples
HvanderStok Jan 26, 2024
2cc394d
chore(examples): Automatic commit of example files in Markdown and Ju…
Jan 26, 2024
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
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ exclude_lines =
if __name__ == '__main__':
raise ImportError
except Exception as error:
except ImportError
except ImportError
plt.show()
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*.bak
.project
.pydevproject
aixcalibuha/examples/testzone
examples/testzone
examples/results

# pip install #
#####################
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ stages:
variables:
COVERAGE_TYPE: "FMU"
PAGES_BRANCH: master
EXLUDE_PYTHON: 37
EXCLUDE_PYTHON: 37
GIT_REPO: RWTH-EBC/AixCaliBuHA
PYTHON_PACKAGE_NAME: "aixcalibuha"
PYTHON_VERSION: "registry.git.rwth-aachen.de/ebc/ebc_all/gitlab_ci/templates:python_3.9"
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@

- **v0.3.1**
- Issue 41: Fix logging and add kwarg

- **v1.0.0**
- Issue 43: Improvement of sensitivity analysis
FWuellhorst marked this conversation as resolved.
Show resolved Hide resolved
- Enables verbose sensitivity analysis and the reuse of simulations
- It is now possible to use verbose sensitivity analysis for an automatic selection of tuner parameters
- Enables multiprocessing for the entire sensitivity process
- Sensitivity analysis is now usable for large models and data
- Add time dependent sensitivity analysis
- Ends support vor python 3.7
HvanderStok marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions aixcalibuha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"""
from .data_types import CalibrationClass, TunerParas, Goals
from .calibration import Calibrator, MultipleClassCalibrator
from .sensitivity_analysis import SobolAnalyzer, MorrisAnalyzer
__version__ = "0.3.1"
from .sensitivity_analysis import SobolAnalyzer, MorrisAnalyzer, FASTAnalyzer, PAWNAnalyzer
__version__ = "1.0.0"
32 changes: 25 additions & 7 deletions aixcalibuha/calibration/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Dict
from copy import copy
import numpy as np
import pandas as pd
from ebcpy import data_types, Optimizer
from ebcpy.simulationapi import SimulationAPI
from aixcalibuha.utils import visualizer, MaxIterationsReached
Expand Down Expand Up @@ -243,13 +244,13 @@ def obj(self, xk, *args):
)
return self.ret_val_on_error

total_res = self._kpi_and_logging_calculation(
total_res, unweighted_objective = self._kpi_and_logging_calculation(
xk_descaled=xk_descaled,
counter=self._counter,
results=sim_target_data
)

return total_res
return total_res, unweighted_objective

def mp_obj(self, x, *args):
# Initialize list for results
Expand Down Expand Up @@ -304,7 +305,7 @@ def mp_obj(self, x, *args):
if result is None:
total_res_list[idx] = self.ret_val_on_error
continue
total_res = self._kpi_and_logging_calculation(
total_res, unweighted_objective = self._kpi_and_logging_calculation(
xk_descaled=xk_descaled_list[idx],
counter=self._counter,
results=result
Expand Down Expand Up @@ -370,7 +371,7 @@ def _kpi_and_logging_calculation(self, *, xk_descaled, counter, results):
f"of iterations {self.max_itercount} has been reached."
)

return total_res
return total_res, unweighted_objective

def calibrate(self, framework, method=None, **kwargs) -> dict:
"""
Expand Down Expand Up @@ -486,7 +487,7 @@ def save_results(self, parameter_values: dict, filename: str):
with open(s_path, 'w') as json_file:
json.dump(parameter_values, json_file, indent=4)

def validate(self, validation_class: CalibrationClass, calibration_result: Dict):
def validate(self, validation_class: CalibrationClass, calibration_result: Dict, verbose=False):
"""
Validate the given calibration class based on the given
values for tuner_parameters.
Expand All @@ -501,10 +502,10 @@ def validate(self, validation_class: CalibrationClass, calibration_result: Dict)
self.logger.log(f"Start validation of model: {self.sim_api.model_name} with "
f"framework-class {self.__class__.__name__}")
# Use start-time of calibration class
self.calibration_class = validation_class
start_time = self._apply_start_time_method(
start_time=self.calibration_class.start_time
)
self.calibration_class = validation_class
old_tuner_paras = copy(self.calibration_class.tuner_paras)
tuner_values = list(calibration_result.values())
self.calibration_class.tuner_paras = TunerParas(
Expand All @@ -526,12 +527,29 @@ def validate(self, validation_class: CalibrationClass, calibration_result: Dict)
# Scale the tuner parameters
xk = self.tuner_paras.scale(tuner_values)
# Evaluate objective
obj = self.obj(xk=xk)
obj, unweighted_objective = self.obj(xk=xk)
self.logger.validation_callback_func(
obj=obj
)
# Reset tuner_parameters to avoid unwanted behaviour
self.calibration_class.tuner_paras = old_tuner_paras
if verbose:
weights = [1]
objectives = [obj]
goals = ['all']
for goal, val in unweighted_objective.items():
weights.append(val[0])
objectives.append(val[1])
goals.append(goal)
index = pd.MultiIndex.from_product(
[[validation_class.name], goals],
names=['Class', 'Goal']
)
obj_verbos = pd.DataFrame(
{'weight': weights, validation_class.goals.statistical_measure: objectives},
index=index
)
return obj_verbos
return obj

def _handle_error(self, error):
Expand Down
2 changes: 2 additions & 0 deletions aixcalibuha/calibration/multi_class_calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def calibrate(self, framework, method=None, **kwargs) -> dict:
for cal_run in self._cal_history:
for p_name in cal_run['res']['Parameters'].index:
parameter_values[p_name] = cal_run['res']['Parameters'][p_name]
for p_name, res_intersection in res_tuner.items():
parameter_values[p_name] = res_intersection
self.save_results(parameter_values=parameter_values,
filename='MultiClassCalibrationResult')

Expand Down
4 changes: 1 addition & 3 deletions aixcalibuha/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ def eval_difference(self, verbose=False, penaltyfactor=1):
)
# Apply penalty function
_diff = _diff * penaltyfactor

_verbose_calculation[self._weightings[i]] = _diff
_verbose_calculation[goal_name] = (self._weightings[i], _diff)
total_difference += self._weightings[i] * _diff

if verbose:
return total_difference, _verbose_calculation
return total_difference
Expand Down
4 changes: 3 additions & 1 deletion aixcalibuha/sensitivity_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
This package contains classes to perform
sensitivity analysis with.
"""
from .sensitivity_analyzer import SenAnalyzer
from .sensitivity_analyzer import SenAnalyzer, _del_duplicates, _rename_tuner_names
from .sobol import SobolAnalyzer
from .morris import MorrisAnalyzer
from .fast import FASTAnalyzer
from .pawn import PAWNAnalyzer
90 changes: 90 additions & 0 deletions aixcalibuha/sensitivity_analysis/fast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
Adds the FASTAnalyzer to the available
classes of sensitivity analysis.
"""
from SALib.sample import fast_sampler as fast
from SALib.analyze import fast as analyze_fast
import numpy as np
from aixcalibuha.sensitivity_analysis import SenAnalyzer
from aixcalibuha import CalibrationClass
import warnings


class FASTAnalyzer(SenAnalyzer):
"""
Sobol method from SALib https://salib.readthedocs.io/en/latest/api.html#fast-fourier-amplitude-sensitivity-test
HvanderStok marked this conversation as resolved.
Show resolved Hide resolved
A variance-based method which can compute the sensitivity measures
'S1' and 'ST'.

Additional arguments:
FWuellhorst marked this conversation as resolved.
Show resolved Hide resolved

:keyword int M:
Default 4, used for the fast-method
:keyword seed:
Used for the fast-method
"""

def __init__(self, sim_api, **kwargs):
super().__init__(
sim_api=sim_api,
**kwargs)
# Set additional kwargs
self.M = kwargs.pop("M", 4)
self.seed = kwargs.pop("seed", None)

@property
def analysis_variables(self):
"""The analysis variables of the FAST method"""
return ['S1', 'ST']

def analysis_function(self, x, y):
"""
Use the SALib.analyze.fast method to analyze the simulation results.

:param np.array x:
placeholder for the `X` parameter of the morris method not used for sobol
:param np.array y:
The NumPy array containing the model outputs
:return:
returns the result of the SALib.analyze.fast method (from the documentation:
Returns a dictionary with keys 'S1' and 'ST', where each entry is a list of
size D (the number of parameters) containing the indices in the same order
as the parameter file.)
"""
return analyze_fast.analyze(self.problem, y,
M=self.M)

def create_sampler_demand(self):
"""
Function to create the sampler parameters for the fast method
"""
return {'M': self.M}

def generate_samples(self):
"""
Run the sampler for fast and return the results.

:return:
The list of samples generated as a NumPy array with one row per sample
and each row containing one value for each variable name in `problem['names']`.
:rtype: np.ndarray
"""
return fast.sample(self.problem,
N=self.num_samples,
**self.create_sampler_demand())

def _get_res_dict(self, result: dict, cal_class: CalibrationClass, analysis_variable: str):
"""
Convert the result object to a dict with the key
being the variable name and the value being the result
associated to self.analysis_variable.
"""
names = self.create_problem(cal_class.tuner_paras)['names']
if result is None:
return {var_name: np.abs(res_val)
for var_name, res_val in zip(names,
np.zeros(len(names)))}
else:
return {var_name: np.abs(res_val)
for var_name, res_val in zip(names,
result[analysis_variable])}
19 changes: 14 additions & 5 deletions aixcalibuha/sensitivity_analysis/morris.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Adds the MorrisAnalyzer to the available
classes of sensitivity analysis.
"""
import numpy as np
from SALib.sample import morris
from SALib.analyze import morris as analyze_morris
from aixcalibuha.sensitivity_analysis import SenAnalyzer
Expand All @@ -10,10 +11,14 @@

class MorrisAnalyzer(SenAnalyzer):
"""
Moris method from SALib https://salib.readthedocs.io/en/latest/api.html#method-of-morris
An elementary effects (O-a-T) method which computes the sensitivity
HvanderStok marked this conversation as resolved.
Show resolved Hide resolved
measures 'mu', 'mu_star' and 'sigma' with a confidence interval for mu_star.

Additional arguments:

:keyword int num_levels:
Default 4, used for the morris-method
Default num_samples, used for the morris-method
:keyword optimal_trajectories:
Used for the morris-method
:keyword bool local_optimization:
Expand All @@ -24,14 +29,14 @@ def __init__(self, sim_api, **kwargs):
sim_api=sim_api,
**kwargs)
# Set additional kwargs
self.num_levels = kwargs.pop("num_levels", 4)
self.num_levels = kwargs.pop("num_levels", self.num_samples)
self.optimal_trajectories = kwargs.pop("optimal_trajectories", None)
self.local_optimization = kwargs.pop("local_optimization", True)

@property
def analysis_variables(self):
"""The analysis variables of the sobol method"""
return ['mu_star', 'sigma', 'mu_star_conf']
return ['mu_star', 'mu', 'sigma', 'mu_star_conf']

def analysis_function(self, x, y):
"""
Expand Down Expand Up @@ -71,10 +76,14 @@ def generate_samples(self):
N=self.num_samples,
**self.create_sampler_demand())

def _get_res_dict(self, result: dict, cal_class: CalibrationClass):
def _get_res_dict(self, result: dict, cal_class: CalibrationClass, analysis_variable: str):
"""
Convert the result object to a dict with the key
being the variable name and the value being the result
associated to self.analysis_variable.
"""
return dict(zip(result['names'], result[self.analysis_variable]))
if result is None:
names = cal_class.tuner_paras.get_names()
return dict(zip(names, np.zeros(len(names))))
else:
return dict(zip(result['names'], result[analysis_variable]))
Loading