fastoad.io.configuration.configuration module

Module for building OpenMDAO problem from configuration file

class fastoad.io.configuration.configuration.FASTOADProblemConfigurator(conf_file_path: str | PathLike = None)[source]

Bases: object

class for configuring an OpenMDAO problem from a configuration file

See description of configuration file.

Parameters:

conf_file_path – if provided, configuration will be read directly from it

property input_file_path: str

path of file with input variables of the problem

property output_file_path: str

path of file where output variables will be written

get_problem(read_inputs: bool = False, auto_scaling: bool = False) FASTOADProblem[source]

Builds the OpenMDAO problem from current configuration.

Parameters:
  • read_inputs – if True, the created problem will already be fed with variables from the input file

  • auto_scaling – if True, automatic scaling is performed for design variables and constraints

Returns:

the problem instance

load(conf_file: str | PathLike)[source]

Reads the problem definition

Parameters:

conf_file – Path to the file to open

save(filename: str | PathLike = None)[source]

Saves the current configuration If no filename is provided, the initially read file is used.

Parameters:

filename – file where to save configuration

write_needed_inputs(source_file_path: str | PathLike = None, source_formatter: IVariableIOFormatter = None)[source]

Writes the input file of the problem with unconnected inputs of the configured problem.

Written value of each variable will be taken:

  1. from input_data if it contains the variable

  2. from defined default values in component definitions

Parameters:
  • source_file_path – if provided, variable values will be read from it

  • source_formatter – the class that defines format of input file. if not provided, expected format will be the default one.

get_optimization_definition() Dict[source]
Returns information related to the optimization problem:
  • Design Variables

  • Constraints

  • Objectives

Returns:

dict containing optimization settings for current problem

set_optimization_definition(optimization_definition: Dict)[source]

Updates configuration with the list of design variables, constraints, objectives contained in the optimization_definition dictionary.

Keys of the dictionary are: “design_var”, “constraint”, “objective”.

Configuration file will not be modified until save() is used.

Parameters:

optimization_definition – dict containing the optimization problem definition

make_local(new_folder_path: str | PathLike, copy_models: bool = False)[source]

Modify the current configurator so that all input and output files will be in the indicated folder.

Parameters:
  • new_folder_path – the folder path that will contain in/out files

  • copy_models – True if local models (declared in module_folders) should be copied in new_folder_path