fastoad.io.configuration.configuration module¶
Module for building OpenMDAO problem from configuration file
- class fastoad.io.configuration.configuration.FASTOADProblemConfigurator(conf_file_path=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¶
path of file with input variables of the problem
- property output_file_path¶
path of file where output variables will be written
- get_problem(read_inputs: bool = False, auto_scaling: bool = False) fastoad.openmdao.problem.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)[source]¶
Reads the problem definition
- Parameters
conf_file – Path to the file to open or a file descriptor
- save(filename: Optional[str] = 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: Optional[str] = None, source_formatter: Optional[fastoad.io.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:
from input_data if it contains the variable
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
- class fastoad.io.configuration.configuration.AutoUnitsDefaultGroup(**kwargs)[source]¶
Bases:
openmdao.core.group.Group
OpenMDAO group that automatically use self.set_input_defaults() to resolve declaration conflicts in variable units.
Set the solvers to nonlinear and linear block Gauss–Seidel by default.
- Parameters
**kwargs (dict) – dict of arguments available here and in all descendants of this Group.
- configure()[source]¶
Configure this group to assign children settings.
This method may optionally be overidden by your Group’s method.
You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.
You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.
- Available attributes:
name pathname comm options system hieararchy with attribute access
- class fastoad.io.configuration.configuration.FASTOADModel(**kwargs)[source]¶
Bases:
fastoad.io.configuration.configuration.AutoUnitsDefaultGroup
OpenMDAO group that defines active submodels after the initialization of all its subsystems, and inherits from
AutoUnitsDefaultGroup
for resolving declaration conflicts in variable units.It allows to have a submodel choice in the initialize() method of a FAST-OAD module, but to possibly override it with the definition of
active_submodels
(i.e. from the configuration file).Set the solvers to nonlinear and linear block Gauss–Seidel by default.
- Parameters
**kwargs (dict) – dict of arguments available here and in all descendants of this Group.
- active_submodels¶
Definition of active submodels that will be applied during setup()
- setup()[source]¶
Build this group.
This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.
You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.
- Available attributes:
name pathname comm options