def CreateOptimizer(optimization_settings, model, external_analyzer=EmptyAnalyzer()): _ValidateSettings(optimization_settings) model_part_controller = model_part_controller_factory.CreateController( optimization_settings["model_settings"], model) analyzer = analyzer_factory.CreateAnalyzer(optimization_settings, model_part_controller, external_analyzer) communicator = communicator_factory.CreateCommunicator( optimization_settings) if optimization_settings["design_variables"]["type"].GetString( ) == "vertex_morphing": return VertexMorphingMethod(optimization_settings, model_part_controller, analyzer, communicator) else: raise NameError( "The following type of design variables is not supported by the optimizer: " + variable_type)
def CreateOptimizer(optimization_settings, model, external_analyzer=EmptyAnalyzer()): default_settings = Parameters(""" { "model_settings" : { }, "objectives" : [ ], "constraints" : [ ], "design_variables" : { }, "optimization_algorithm" : { }, "output" : { } }""") for key in default_settings.keys(): if not optimization_settings.Has(key): raise RuntimeError( "CreateOptimizer: Required setting '{}' missing in 'optimization_settings'!" .format(key)) optimization_settings.ValidateAndAssignDefaults(default_settings) model_part_controller = model_part_controller_factory.CreateController( optimization_settings["model_settings"], model) analyzer = analyzer_factory.CreateAnalyzer(optimization_settings, model_part_controller, external_analyzer) communicator = communicator_factory.CreateCommunicator( optimization_settings) if optimization_settings["design_variables"]["type"].GetString( ) == "vertex_morphing": return VertexMorphingMethod(optimization_settings, model_part_controller, analyzer, communicator) else: raise NameError( "The following type of design variables is not supported by the optimizer: " + variable_type)