--- myst: substitutions: macro: python: 1-6,14-34,38-41,44-61,64-67 cpp: 4-24,28-46,49-52,58 bloc1: python: 58-61,64 cpp: 43-46,49 bloc2: python: "56" cpp: "4" sentence: python: "line used right before the sampler creation" cpp: "very first line" --- # Macro "**samplingConstrLHSEllipses.{{extension}}**" ## Objective This macro shows the usage of the `TConstrLHS` class when one wants to create a constrained LHS with non-linear constraints. In order to illustate the concept, it is applied on three input variables drawn from uniform distribution with well-thought boundaries (as the concept of the LHS is to have nicely distributed marginals). The constraints are excluding the inner part of an ellipse for one of the input plane and the outter part of another ellipse for another input plane. ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/sampler/use_cases/" + language + "/samplingConstrLHSEllipses." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + macro[language] + "\n" + "```" }} The very beginning of these macros is the `nicegrid` method which is here only to show the nice marginal distributions and the scatter plots. One can clearly skip this part to focus on the rest in the main function. The macro very much looks like any other {{doe}} generating macro above: the dataserver is created along with the canvas object and the problem is defined along with the input variables and the number of locations to be produced. Once done, then the `TConstrLHS` instance is created with the four following lines: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/sampler/use_cases/" + language + "/samplingConstrLHSEllipses." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} The constructor is pretty obvious, as it takes only the dataserver object and the number of locations. Once created the main method to be called is the `addConstraint` function which has been largely discussed in [](#sampler_stochastic_method_tconstrlhs). The first argument of this method is the pointer to the C++ function which has been included in our macro through the {{sentence[language]}}: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/sampler/use_cases/" + language + "/samplingConstrLHSEllipses." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} which contains the `CircularRules` function. The rest of the argument are the number of constraints, the size of the list of parameters and its content. Finally the `nicegrid` method is called to produce the nice plot shown in {numref}`use_cases_samplingConstrLHSEllipses` ## Graph {{ "```{figure} " + parent_dir + "/roottest/build/uranie/doc/sampler/use_cases/" + language + "/lhs_ellipses/samplingConstrLHSEllipses.png\n" + ":align: center\n" + ":name: use_cases_samplingConstrLHSEllipses\n" + figure_scale + "\n" + "\n" + "Graph of the macro **\"samplingConstrLHSEllipses." + extension + "\"**" + "\n" + "```" }}