--- myst: substitutions: macro: python: 1-6,14-39,42-57,60-86,89-105,108-168 cpp: 1-7,11-34,38-53,56-83,86-141,147 bloc1: python: 16-20 cpp: 11-16 bloc2: python: 24-30 cpp: 20-26 bloc3: python: 51-54 cpp: 48-50 bloc4: python: 56-57,60-66 cpp: 52-53,56-63 bloc5: python: 79-83 cpp: 76-80 dedent: python: ":dedent: \n" cpp: "" --- (use_cases_macro_reoptimizer_bar_vizir_moead)= # Macro "**reoptimizeHollowBarVizirMoead.{{extension}}**" ## Objective The objective of the macro is to optimize the section and distortion of the hollow bar defined in [](#reoptimizer_problem_example_problem) using the evolutionary solvers, with a reduce number of points to compose the Pareto set/front. This example is comparing both the usual Vizir genetic algorithm and the MOEAD implementation that is meant to be a many-objective criteria algorithm. A short discussion on the many-objective aspect can be found in {{metho}}. ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarVizirMoead." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + macro[language] + "\n" + "```" }} The variables are defined as follow: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarVizirMoead." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} where the first two are the input ones while the last ones are computed using the provided code (as explained in [](#reoptimizer_problem_example_problem)). This code is configured through these lines {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarVizirMoead." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} The usual {{Relaun}} construction is followed, using a `TSequentialRun` runner. The first solver is defined in these lines {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarVizirMoead." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + dedent[language] + "```" }} Combining the runner, solver and dataserver, the master object is created and the objective and constraint are defined. This is done in: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarVizirMoead." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + dedent[language] + "```" }} In a second block a new dataserver is created along with a new genetic solver in these lines: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarVizirMoead." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc5[language] + "\n" + dedent[language] + "```" }} The idea here is to use the Moead algorithm whose principle in few words is to split the space into a certain numbers of direction intervals (set by the argument in the function `setMoeadDiversity`). This should provide a Pareto front with a better homogeneity in the front member distribution (particularly visible here when the size of the requested ensemble is small). The second method, `setStoppingCriteria(1)` states that the only stopping criteria available is the total number of estimation, allowed in the `setSize` method. Finally, the last function to be called is the `setSize` one, with a peculiar first argument here: the size of the pareto can be chosen but if 0 is put (as done here) the number of elements will be the number of intervals defined previously plus one (the plus one comes from the fact that the elements are created at the edge of every interval, so for 20 intervals, there are 21 edges in total). The rest of the code is creating the plot shown below in which both Pareto set and front are compared. ## Graph {{ "```{figure} " + parent_dir + "/roottest/build/uranie/doc/reoptimizer/use_cases/" + language + "/bar_vizir_moead/reoptimizeHollowBarVizirMoead.png\n" + ":align: center\n" + ":name: use_cases_reoptimizeHollowBarVizirMoead\n" + figure_scale + "\n" + "\n" + "Graph of the macro **\"reoptimizeHollowBarVizirMoead." + extension + "\"**" + "\n" + "```" }}