profit.config

Module Contents

Classes

AbstractConfig

General class with methods which are useful for all Config classes.

BaseConfig

This class and its modular subclasses provide all possible configuration parameters.

RunConfig

Run configuration with the following sub classes:

FitConfig

Configuration for the surrogate and encoder. Currently, the only sub config is for the GaussianProcess classes.

ALConfig

Active learning configuration.

AlgorithmALConfig

General class with methods which are useful for all Config classes.

SimpleALConfig

General class with methods which are useful for all Config classes.

McmcConfig

General class with methods which are useful for all Config classes.

AcquisitionFunctionConfig

Acquisition function configuration.

SimpleExplorationConfig

Acquisition function configuration.

ExplorationWithDistancePenaltyConfig

Acquisition function configuration.

WeightedExplorationConfig

Acquisition function configuration.

ProbabilityOfImprovementConfig

Acquisition function configuration.

ExpectedImprovementConfig

Acquisition function configuration.

ExpectedImprovement2Config

Acquisition function configuration.

AlternatingExplorationConfig

Acquisition function configuration.

UIConfig

Configuration for the Graphical User Interface.

DefaultConfig

Default config for all run sub configs which just updates the attributes with user entries.

Functions

represent_ordereddict(dumper, data)

dict_constructor(loader, node)

load_config_from_py(filename)

Load the configuration parameters from a python file into dict.

Attributes

VALID_FORMATS

yaml has to be configured to represent OrderedDict

_mapping_tag

profit.config.VALID_FORMATS = ('.yaml', '.py')

yaml has to be configured to represent OrderedDict see https://stackoverflow.com/questions/16782112/can-pyyaml-dump-dict-items-in-non-alphabetical-order and https://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml-mappings-as-ordereddicts

profit.config.represent_ordereddict(dumper, data)[source]
profit.config.dict_constructor(loader, node)[source]
profit.config._mapping_tag
profit.config.load_config_from_py(filename)[source]

Load the configuration parameters from a python file into dict.

class profit.config.AbstractConfig(**entries)[source]

Bases: profit.util.base_class.CustomABC

General class with methods which are useful for all Config classes.

labels
defaults
update(**entries)[source]

Updates the attributes with user inputs. A warning is issued if the attribute set by the user is unknown.

Parameters:

entries (dict) – User input of the config parameters.

process_entries(base_config)[source]

After the attributes are set, they are formatted and edited to standardize the user inputs.

Parameters:

base_config (BaseConfig) – In sub configs, the data from the base config is needed.

set_defaults(default_dict)[source]

Default values are set from a default dictionary, which is usually located in the global profit.defaults file.

create_subconfig(sub_config_label, **entries)[source]

Instances of sub configs are created from a string or a dictionary.

Parameters:
  • sub_config_label (str) – Dict key of registered sub config.

  • entries (dict) – User input parameters.

__getitem__(item)[source]

Implements the dictionary like get method with brackets.

Parameters:

item (str) – Label of the attribute to return.

Returns:

Attribute or if the attribute is a sub config, a dictionary of the sub config items.

items()[source]

Implements the dictionary like self.items() method.

Returns:

List of (key, value) tuples of the class attributes.

Return type:

list

get(item, default=None)[source]

Implements the dictionary like get method with a default value.

Parameters:
  • item (str) – Label of the attribute to return.

  • default – Default value, if the attribute is not found.

Returns:

Attribute or the default value.

class profit.config.BaseConfig(base_dir=defaults.base_dir, **entries)[source]

Bases: AbstractConfig

This class and its modular subclasses provide all possible configuration parameters.

Parts of the Config:
  • base_dir

  • run_dir

  • config_file

  • include

  • ntrain

  • variables

  • files
    • input

    • output

  • run
    • runner

    • interface

    • pre

    • post

  • fit
    • surrogate

    • save / load

    • fixed_sigma_n

  • active_learning

  • ui

Base configuration for fundamental parameters.

Parameters:
  • base_dir (str) – Base directory.

  • run_dir (str) – Run directory.

  • config_path (str) – Path to configuration file.

  • include (list) – Paths to custom files which are loaded in the beginning.

  • files (dict) – Paths for input and output files.

  • ntrain (int) – Number of training samples.

  • variables (dict) – All variables.

  • input (dict) – Input variables.

  • output (dict) – Output variables.

  • independent (dict) – Independent variables, if the result of the simulation is a vector.

