**consolidate** ============================== .. py:module:: optimeed.consolidate .. toctree:: :titlesonly: :maxdepth: 1 OpenTURNS_interface/index.rst SALib_interface/index.rst fit/index.rst parametric_analysis/index.rst sensitivity_analysis/index.rst sensitivity_analysis_evaluation/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: optimeed.consolidate.Option_class optimeed.consolidate.Option_int optimeed.consolidate.ListDataStruct optimeed.consolidate.AutosaveStruct optimeed.consolidate.Parametric_Collection optimeed.consolidate.Parametric_parameter optimeed.consolidate.Parametric_minmax optimeed.consolidate.Parametric_analysis optimeed.consolidate.SensitivityParameters optimeed.consolidate.Restrained_SensitivityParameters optimeed.consolidate.SensitivityAnalysis_LibInterface Functions ~~~~~~~~~ .. autoapisummary:: optimeed.consolidate.getPath_workspace optimeed.consolidate.rsetattr optimeed.consolidate.rgetattr optimeed.consolidate.leastSquare optimeed.consolidate.do_fit optimeed.consolidate.evaluate_sensitivities optimeed.consolidate.evaluate_sensitivities_fast optimeed.consolidate.prepare_embarrassingly_parallel_sensitivity optimeed.consolidate.gather_embarrassingly_parallel_sensitivity optimeed.consolidate.launch_embarrassingly_parallel_sensitivity optimeed.consolidate.launch_missing_embarrassingly_parallel_sensitivity optimeed.consolidate.condition_aborted_sensitivities optimeed.consolidate.printIfShown Attributes ~~~~~~~~~~ .. autoapisummary:: optimeed.consolidate.SHOW_INFO optimeed.consolidate.has_openTurns optimeed.consolidate.has_SALib .. py:class:: Option_class .. py:attribute:: options_bool :type: Dict[int, Option_bool] .. py:attribute:: options_str :type: Dict[int, Option_str] .. py:attribute:: options_int :type: Dict[int, Option_int] .. py:attribute:: options_float :type: Dict[int, Option_float] .. py:attribute:: options_dict :type: Dict[int, Option_dict] .. py:method:: get_option_attributes() :staticmethod: .. py:method:: add_option(idOption, theOption) .. py:method:: get_option_name(idOption) .. py:method:: get_option_value(idOption) .. py:method:: set_option(idOption, value) .. py:method:: _pack_options() .. py:method:: __str__() Return str(self). .. py:class:: Option_int(name, based_value, choices=None) Bases: :py:obj:`Base_Option` .. py:attribute:: name :type: str .. py:attribute:: value :type: int .. py:method:: set_value(value) .. py:class:: ListDataStruct(compress_save=False) Bases: :py:obj:`ListDataStruct_Interface` .. py:attribute:: _DATA_STR :value: 'data' .. py:attribute:: _COMPRESS_SAVE_STR :value: 'module_tree' .. py:method:: __len__() .. py:method:: get_length() .. py:method:: clone(filename) Clone the datastructure to a new location .. py:method:: save(filename) Save data using json format. The data to be saved are automatically detected, see :meth:`~optimeed.core.myjson.obj_to_json` .. py:method:: extract_collection_from_indices(indices) Extract data from the collection at specific indices, and return it as new collection .. py:method:: _format_str_save() Save data using json format. The data to be saved are automatically detected, see :meth:`~optimeed.core.myjson.obj_to_json` .. py:method:: _format_data_lines() .. py:method:: _get_json_module_tree() .. py:method:: load(filename, theClass=None) :staticmethod: Load the file filename. :param filename: file to load :param theClass: optional. Can be used to fix unpickling errors. :return: self-like object .. py:method:: add_data(data_in) Add a data to the list .. py:method:: get_data() Get full list of datas .. py:method:: get_data_generator() Get a generator to all the data stored .. py:method:: get_data_at_index(index) .. py:method:: set_data(theData) Set full list of datas .. py:method:: set_data_at_index(data_in, index) Replace data at specific index .. py:method:: extract_collection_from_attribute(attributeName) Convenience class to create a sub-collection from an attribute of all the items. :param attributeName: Name of the attribute to extract :return: ListDataStruct .. py:method:: reset_data() .. py:method:: delete_points_at_indices(indices) Delete several elements from the Collection :param indices: list of indices to delete .. py:method:: merge(collection) Merge a collection with the current collection :param collection: :class:`~optimeed.core.Collection.Collection` to merge .. py:method:: get_nbr_elements() :return: the number of elements contained inside the structure .. py:class:: AutosaveStruct(dataStruct, filename='', change_filename_if_exists=True) Structure that provides automated save of DataStructures .. py:method:: __str__() Return str(self). .. py:method:: get_filename() Get set filename .. py:method:: set_filename(filename, change_filename_if_exists) :param filename: Filename to set :param change_filename_if_exists: If already exists, create a new filename .. py:method:: stop_autosave() Stop autosave .. py:method:: start_autosave(timer_autosave, safe_save=True) Start autosave .. py:method:: save(safe_save=True) Save .. py:method:: get_datastruct() Return :class:'~DataStruct_Interface' .. py:method:: __getstate__() .. py:method:: __setstate__(state) .. py:function:: getPath_workspace() Get workspace path (i.e., location where optimeed files will be created). Create directory if doesn't exist. .. py:function:: rsetattr(obj, attr, val) setattr, but recursively. Works with list (i.e. theObj.myList[0].var_x) .. py:function:: rgetattr(obj, attr) getattr, but recursively. Works with list. .. py:class:: Parametric_Collection(**kwargs) Bases: :py:obj:`optimeed.core.collection.ListDataStruct` .. py:method:: get_extension() :staticmethod: File extension used for datastructure .. py:class:: Parametric_parameter(analyzed_attribute, reference_device) Abstract class for a parametric parameter .. py:method:: get_values() :abstractmethod: .. py:method:: get_reference_device() .. py:method:: get_analyzed_attribute() .. py:class:: Parametric_minmax(analyzed_attribute, reference_device, minValue, maxValue, is_relative=False, npoints=10) Bases: :py:obj:`Parametric_parameter` Abstract class for a parametric parameter .. py:method:: get_values() .. py:class:: Parametric_analysis(theParametricParameter, theCharacterization, filename_collection=None, autosave=False) Bases: :py:obj:`optimeed.core.Option_class` .. py:attribute:: NUMBER_OF_CORES :value: 1 .. py:method:: run() Instantiates input arguments for analysis .. py:method:: evaluate(theDevice) .. py:method:: initialize_output_collection() .. py:function:: leastSquare(function, functionArgs, x_data, y_data) Least square calculation (sum (y-ลท)^2) :param function: Function to fit :param functionArgs: Arguments of the function :param x_data: x-axis coordinates of data to fit :param y_data: y-axis coordinates of data to fit :return: least squares .. py:function:: do_fit(fitFunction, x_data, y_data, *args, fitCriterion=leastSquare) Main method to fit a function :param fitFunction: the function to fit (link to it) :param x_data: x-axis coordinates of data to fit :param y_data: y-axis coordinates of data to fit :param args: for each parameter: [min, max] admissible value :param fitCriterion: fit criterion to minimize. Default: least square :return: [arg_i_optimal, ...], y estimated, error. .. py:function:: evaluate_sensitivities(theSensitivityParameters: SensitivityParameters, numberOfCores=2, studyname='sensitivity', indices_to_evaluate=None) Evaluate the sensitivities :param theSensitivityParameters: class`~SensitivityParameters` :param numberOfCores: number of core for multicore evaluation :param studyname: Name of the study, that will be the subfolder name in workspace :param indices_to_evaluate: if None, evaluate all param_values, otherwise if list: evaluate subset of param_values defined by indices_to_evaluate :return: collection of class`~SensitivityResults` .. py:function:: evaluate_sensitivities_fast(theSensitivityParameters: SensitivityParameters) Deactivate multicore and save management for fast results .. py:class:: SensitivityParameters(param_values, list_of_optimization_variables, theDevice, theMathsToPhys, theCharacterization) Bases: :py:obj:`optimeed.core.SaveableObject` Abstract class for dynamically type-hinted objects. This class is to solve the special case where the exact type of an attribute is not known before runtime, yet has to be saved. .. py:attribute:: list_of_optimization_variables :type: List[optimeed.optimize.Real_OptimizationVariable] .. py:attribute:: param_values :type: List[List[float]] .. py:method:: get_device() .. py:method:: get_M2P() .. py:method:: get_charac() .. py:method:: get_optivariables() .. py:method:: get_paramvalues() .. py:method:: get_additional_attributes_to_save() Return list of attributes corresponding to object, whose type cannot be determined statically (e.g. topology change) .. py:class:: Restrained_SensitivityParameters(*args) Bases: :py:obj:`SensitivityParameters` Class to perform Sensitivty Analysis on a subset of the full parameters .. py:method:: create_from_sensitivityParameters(theSensitivityParameters) :staticmethod: .. py:method:: set_selected(selection) .. py:method:: get_optivariables() .. py:method:: get_paramvalues() .. py:class:: SensitivityAnalysis_LibInterface(theSensitivityParameters: SensitivityParameters, theObjectives) Interface a library for sensitivity analysis :param theSensitivityParameters: :class:`optimeed.consolidate.sensitivity_analysis.SensitivityParameters` :param theObjectives: array-like objective associated to evaluation, using Sobol sampling .. py:method:: sample_sobol(theOptimizationVariables, N) :staticmethod: :abstractmethod: .. py:method:: get_sobol_S1() :abstractmethod: Get first order sobol indices :return: .. py:method:: get_sobol_S1conf() :abstractmethod: .. py:method:: get_sobol_S2() :abstractmethod: Get second order sobol indices :return: .. py:method:: get_sobol_ST() :abstractmethod: Get total order sobol indices :return: .. py:method:: get_sobol_STconf() :abstractmethod: .. py:method:: get_summary() Display a summary of the sobol indices .. py:method:: get_convergence_S1(stepsize=1) Create dictionary for convergence plot - First order index :param stepsize: increments of sampling size :return: Dictionary .. py:method:: get_convergence_ST(stepsize=1) Create dictionary for convergence plot - Total order index :param stepsize: increments of sampling size :return: Dictionary .. py:method:: _get_convergence(method, stepsize) .. py:method:: get_SA_params() .. py:method:: set_SA_params(theSensitivityParameters) .. py:method:: set_objectives(theObjectives) .. py:function:: prepare_embarrassingly_parallel_sensitivity(theSensitivityParameters, studyname) Initialize sensitivity analysis folder :param theSensitivityParameters: :param studyname: Folder to be created in Workspace :return: .. py:function:: gather_embarrassingly_parallel_sensitivity(theSensitivityParameters, studyname) Gather the results. If some are missing, display the indices. :param theSensitivityParameters: :param studyname: :return: .. py:function:: launch_embarrassingly_parallel_sensitivity(theSensitivityParameters, studyname, base_index, mult_factor=1) Single job launcher for an embarrassingly parallel evaluation :param theSensitivityParameters: :param studyname: Name of the folder in Workspace in which the study is performed :param base_index: start index (Formula: index to evaluate = base_index*mult_factor) :param mult_factor: Multiplication factor of the base_index. Allows to overcome QOSMaxJobPerUserLimit in clusters. :return: .. py:function:: launch_missing_embarrassingly_parallel_sensitivity(theSensitivityParameters, studyname, missing_list, base_index, mult_factor=1) Same as launch_embarrassingly_parallel_sensitivity, but using the 'missing_list' arg used for mapping .. py:function:: condition_aborted_sensitivities(foldername) .. py:function:: printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='\n') .. py:data:: SHOW_INFO :value: 1 .. py:data:: has_openTurns :value: True .. py:data:: has_SALib :value: True