--- myst: substitutions: macro: python: 1-75 cpp: 1-4,7-74,77 bloc1: python: 8-13 cpp: 7-12 bloc2: python: 15,19-36 cpp: 14,18-31 bloc3: python: 45-50 cpp: 44-49 bloc4: python: 52-62 cpp: 51-61 bloc5: python: 64-69 cpp: 63-68 console: python: 2-12 cpp: 4-14 dedent: python: ":dedent: \n" cpp: "" --- (use_cases_macro_reoptimizer_bar_code)= # Macro "**reoptimizeHollowBarCode.{{extension}}**" ## Objective The objective of the macro is to optimize the section of the hollow bar defined in [](#reoptimizer_problem_example_problem) using the NLopt solvers (reducing it to a single-criterion optimisation as already explained in [](#reoptimizer_local_solver). This can be done with different solvers, the results being achieved within more or less time and following the requested constraints with more or less accuracy (depending on the hypothesis embedded by the chosen solver). ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarCode." + 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 + "/reoptimizeHollowBarCode." + 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 + "/reoptimizeHollowBarCode." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} The usual {{Relaun}} construction is followed, using a `TSequentialRun` runner and the solver is chosen in these lines: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarCode." + 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 (keeping in mind that only single-criterion problems are implemented when dealing with NLopt, so the distortion criteria is downgraded to a constraint). This is done in {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarCode." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + dedent[language] + "```" }} Finally the starting point is set along with the maximal number of evaluation just before starting the loop. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarCode." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc5[language] + "\n" + dedent[language] + "```" }} ## Console This macro leads to the following result {{ "```{literalinclude} " + parent_dir + "/roottest/build/uranie/doc/reoptimizer/use_cases/" + language + "/reoptimizeHollowBarCode_clean.log\n" + ":language: none\n" + ":lines: " + console[language] + "\n" + "```" }}