labels
process_entries()[source]

Sets absolute paths, creates variables and delegates to the sub configs.

classmethod from_file(filename=defaults.config_file)[source]

Creates a configuration class from a .yaml or .py file.

load_includes()[source]
class profit.config.RunConfig(**entries)[source]

Bases: AbstractConfig

Run configuration with the following sub classes:
  • runner
    • local

    • slurm

  • interface
    • memmap

    • zeromq

  • pre
    • template

  • post
    • json

    • numpytxt

    • hdf5

A default sub class which just updates the entries from a user input is also implemented and used if the class from the user input is not found.

Custom config classes can also be registered, e.g. as a custom runner:

@RunnerConfig.register("custom")
class CustomRunner(LocalRunnerConfig):
    def process_entries(self, base_config):
        # do something else than the usual LocalRunnerConfig
        pass

Default values from the global profit.defaults.py file are loaded.

labels
defaults = 'run'
update(**entries)[source]

Updates the attributes with user inputs. No warning is issued if the attribute set by the user is unknown.

Parameters:

entries (dict) – User input of the config parameters.

class profit.config.FitConfig(**entries)[source]

Bases: AbstractConfig

Configuration for the surrogate and encoder. Currently, the only sub config is for the GaussianProcess classes.

labels
defaults = 'fit'
update(**entries)[source]

Updates the attributes with user inputs. A warning is issued if the attribute set by the user is unknown.

Parameters:

entries (dict) – User input of the config parameters.

process_entries(base_config)[source]

Set ‘load’ and ‘save’ as well as the encoder.

class profit.config.ALConfig(**entries)[source]

Bases: AbstractConfig

Active learning configuration.

labels
defaults = 'active_learning'
process_entries(base_config)[source]

After the attributes are set, they are formatted and edited to standardize the user inputs.

Parameters:

base_config (BaseConfig) – In sub configs, the data from the base config is needed.

class profit.config.AlgorithmALConfig(**entries)[source]

Bases: AbstractConfig

General class with methods which are useful for all Config classes.

labels
defaults
class profit.config.SimpleALConfig(**entries)[source]

Bases: AlgorithmALConfig

General class with methods which are useful for all Config classes.

labels
defaults = 'al_algorithm_simple'
process_entries(base_config)[source]

After the attributes are set, they are formatted and edited to standardize the user inputs.

Parameters:

base_config (BaseConfig) – In sub configs, the data from the base config is needed.

class profit.config.McmcConfig(**entries)[source]

Bases: AlgorithmALConfig

General class with methods which are useful for all Config classes.

labels
defaults = 'al_algorithm_mcmc'
process_entries(base_config)[source]

After the attributes are set, they are formatted and edited to standardize the user inputs.

Parameters:

base_config (BaseConfig) – In sub configs, the data from the base config is needed.

class profit.config.AcquisitionFunctionConfig(**entries)[source]

Bases: AbstractConfig

Acquisition function configuration.

labels
defaults
process_entries(base_config)[source]

After the attributes are set, they are formatted and edited to standardize the user inputs.

Parameters:

base_config (BaseConfig) – In sub configs, the data from the base config is needed.

class profit.config.SimpleExplorationConfig(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_simple_exploration'
class profit.config.ExplorationWithDistancePenaltyConfig(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_exploration_with_distance_penalty'
class profit.config.WeightedExplorationConfig(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_weighted_exploration'
class profit.config.ProbabilityOfImprovementConfig(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_probability_of_improvement'
class profit.config.ExpectedImprovementConfig(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_expected_improvement'
class profit.config.ExpectedImprovement2Config(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_expected_improvement_2'
class profit.config.AlternatingExplorationConfig(**entries)[source]

Bases: AcquisitionFunctionConfig

Acquisition function configuration.

labels
defaults = 'al_acquisition_function_alternating_exploration'
class profit.config.UIConfig(**entries)[source]

Bases: AbstractConfig

Configuration for the Graphical User Interface.

labels
defaults = 'ui'
class profit.config.DefaultConfig(**entries)[source]

Bases: AbstractConfig

Default config for all run sub configs which just updates the attributes with user entries.

labels
defaults
update(**entries)[source]

Updates the attributes with user inputs. A warning is issued if the attribute set by the user is unknown.

Parameters:

entries (dict) – User input of the config parameters.