Source code for symtolerance2.symtolsettings

#!/usr/bin/python
# -*- coding: <UTF-8> -*-

"""
Python Version : 3.6

$LastChangedRevision$
$LastChangedDate::                           $


Copyright (c) 2018, Linz Center of Mechatronics GmbH (LCM) http://www.lcm.at/
All rights reserved.
"""

"""
This module defines settings dataclasses used for the SyMSpace tolerance evaluation module ´symtol´.
"""

from dataclasses import dataclass, field
import logging
from typing import List, Any


[docs]@dataclass() class SimControlSettings: """ Settings used to control processing of the indices and JobManager related information """ remoteCompute: bool = True # SyMSpace regenerate setting optimize: bool = True # SyMSpace regenerate setting runSim: bool = True # SyMSpace regenerate setting batch: int = 5 # Controls execution order of the project # indices, i.e., after `batch` indices are # regenerated, index is reset to first index. # Set `batch` to the number of indices to update # all indices in order. indexTimeout: int = 120 # minutes, timeout per index, set with respect to the longest function evaluation in the # project (timeout counter is reset every time a job is assigned to the jobmanager!). # UPDATE: timeout is passed to job manager - not used internally! # UPDATE 2: indexTimeout has no effect at the moment! jobTimeout: int = 0 # minutes, set timeout for individual jobs, 0 means no timeout! tolDataPickleInterval: int = 0 # pickle tolerance related data (results and variables) after every
# tolDataPickleInterval sample evaluations, if 0, tolData is only pickled at the end # of a run (at the end of start()).
[docs]@dataclass() class SimProjectSettings: """ Settings to control the SyMSpace project which is used during tolerance calculation """ clone: bool = True # if True, a clone of the actual SyMSpace project is created # and used for tolerance analysis, if False, the actual project is used cleanUp: bool = True # if True and `clone`==True, the temporary SyMSpace Project is removed after defined number # of samples is evaluated. # if True and `clone`==False, all indices except one are removed from the actual SyMSpace project # If set to False this is not done automatically and can be done manually using # SymTol.cleanUpProject() indices: int = 20 # number of indices used for calculation of tolerance samples initializeIndices: bool = True # set False, if indices should not be newly initialized when starting a tolerance analysis
# UPDATE: in the actual implementation this setting makes no sense -> do NOT set to False!
[docs]@dataclass class SymTolSettings: """ Main settings class to handle configurations of `symtol.SymTol` class """ baseProjectFile: str # set internally to reload the base project -> do not set manually! samplesCount: int = 500 # defines how many samples to be evaluated storeIndices: bool = False # if True, whole SyMSpace project tree of every simulated sample # is stored as pickle file in `storeIndicesDirecotry`. storeIndicesDirectory: str = None # defines where pickles are stored if `storeIndices`==True # it is recommended to keep the direcotry path which is used by default and set # automatically. If not, it has to be defined as absolute path! #verbose = True loggingLevel = 'INFO' # set to: DEBUG, INFO, WARNING, ERROR, CRITICAL, todo: has no effect so far -> to be implemented!!! seperate for console and file logging! simProject: SimProjectSettings = SimProjectSettings() simControl: SimControlSettings = SimControlSettings()
""" @dataclass(frozen=True) class AtTolerance: @dataclass class Uniform: params: List[str] = field(default_factory=lambda: ['lower_tol', 'upper_tol']) @dataclass class Norm: params: List[str] = field(default_factory=lambda: ['sigma']) @dataclass class Variable: distributions: List[any] = field(default_factory=lambda: [Uniform(), Norm()]) """