Objective and constraints history

Preliminaries: instantiation and execution of the MDO scenario

Let’s start with the following code lines which instantiate and execute the MDOScenario :

from gemseo.api import create_discipline, create_scenario

formulation = 'MDF'

disciplines = create_discipline(["SobieskiPropulsion", "SobieskiAerodynamics",
                                 "SobieskiMission", "SobieskiStructure"])

scenario = create_scenario(disciplines,
                           formulation=formulation,
                           objective_name="y_4",
                           maximize_objective=True,
                           design_space="design_space.txt")

scenario.set_differentiation_method("user")

algo_options = {'max_iter': 10, 'algo': "SLSQP"}
for constraint in ["g_1","g_2","g_3"]:
    scenario.add_constraint(constraint, 'ineq')

scenario.execute(algo_options)

ObjConstrHist

Description

The ObjConstrHist post processing plots the objective history in a line chart with constraint violation indication by color in the background.

By default, all the constraints are considered. A sublist of constraints can be passed as options. It is possible either to save the plot, to show the plot or both.

Options

  • constr_names, list(str) - The constraint names to plot. If empty, plot all.

  • extension, str - The file extension.

  • file_path, str - The base paths of the files to export. Relative to the working directory.

  • save, bool - If True, export plot to a file.

  • show, bool - If True, display the plot windows.

Case of the MDF formulation

To visualize the objective and constraints history of the scenario, we use the execute_post() API method with the keyword "ObjConstrHist" and additional arguments concerning the type of display (file , screen, both):

scenario.post_process("ObjConstrHist", constr_names=["g_1", "g_2", "g_3"], save=True, show=False, file_path="mdf")
../../_images/mdf_objective_and_constraints_history.png

History of the constraints on the Sobieski use case for the MDF formulation using the ObjConstrHist plot.