<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing with OASIS Tables v3.0 20080202//EN" "https://jats.nlm.nih.gov/nlm-dtd/publishing/3.0/journalpub-oasis3.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table" xml:lang="en" dtd-version="3.0" article-type="research-article">
  <front>
    <journal-meta><journal-id journal-id-type="publisher">GMD</journal-id><journal-title-group>
    <journal-title>Geoscientific Model Development</journal-title>
    <abbrev-journal-title abbrev-type="publisher">GMD</abbrev-journal-title><abbrev-journal-title abbrev-type="nlm-ta">Geosci. Model Dev.</abbrev-journal-title>
  </journal-title-group><issn pub-type="epub">1991-9603</issn><publisher>
    <publisher-name>Copernicus Publications</publisher-name>
    <publisher-loc>Göttingen, Germany</publisher-loc>
  </publisher></journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.5194/gmd-16-5265-2023</article-id><title-group><article-title>AutoQS v1: automatic parametrization of QuickSampling based on training images analysis</article-title><alt-title>AutoQS v1</alt-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author" corresp="yes" rid="aff1 aff2 aff3">
          <name><surname>Gravey</surname><given-names>Mathieu</given-names></name>
          <email>research@mgravey.com</email>
        <ext-link>https://orcid.org/0000-0002-0871-1507</ext-link></contrib>
        <contrib contrib-type="author" corresp="no" rid="aff2">
          <name><surname>Mariethoz</surname><given-names>Grégoire</given-names></name>
          
        <ext-link>https://orcid.org/0000-0002-8820-2808</ext-link></contrib>
        <aff id="aff1"><label>1</label><institution>Institute for Interdisciplinary Mountain Research, Austrian Academy of Sciences, Innsbruck, Austria</institution>
        </aff>
        <aff id="aff2"><label>2</label><institution>Institute of Earth Surface Dynamics, Faculty of Geosciences and Environment, University of Lausanne, Lausanne, Switzerland</institution>
        </aff>
        <aff id="aff3"><label>3</label><institution>Department of Physical Geography, Faculty of Geosciences, Utrecht University, Utrecht, the Netherlands</institution>
        </aff>
      </contrib-group>
      <author-notes><corresp id="corr1">Mathieu Gravey (research@mgravey.com)</corresp></author-notes><pub-date><day>14</day><month>September</month><year>2023</year></pub-date>
      
      <volume>16</volume>
      <issue>17</issue>
      <fpage>5265</fpage><lpage>5279</lpage>
      <history>
        <date date-type="received"><day>15</day><month>September</month><year>2022</year></date>
           <date date-type="rev-request"><day>17</day><month>October</month><year>2022</year></date>
           <date date-type="rev-recd"><day>2</day><month>May</month><year>2023</year></date>
           <date date-type="accepted"><day>26</day><month>June</month><year>2023</year></date>
      </history>
      <permissions>
        <copyright-statement>Copyright: © 2023 Mathieu Gravey</copyright-statement>
        <copyright-year>2023</copyright-year>
      <license license-type="open-access"><license-p>This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this licence, visit <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/4.0/">https://creativecommons.org/licenses/by/4.0/</ext-link></license-p></license></permissions><self-uri xlink:href="https://gmd.copernicus.org/articles/gmd-16-5265-2023.html">This article is available from https://gmd.copernicus.org/articles/gmd-16-5265-2023.html</self-uri><self-uri xlink:href="https://gmd.copernicus.org/articles/gmd-16-5265-2023.pdf">The full text article is available as a PDF file from https://gmd.copernicus.org/articles/gmd-16-5265-2023.pdf</self-uri>
      <abstract><title>Abstract</title>

      <p id="d2e107">Multiple-point geostatistics are widely used to simulate complex spatial structures based on a training image. The practical applicability of these methods relies on the possibility of finding optimal training images and parametrization of the simulation algorithms. While methods for automatically selecting training images are available, parametrization can be cumbersome. Here, we propose to find an optimal set of parameters using only the training image as input. The difference between this and previous work that used parametrization optimization is that it does not require the definition of an objective function. Our approach is based on the analysis of the errors that occur when filling artificially constructed patterns that have been borrowed from the training image. Its main advantage is to eliminate the risk of overfitting an objective function, which may result in variance underestimation or in verbatim copy of the training image. Since it is not based on optimization, our approach finds a set of acceptable parameters in a predictable manner by using the knowledge and understanding of how the simulation algorithms work. The technique is explored in the context of the recently developed QuickSampling algorithm, but it can be easily adapted to other pixel-based multiple-point statistics algorithms using pattern matching, such as direct sampling or single normal equation simulation (SNESIM).</p>
  </abstract>
    
<funding-group>
<award-group id="gs1">
<funding-source>Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung</funding-source>
<award-id>200021_162882</award-id>
</award-group>
</funding-group>
</article-meta>
  </front>
<body>
      

      
<sec id="Ch1.Sx1" specific-use="unnumbered">
  <title>Highlights</title>
      <p id="d2e119"><list list-type="bullet">
          <list-item>

      <p id="d2e124">Adaptive calibration as a function of the simulation progression</p>
          </list-item>
          <list-item>

      <p id="d2e130">Calibration depends on each training image</p>
          </list-item>
          <list-item>

      <p id="d2e136">Robust parametrization based on a rapid prior analysis of the training image</p>
          </list-item>
        </list></p>
</sec>
<sec id="Ch1.S1" sec-type="intro">
  <label>1</label><title>Introduction</title>
      <p id="d2e149">Geostatistics is extensively used in natural sciences to map spatial variables such as surface properties (e.g., soils, geomorphology, meteorology) and subsurface geological features (e.g., porosity, hydraulic conductivity, 3D geological facies). Its main applications involve the estimation and simulation of natural phenomena. In this paper, we focus on simulation approaches.</p>
      <p id="d2e152">Traditional two-point geostatistical simulations preserve the histogram and variogram inferred from point data (Matheron, 1973). However, inherent limitations make the reproduction of complex structures difficult (Gómez-Hernández and Wen, 1998; Journel and Zhang, 2006). Multiple-point statistics (MPS), by accounting for more complex relations, enables the reproduction of such complex structures (Guardiano and Srivastava, 1993) but comes with its own limitations (Mariethoz and Caers, 2014). The main requirements for using MPS algorithms are (1) analog images (called training images) and (2) appropriate parametrization, while training images can often be provided by expert knowledge, and several methods have been proposed to automatically select one or a subset of appropriate training images among a set of candidates (Pérez et al., 2014; Abdollahifard et al., 2019). However, the parametrization of an MPS algorithm depends not only on the chosen training image but also on the specifics of the algorithm. This makes the task of finding a good parametrization cumbersome, and therefore users often have to resort to trial-and-error approaches (Meerschman et al., 2013). Here we will mainly focus on QuickSampling (QS) (Gravey and Mariethoz, 2020), which has two main parameters: <inline-formula><mml:math id="M1" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>, which defines the maximum number of conditional data points to consider during the search process, and <inline-formula><mml:math id="M2" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>, which is the number of best candidates from which to sample the simulated value. Additionally, QS supports a kernel that allows weighting each conditioning pixel in the pattern based on its position related to the simulated pixel. Direct sampling (DS) has the following parameters: <inline-formula><mml:math id="M3" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>, which has an identical role as in QS; “th”, which represents the pattern acceptance threshold, or the degree of similarity between local data patterns and the training image; and <inline-formula><mml:math id="M4" display="inline"><mml:mi>f</mml:mi></mml:math></inline-formula>, which is the maximum proportion of the image that can be explored for each simulated pixel. In summary, <inline-formula><mml:math id="M5" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> controls the spatial continuity, and <inline-formula><mml:math id="M6" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> or “th” and <inline-formula><mml:math id="M7" display="inline"><mml:mi>f</mml:mi></mml:math></inline-formula> control the variability.</p>
      <p id="d2e205">Over the last few years, several studies have addressed the challenge of automatically finding appropriate parameters for MPS simulation. These can be categorized in two approaches. The first approach is to assume that an optimal parametrization is related to the simulation grid (including possible conditioning data), the training image, and the MPS algorithm. In this vein, Dagasan et al. (2018) proposed a method that uses the known hard data from the simulation grid as a reference for computing the Jensen–Shannon divergence between histograms. Following this, they employ a simulated annealing optimization to update the MPS parameters until the metrics achieve the lowest divergence. This method is flexible enough to be adapted to any other metric. The second type of approach assumes that the parametrization is only related to the training image and the MPS algorithm. Along these lines, Baninajar et al. (2019) propose the MPS automatic parameter optimizer (MPS-APO) method based on the cross-validation of the training image (TI) to optimize simulation quality and CPU cost. In this approach, artificially generated gaps in the high-gradient areas of the training image are created, and a MPS algorithm is used to fill those gaps. The performance of a particular parametrization is quantified by assessing the correspondence between the filled and original training data. By design, this approach is extremely interesting for gap-filling problems. The authors state that it can be used for the parametrization of unconditional simulations; however, the use of limited gaps cannot guarantee the reproduction of long-range dependencies. Furthermore, due to the design of the framework for generating gaps, only MPS algorithms able to handle gap-filling problems can be used.</p>
      <p id="d2e208">While both approaches yield good results based on their objective functions, they all rely on a stochastic optimization process; therefore, the duration of the optimization process cannot be predetermined or controlled by the user. Furthermore, an objective function is needed, which can be difficult because it depends on the training image used: many metrics can be accounted for in the objective function, such as histogram, variogram, pattern histogram, connectivity function, and Euler characteristic, among others (Boisvert et al., 2010; Renard and Allard, 2013; Tan et al., 2013), or a weighted combination of these. Similarly, one has to define meta-parameters linked to the optimization algorithm itself, such as the cooling rate in simulated annealing or maximum number of iterations. As a result, MPS parameter optimization approaches tend to be complex and difficult to use.</p>
      <p id="d2e212">In this contribution, we propose a simplified optimization procedure for simulating complex systems. Rather than using a complex optimization algorithm, our approach focuses on finding optimal parameters to accurately simulate a single pixel in the system. The underlying principle of our approach is that if each pixel is accurately simulated, the resulting sequence of pixels will converge to an accurate representation of the real-world system being simulated. The goal is therefore to find the optimal parameters to simulate a single pixel using the training image as the only reference. Baninajar et al. (2019) showed that computing the prediction error (i.e., the error between the simulation and the reference) is an appropriate metric to identify optimal parameters. To find the optimal parameters for simulating a single pixel, we propose an exhaustive exploration of the parameter space and a computation of the prediction error between the simulation and the reference image.</p>
      <p id="d2e215">The remainder of this paper is structured as follows. Section 2 presents the proposed method. Section 3 evaluates the approach in terms of quantitative and qualitative metrics. Finally, Sect. 4 discusses the strengths and weaknesses of the proposed approach and presents the conclusions of this work.</p>
</sec>
<sec id="Ch1.S2">
  <label>2</label><title>Understanding and addressing verbatim copy in multiple-point simulation</title>
      <p id="d2e226">The principle underlying multiple-point simulation is that the neighborhood of a given pixel <inline-formula><mml:math id="M8" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> (the pattern generated by known or previously simulated pixels) is informative enough to constrain the probability density function of the value <inline-formula><mml:math id="M9" display="inline"><mml:mrow><mml:mi>Z</mml:mi><mml:mo>(</mml:mo><mml:mi>x</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>. This requires a training image with several pattern repetitions. The extended normal equation simulation (ENESIM) algorithm (Guardiano and Srivastava, 1993) computes the full probability distribution for each simulated pixel. To ensure that enough samples are used, the SNESIM (Strebelle, 2002) and the Impala (Straubhaar et al., 2011) algorithms include a parameter to define a minimum number of pattern replicates. Direct sampling (DS) (Mariethoz et al., 2010) adopts a different strategy by allowing for the interrupted exploration of the training image. It includes a distance threshold parameter that defines what is an acceptable match for a neighborhood; however, too small a threshold typically results in a single acceptable pattern in the training image, leading to exact replication of parts of the training image – a phenomenon known as verbatim copy. To reduce this issue, a parameter <inline-formula><mml:math id="M10" display="inline"><mml:mi>f</mml:mi></mml:math></inline-formula> is introduced, controlling the fraction of the explored training image. QuickSampling (QS) (Gravey and Mariethoz, 2020) also suffers from verbatim copy when the number of candidate patterns is set to <inline-formula><mml:math id="M11" display="inline"><mml:mrow><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:math></inline-formula>; the authors recommend the use of <inline-formula><mml:math id="M12" display="inline"><mml:mrow><mml:mi>k</mml:mi><mml:mo>&gt;</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:math></inline-formula> and highlight that <inline-formula><mml:math id="M13" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> is similar to the number of replicates in SNESIM or IMPALA. A value <inline-formula><mml:math id="M14" display="inline"><mml:mrow><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1.5</mml:mn></mml:mrow></mml:math></inline-formula> in QS can be seen as SNESIM with a minimum number of replicates of 1 for 50 % of the simulated values and 2 for the remaining values.</p>
      <p id="d2e301">The definition of verbatim copy is the unintended pasting of a large section from the training image to the simulation (patch-based approaches do so intentionally, e.g., Rezaee et al., 2013). This means that the relative position of the simulated values is the same as that in the training image. This occurs when the neighborhood constraints on the simulated pixels are too strong, and only the exact same patterns as those in the training image are acceptable. To detect this issue, a common strategy is to create a position map (similar to the index map), which represents the provenance of simulated values by mapping their original coordinates in the training image, as shown in Fig. 1.</p>
      <p id="d2e304">Figure 1 illustrates the most common forms of verbatim copy. The pure verbatim (the most common type of verbatim copy) is a simple copy of a large part of the image, with all pixels in the same order inside of the patches. Block verbatim typically appears when there are many replicates of a very specific type of pattern in the training image and few replicates of all other patterns. Consequently, the MPS algorithm uses common patterns for transitioning between copied blocks resulting from rare patterns. Structural verbatim occurs when the copied portion spreads throughout the simulation without giving a direct impression of copying (e.g., pure verbatim over a subset of pixels). Structural verbatim tends to appear when large-scale structures are unique in the training image, which often allows a visually satisfying image to be quickly obtained, but with large non-stationary features identical to the training image. Often, users are willing to allow verbatim on large-scale structures, but this can easily introduce bias between simulations. This is one of the hardest types of verbatim to detect. Typically, this can occur when the maximum neighborhood radius is too large, leading to the duplication of large structures in the initial phase of the simulation. Finally, no verbatim, which is the expected result of simulations, occurs when the position of pixels does not have any particular structure (i.e., their position is unpredictable).</p>

      <fig id="F1" specific-use="star"><label>Figure 1</label><caption><p id="d2e310">Visualization of verbatim copies using a position map. This is an extreme case that highlights that verbatim is not defined by the values simulated but by their position in the training image.</p></caption>
        <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f01.png"/>

      </fig>

</sec>
<sec id="Ch1.S3">
  <label>3</label><title>Method</title>
      <p id="d2e328">The objective of the approach presented here is to find an optimal set of parameters using only the training image and knowledge of the simulation algorithm's mechanics. The simulation algorithm is not used in this context; in fact, simulations are not required to obtain a proper calibration with the proposed method. The main target application of the presented approach is the pattern-matching simulation algorithm QuickSampling (QS), where the values, at a pixel scale, are directly sampled from the training image. The method is suitable for the simulation of continuous and/or categorical variables.</p>
      <p id="d2e331">Simulation algorithms such as QS can be summarized by Algorithm 1. The key operation occurs at Line 3, which is when the algorithm searches for an optimal match based on the neighboring conditioning data.</p><boxed-text content-type="algorithm" position="float" id="Ch1.Prog1"><label>Algorithm 1</label><caption><p id="d2e335">The sequential simulation algorithm. <inline-formula><mml:math id="M15" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M16" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>, and <inline-formula><mml:math id="M17" display="inline"><mml:mi mathvariant="italic">ω</mml:mi></mml:math></inline-formula>, the parametrization for QS.</p></caption><disp-quote content-type="algorithmic" specific-use="numbering{0}"><list>

    <list-item>

      <p id="d2e363" specific-use="STATE">Inputs:</p>
          </list-item>

    <list-item>

      <p id="d2e369" specific-use="STATE"><inline-formula><mml:math id="M18" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula>: training images</p>
          </list-item>

    <list-item>

      <p id="d2e381" specific-use="STATE"><inline-formula><mml:math id="M19" display="inline"><mml:mi>S</mml:mi></mml:math></inline-formula>: simulation grid, including the conditioning data</p>
          </list-item>

    <list-item>

      <p id="d2e393" specific-use="STATE"><inline-formula><mml:math id="M20" display="inline"><mml:mi>P</mml:mi></mml:math></inline-formula>: simulation path</p>
          </list-item>

    <list-item>

      <p id="d2e405" specific-use="STATE"><inline-formula><mml:math id="M21" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula>: parametrization</p>
          </list-item>

    <list-item>

            

      <p id="d2e420" specific-use="STATE"><inline-formula><mml:math id="M22" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>: number of neighbors</p>
          </list-item>

    <list-item>

            

      <p id="d2e436" specific-use="STATE"><inline-formula><mml:math id="M23" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>: the number of best candidates</p>
          </list-item>

    <list-item>

            

      <p id="d2e451" specific-use="STATE"><inline-formula><mml:math id="M24" display="inline"><mml:mi mathvariant="italic">ω</mml:mi></mml:math></inline-formula>: the kernel, by default uniform</p>
          </list-item>
        </list></disp-quote>
        <disp-quote content-type="algorithmic" specific-use="numbering{1}"><list>

    <list-item>

      <p id="d2e467" specific-use="FOR"><bold>for</bold> each unsimulated pixel <inline-formula><mml:math id="M25" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> following the path <inline-formula><mml:math id="M26" display="inline"><mml:mi>P</mml:mi></mml:math></inline-formula>: <bold>do</bold> <list>
    <list-item>
      <p id="d2e492" specific-use="STATE">Find the neighborhood <inline-formula><mml:math id="M27" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mfenced open="(" close=")"><mml:mi>x</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula> in <inline-formula><mml:math id="M28" display="inline"><mml:mi>S</mml:mi></mml:math></inline-formula> composed of the <inline-formula><mml:math id="M29" display="inline"><mml:mrow><mml:mi>n</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> closest neighbors</p></list-item>
    <list-item>
      <p id="d2e529" specific-use="STATE">Find a candidate in <inline-formula><mml:math id="M30" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> those matches <inline-formula><mml:math id="M31" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mfenced close=")" open="("><mml:mi>x</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula> using the parametrization <inline-formula><mml:math id="M32" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula></p></list-item>
    <list-item>
      <p id="d2e558" specific-use="STATE">Assign the value of the selected candidate to <inline-formula><mml:math id="M33" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> in <inline-formula><mml:math id="M34" display="inline"><mml:mi>S</mml:mi></mml:math></inline-formula></p></list-item></list></p>
          </list-item>

    <list-item>

      <p id="d2e577" specific-use="ENDFOR"><bold>end</bold> <bold>for</bold></p>
          </list-item>
        </list></disp-quote></boxed-text>
      <p id="d2e586">Here, we propose a divide-and-conquer approach that splits any pixel-based sequential simulation into its atomic operation: the simulation of a single pixel. We assume that if all pixels are perfectly simulated, then the resulting simulation should also be good. By a perfectly simulated pixel, we mean a pixel that respects the conditional probability distribution. When simulating a pixel, there may be numerous potential valid values, but at the very least, there should be one valid value; i.e., the conditional probability distribution should be represented in the data. This can be formalized by the following condition:

          <disp-formula id="Ch1.E1" content-type="numbered"><label>1</label><mml:math id="M35" display="block"><mml:mrow><mml:mfenced open="|" close="|"><mml:mfenced open="{" close="}"><mml:mrow><mml:mi>A</mml:mi><mml:mi mathvariant="normal">|</mml:mi><mml:mi>P</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi>A</mml:mi><mml:mi mathvariant="normal">|</mml:mi><mml:mi>N</mml:mi><mml:mo>(</mml:mo><mml:mi>x</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mfenced><mml:mo>&gt;</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:mfenced></mml:mfenced><mml:mo>≥</mml:mo><mml:mn mathvariant="normal">1</mml:mn><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

        where <inline-formula><mml:math id="M36" display="inline"><mml:mrow><mml:mfenced close="|" open="|"><mml:mo>.</mml:mo></mml:mfenced></mml:mrow></mml:math></inline-formula> represents the cardinality of a set. <inline-formula><mml:math id="M37" display="inline"><mml:mrow><mml:mi>P</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi>A</mml:mi><mml:mi mathvariant="normal">|</mml:mi><mml:mi>N</mml:mi><mml:mfenced close=")" open="("><mml:mi>x</mml:mi></mml:mfenced></mml:mrow></mml:mfenced></mml:mrow></mml:math></inline-formula> denotes the probability of <inline-formula><mml:math id="M38" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula> (a given value) knowing <inline-formula><mml:math id="M39" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mfenced close=")" open="("><mml:mi>x</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula>, the neighborhood.</p>
      <p id="d2e675">The proposed approach consists of finding a set of parameters that results in accurate samples for each pattern. At the same time, we want to avoid systematically sampling perfect matches (the exact same neighborhood is available in the training image), which results in verbatim copy.</p>
      <p id="d2e678">The search for the optimal parametrization is carried out by exhaustive exploration (Algorithm 2), and the choice of optimal parameters is based on a prediction error defined as the difference between the original value of the pattern and the value of the selected pattern in the training image.</p><boxed-text content-type="algorithm" position="float" id="Ch1.Prog2"><label>Algorithm 2</label><caption><p id="d2e682">The AutoQS algorithm.</p></caption><disp-quote content-type="algorithmic" specific-use="numbering{0}"><list>

    <list-item>

      <p id="d2e689" specific-use="STATE">Inputs:</p>
          </list-item>

    <list-item>

      <p id="d2e695" specific-use="STATE"><inline-formula><mml:math id="M40" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>: list of stages of the simulation (i.e., pattern decimation levels, equivalent to fractions of the simulation path)</p>
          </list-item>

    <list-item>

      <p id="d2e707" specific-use="STATE"><inline-formula><mml:math id="M41" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula>: list of discretized parameters</p>
          </list-item>

    <list-item>

      <p id="d2e719" specific-use="STATE"><inline-formula><mml:math id="M42" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> the training images</p>
          </list-item>

    <list-item>

      <p id="d2e731" specific-use="STATE"><inline-formula><mml:math id="M43" display="inline"><mml:mi>V</mml:mi></mml:math></inline-formula> a set of random positions (in practice we generated the random position on the fly)</p>
          </list-item>
        </list></disp-quote>
        <disp-quote content-type="algorithmic" specific-use="numbering{1}"><list>

    <list-item>

      <p id="d2e746" specific-use="STATE"><bold>for</bold> each possible combination of <inline-formula><mml:math id="M44" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M45" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula> <bold>do</bold> for all <inline-formula><mml:math id="M46" display="inline"><mml:mrow><mml:mi>v</mml:mi><mml:mo>∈</mml:mo><mml:mi>V</mml:mi></mml:mrow></mml:math></inline-formula>: <list>
    <list-item>
      <p id="d2e783" specific-use="STATE">Sample a neighborhood <inline-formula><mml:math id="M47" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mfenced open="(" close=")"><mml:mi>v</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula> from <inline-formula><mml:math id="M48" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> and decimate it according to stage <inline-formula><mml:math id="M49" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula></p></list-item>
    <list-item>
      <p id="d2e812" specific-use="STATE">Using <inline-formula><mml:math id="M50" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula>, find a candidate in <inline-formula><mml:math id="M51" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> that matches <inline-formula><mml:math id="M52" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mfenced close=")" open="("><mml:mi mathvariant="normal">v</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula> excluding for <inline-formula><mml:math id="M53" display="inline"><mml:mi>v</mml:mi></mml:math></inline-formula> itself</p></list-item>
    <list-item>
      <p id="d2e849" specific-use="STATE">Compute the error <inline-formula><mml:math id="M54" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> between the selected  candidate and <inline-formula><mml:math id="M55" display="inline"><mml:mrow><mml:mi>Z</mml:mi><mml:mo>(</mml:mo><mml:mi>v</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula></p></list-item></list></p>
          </list-item>

    <list-item>

      <p id="d2e875" specific-use="STATE"><bold>end for</bold></p>
          </list-item>

    <list-item>

      <p id="d2e882" specific-use="STATE">Analyze the errors <inline-formula><mml:math id="M56" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> to determine the best <inline-formula><mml:math id="M57" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula> for each <inline-formula><mml:math id="M58" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula></p>
          </list-item>
        </list></disp-quote></boxed-text>
      <p id="d2e907">The proposed algorithm explores a discretized parameter space <inline-formula><mml:math id="M59" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula> (Algorithm 2, Line 1) (e.g., for QS: <inline-formula><mml:math id="M60" display="inline"><mml:mrow><mml:mi>n</mml:mi><mml:mi>k</mml:mi><mml:mi mathvariant="italic">ω</mml:mi></mml:mrow></mml:math></inline-formula>). While this discretization is natural for some parameters, such as <inline-formula><mml:math id="M61" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> that is an integer, it can require an explicit discretization for other parameters, such as the kernel in QS (or “th” in DS). Furthermore, a key component of our method is the exploration of the parameter space for several representative stages <inline-formula><mml:math id="M62" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula> of the simulation (Algorithm 2, Line 1). In the case of a random path, the progress of the simulation is directly related to the density of the neighborhoods; i.e., when <inline-formula><mml:math id="M63" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> % of the pixels are simulated, on average <inline-formula><mml:math id="M64" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> % of neighbors are informed. To reproduce this behavior, at each stage <inline-formula><mml:math id="M65" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>, we randomly decimate patterns extracted from the TI by keeping only <inline-formula><mml:math id="M66" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> % pixels informed. For each combination <inline-formula><mml:math id="M67" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M68" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula>, multiple measures over a set of random locations <inline-formula><mml:math id="M69" display="inline"><mml:mi>V</mml:mi></mml:math></inline-formula> (<inline-formula><mml:math id="M70" display="inline"><mml:mrow><mml:mn mathvariant="normal">500</mml:mn><mml:mo>&lt;</mml:mo><mml:mfenced open="|" close="|"><mml:mi>V</mml:mi></mml:mfenced><mml:mo>&lt;</mml:mo><mml:mn mathvariant="normal">10</mml:mn><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mn mathvariant="normal">000</mml:mn><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> are computed in Lines 1–5 in Algorithm 2, with their mathematical expression shown in Eq. (2):

          <disp-formula id="Ch1.E2" content-type="numbered"><label>2</label><mml:math id="M71" display="block"><mml:mtable class="split" rowspacing="0.2ex" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>=</mml:mo></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mspace linebreak="nobreak" width="1em"/><mml:msqrt><mml:mrow><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mrow><mml:mfenced close="|" open="|"><mml:mi>V</mml:mi></mml:mfenced></mml:mrow></mml:mfrac></mml:mstyle><mml:munder><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>v</mml:mi><mml:mo>∈</mml:mo><mml:mi>V</mml:mi></mml:mrow></mml:munder><mml:msup><mml:mfenced open="(" close=")"><mml:mrow><mml:mi>Z</mml:mi><mml:mfenced close=")" open="("><mml:mi>v</mml:mi></mml:mfenced><mml:mo>-</mml:mo><mml:mi>Z</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:munder><mml:mi mathvariant="normal">Cand</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>∖</mml:mo><mml:mo mathvariant="italic">{</mml:mo><mml:mi>v</mml:mi><mml:mo mathvariant="italic">}</mml:mo></mml:mrow></mml:munder><mml:mfenced open="(" close=")"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>N</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mi>D</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:msqrt><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>

        where <inline-formula><mml:math id="M72" display="inline"><mml:mrow><mml:mi mathvariant="normal">Cand</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>N</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:math></inline-formula> returns a single candidate position for a given neighborhood <inline-formula><mml:math id="M73" display="inline"><mml:mi>N</mml:mi></mml:math></inline-formula> and follows the parametrization <inline-formula><mml:math id="M74" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula>. <inline-formula><mml:math id="M75" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:math></inline-formula> denotes a neighborhood around <inline-formula><mml:math id="M76" display="inline"><mml:mi>v</mml:mi></mml:math></inline-formula> that is decimated according to stage <inline-formula><mml:math id="M77" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>. <inline-formula><mml:math id="M78" display="inline"><mml:mi>V</mml:mi></mml:math></inline-formula> represents a random set of positions in the training image, and <inline-formula><mml:math id="M79" display="inline"><mml:mrow><mml:mi>Z</mml:mi><mml:mo>(</mml:mo><mml:mi>v</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> refers to the actual value at position <inline-formula><mml:math id="M80" display="inline"><mml:mrow><mml:mi>v</mml:mi><mml:mo>∈</mml:mo><mml:mi>V</mml:mi></mml:mrow></mml:math></inline-formula> in the training image. To avoid parameters that generate verbatim copy of the training image, the position <inline-formula><mml:math id="M81" display="inline"><mml:mi>v</mml:mi></mml:math></inline-formula> and its direct neighbors (in a small radius (here 5 pixels)) are excluded from the set of potential candidates. The set of candidates considering this exclusion is denoted by <inline-formula><mml:math id="M82" display="inline"><mml:mrow><mml:mi>T</mml:mi><mml:mo>∖</mml:mo><mml:mo mathvariant="italic">{</mml:mo><mml:mi>v</mml:mi><mml:mo mathvariant="italic">}</mml:mo></mml:mrow></mml:math></inline-formula> in Eq. (2). Furthermore, in the case of equality between several optimal options, we set as a rule to take the cheapest parameter set in terms of computational cost (e.g., the smallest <inline-formula><mml:math id="M83" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>). Figure 2 graphically represents the entire algorithm. Finally, for each stage considered, the set of parameters with the minimum associated error <inline-formula><mml:math id="M84" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> is considered optimal (Algorithm 2, Line 6):

          <disp-formula id="Ch1.E3" content-type="numbered"><label>3</label><mml:math id="M85" display="block"><mml:mrow><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">optimal</mml:mi></mml:msub><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>=</mml:mo><mml:munder><mml:mo movablelimits="false">min⁡</mml:mo><mml:mo mathvariant="italic">θ</mml:mo></mml:munder><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>.</mml:mo></mml:mrow></mml:math></disp-formula></p>

      <fig id="F2" specific-use="star"><label>Figure 2</label><caption><p id="d2e1296">All steps for a single pattern, summarizing Algorithm 2, Lines 2–4.</p></caption>
        <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f02.png"/>

      </fig>

</sec>
<sec id="Ch1.S4">
  <label>4</label><title>An efficient implementation</title>
      <p id="d2e1313">In practice, the implementation of Algorithm 2 separates <inline-formula><mml:math id="M86" display="inline"><mml:mi mathvariant="italic">θ</mml:mi></mml:math></inline-formula> into two parameter subsets: <inline-formula><mml:math id="M87" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M88" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>. The <inline-formula><mml:math id="M89" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> subset consists of all parameters that influence the calculation of a single pattern match, which varies depending on the algorithm used. For instance, in QS, it includes the number of neighbors <inline-formula><mml:math id="M90" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> and the kernel <inline-formula><mml:math id="M91" display="inline"><mml:mi mathvariant="italic">ω</mml:mi></mml:math></inline-formula>, while in DS, it comprises the threshold “th” and <inline-formula><mml:math id="M92" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>. On the other hand, <inline-formula><mml:math id="M93" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> encompasses parameters related to the sampling process of the training image. For QS, this includes the number of candidates to keep <inline-formula><mml:math id="M94" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>, while for DS, it involves the fraction <inline-formula><mml:math id="M95" display="inline"><mml:mi>f</mml:mi></mml:math></inline-formula> of the training image being scanned.</p>
      <p id="d2e1403">Our implementation precomputes and stores all matches for a specific <inline-formula><mml:math id="M96" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> parametrization (e.g., a value of <inline-formula><mml:math id="M97" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> and all matches for <inline-formula><mml:math id="M98" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>). Consequently, the saved matches of <inline-formula><mml:math id="M99" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> can be employed to swiftly evaluate all options for the parameters in <inline-formula><mml:math id="M100" display="inline"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>=</mml:mo><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub><mml:mo>×</mml:mo><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> (e.g., we can process for <inline-formula><mml:math id="M101" display="inline"><mml:mrow><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn><mml:mo>,</mml:mo><mml:mn mathvariant="normal">2</mml:mn><mml:mo>,</mml:mo><mml:mn mathvariant="normal">3</mml:mn><mml:mo>,</mml:mo><mml:mi mathvariant="normal">…</mml:mi><mml:msub><mml:mi>k</mml:mi><mml:mi mathvariant="normal">max</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>). This two-phase approach considerably decreases redundant calculations.</p>
      <p id="d2e1494">The algorithm can be further accelerated by terminating the estimation of <inline-formula><mml:math id="M102" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> if the error remains at a high level after assessing only a small amount of samples from <inline-formula><mml:math id="M103" display="inline"><mml:mi>V</mml:mi></mml:math></inline-formula> (here set to 500). To this end, we increase <inline-formula><mml:math id="M104" display="inline"><mml:mi>V</mml:mi></mml:math></inline-formula> for the parameter combinations of interest, i.e., parametrization with potentially the lowest <inline-formula><mml:math id="M105" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula>. This entails iterating and verifying at each step whether additional computations are required. Only places respecting the following inequality are refined with extra measures:

          <disp-formula id="Ch1.E4" content-type="numbered"><label>4</label><mml:math id="M106" display="block"><mml:mrow><mml:mrow><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced></mml:mrow><mml:mrow><mml:mo>-</mml:mo><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">min</mml:mi></mml:msub><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>&lt;</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle><mml:mi mathvariant="italic">σ</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>+</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle><mml:mi mathvariant="italic">σ</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">min</mml:mi></mml:msub><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>,</mml:mo></mml:mrow></mml:mrow></mml:math></disp-formula>

        with

              <disp-formula specific-use="gather"><mml:math id="M107" display="block"><mml:mtable displaystyle="true"><mml:mtr><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">min</mml:mi></mml:msub><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>=</mml:mo><mml:munder><mml:mo movablelimits="false">min⁡</mml:mo><mml:mo mathvariant="italic">θ</mml:mo></mml:munder><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:mtable class="split" rowspacing="0.2ex" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mi mathvariant="italic">σ</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced><mml:mo>=</mml:mo></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mspace linebreak="nobreak" width="1em"/><mml:msqrt><mml:mrow><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mrow><mml:mfenced close="|" open="|"><mml:mi>V</mml:mi></mml:mfenced></mml:mrow></mml:mfrac></mml:mstyle><mml:munder><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>v</mml:mi><mml:mo>∈</mml:mo><mml:mi>V</mml:mi></mml:mrow></mml:munder><mml:msup><mml:mfenced open="(" close=")"><mml:mrow><mml:mfenced open="(" close=")"><mml:mrow><mml:mi>Z</mml:mi><mml:mfenced open="(" close=")"><mml:mi>v</mml:mi></mml:mfenced><mml:mo>-</mml:mo><mml:mi>Z</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:munder><mml:mi mathvariant="normal">Cand</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>∖</mml:mo><mml:mo mathvariant="italic">{</mml:mo><mml:mi>v</mml:mi><mml:mo mathvariant="italic">}</mml:mo></mml:mrow></mml:munder><mml:mfenced open="(" close=")"><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>N</mml:mi><mml:mfenced open="(" close=")"><mml:mrow><mml:mi>v</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced><mml:mo>-</mml:mo><mml:mi mathvariant="italic">ε</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mi mathvariant="italic">θ</mml:mi><mml:mo>,</mml:mo><mml:mi>D</mml:mi><mml:mo>,</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:msqrt></mml:mrow></mml:mtd></mml:mtr></mml:mtable><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>

        where <inline-formula><mml:math id="M108" display="inline"><mml:mrow><mml:mi mathvariant="italic">ε</mml:mi><mml:mo>(</mml:mo><mml:mo>.</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> represents the error and <inline-formula><mml:math id="M109" display="inline"><mml:mrow><mml:mi mathvariant="italic">σ</mml:mi><mml:mo>(</mml:mo><mml:mo>.</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> represents the standard deviation of all differences, between estimated and true values.</p>
</sec>
<sec id="Ch1.S5">
  <label>5</label><title>Results</title>
<sec id="Ch1.S5.SS1">
  <label>5.1</label><title>Optimization of two parameters</title>
      <p id="d2e1829">All experimental tests in this section are performed using the training image shown in Fig. 2, and the stages <inline-formula><mml:math id="M110" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula> are distributed following a logarithmic scale.</p>
      <p id="d2e1839">As a first test, we use the configuration <inline-formula><mml:math id="M111" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfenced close="}" open="{"><mml:mi>n</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M112" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfenced close="}" open="{"><mml:mi>k</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula>. The kernel <inline-formula><mml:math id="M113" display="inline"><mml:mi mathvariant="italic">ω</mml:mi></mml:math></inline-formula> is defined as uniform, meaning that it has a constant value and is not part of the optimization. The outcome is represented in Fig. 3, with the optimal number of candidates <inline-formula><mml:math id="M114" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> and number of neighbors <inline-formula><mml:math id="M115" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> as a function of the density <inline-formula><mml:math id="M116" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>, which is assimilated to the progression during the simulation. The ignorance threshold is defined as the average error between elements of the marginal distribution. It represents the error value at which no further information can be derived from the neighborhood, meaning that the simulated values can equivalently be drawn from the marginal distribution.</p>

      <fig id="F3" specific-use="star"><label>Figure 3</label><caption><p id="d2e1905">Optimal parameters for QS (<inline-formula><mml:math id="M117" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green and number of neighbors in blue) as a function of the progression, with the associated prediction error (in black). The red line represents the ignorance threshold. The dashed blue line indicates the average maximal number of neighbors.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f03.png"/>

        </fig>

      <p id="d2e1922">The optimal <inline-formula><mml:math id="M118" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> remains small (in fact 1) throughout the simulation, which is probably due to the limited size of the training image in this case. It seems important to use many neighbors in the early stages of the simulation. The number of neighbors increases until approximately 3 % of the simulation. This is followed by a subsequent drastic reduction, indicating that once the large structures are informed, only the few direct neighbors are important. It seems logical that MPS algorithms simulate large structure first and then smaller patterns in a hierarchical manner where each smaller structure is part of the larger one. We, however, note that it remains generally difficult to predict the optimal settings as a function of the simulation stage. This indicates that the use of a single parametrization for the entire MPS simulation is generally suboptimal, and the parameters should be adapted as the simulation progresses.</p>

      <fig id="F4" specific-use="star"><label>Figure 4</label><caption><p id="d2e1934">Pattern error as a function of the number of neighbors <inline-formula><mml:math id="M119" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula>, with <inline-formula><mml:math id="M120" display="inline"><mml:mrow><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:math></inline-formula>, where each curve represents a neighborhood density <inline-formula><mml:math id="M121" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f04.png"/>

        </fig>

      <p id="d2e1969">Figure 4 shows the evolution of <inline-formula><mml:math id="M122" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> as a function of the number of neighbors <inline-formula><mml:math id="M123" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> and the simulation progression <inline-formula><mml:math id="M124" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>. Two regimes are visible: in the first percentages of the simulation, each extra neighbor is informative and improves simulation quality. However, as the neighborhoods become denser, the importance of spatial continuity takes over, and only the few neighbors are really informative. This two-step process is expected, as random large-scale features are generated first, and then the image is filled with consistent fine-scale structures. Furthermore, it shows that using a large number of neighbors at the end of the simulation generates suboptimal results, which could explain the small-scale noise that is sometimes visible in some MPS simulations.</p>
</sec>
<sec id="Ch1.S5.SS2">
  <label>5.2</label><title>Optimization of three parameters</title>
      <p id="d2e2001">Here, we use the following configuration <inline-formula><mml:math id="M125" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">h</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfenced close="}" open="{"><mml:mrow><mml:mi>n</mml:mi><mml:mo>,</mml:mo><mml:mspace linebreak="nobreak" width="0.25em"/><mml:mi mathvariant="italic">α</mml:mi></mml:mrow></mml:mfenced></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M126" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">θ</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfenced open="{" close="}"><mml:mi>k</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula>, and we consider kernels as having a radial exponential shape, i.e., <inline-formula><mml:math id="M127" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">ω</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:msup><mml:mi>e</mml:mi><mml:mrow><mml:mo>-</mml:mo><mml:mi mathvariant="italic">α</mml:mi><mml:mo>.</mml:mo><mml:msub><mml:mi>d</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:msup></mml:mrow></mml:math></inline-formula>. The weight of a given position <inline-formula><mml:math id="M128" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> in the kernel <inline-formula><mml:math id="M129" display="inline"><mml:mi mathvariant="italic">ω</mml:mi></mml:math></inline-formula> is defined as <inline-formula><mml:math id="M130" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">ω</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> and its distance to the kernel center as <inline-formula><mml:math id="M131" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>.</p>

      <fig id="F5" specific-use="star"><label>Figure 5</label><caption><p id="d2e2109">Optimal parameters for QS (<inline-formula><mml:math id="M132" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green, number of neighbors in blue, and best kernel in magenta), as a function of the simulation progress, with the associated prediction error (in black). The dashed blue line indicates the average density for the neighborhood considered. The ignorance threshold in red.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f05.png"/>

        </fig>

      <fig id="F6" specific-use="star"><label>Figure 6</label><caption><p id="d2e2127">Optimal parameters for QS (<inline-formula><mml:math id="M133" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green, number of neighbors in blue, and the best kernel in magenta) as a function of the progression, with the associated prediction error (in black). The dashed blue line is the average density for the neighborhood considered. The ignorance threshold is in red. </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f06.png"/>

        </fig>

      <p id="d2e2144">The results presented in Fig. 5 demonstrate the impact of the number of neighbors and narrow kernels (characterized by high <inline-formula><mml:math id="M134" display="inline"><mml:mi mathvariant="italic">α</mml:mi></mml:math></inline-formula> values) on the evolution of the QS parameters. Specifically, it can be observed that interactions arise between these two factors, resulting in slightly erratic calibrated parameters. As the number of neighbors increases, the weights assigned to the furthest neighbors become negligible with larger <inline-formula><mml:math id="M135" display="inline"><mml:mi mathvariant="italic">α</mml:mi></mml:math></inline-formula> values. This means that these far-away neighbors, despite being considered, have very little influence. This insensitivity only occurs for large <inline-formula><mml:math id="M136" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> values, leading to minimal differences between possible configurations and noise in the metric.</p>
      <p id="d2e2168">As expressed in the methodology section, in cases of a similar error, the cheapest solution is considered. In the case of QS, having a large number of neighbors can marginally increase the computational time; therefore, we introduce a small tolerance that results in favoring small <inline-formula><mml:math id="M137" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> values. It is formulated as a small cost for each extra neighbor, i.e., by adding <inline-formula><mml:math id="M138" display="inline"><mml:mrow><mml:mn mathvariant="normal">5</mml:mn><mml:mo>×</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">5</mml:mn></mml:mrow></mml:msup><mml:mo>×</mml:mo><mml:mfenced close=")" open="("><mml:mrow><mml:mo>max⁡</mml:mo><mml:mfenced close=")" open="("><mml:mi>T</mml:mi></mml:mfenced><mml:mo>-</mml:mo><mml:mo>min⁡</mml:mo><mml:mfenced open="(" close=")"><mml:mi>T</mml:mi></mml:mfenced></mml:mrow></mml:mfenced></mml:mrow></mml:math></inline-formula> for each extra neighbor. However, the speed-up during simulation was limited to up to 10 %. Figure 6 shows a quality similar (<inline-formula><mml:math id="M139" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> curves) to that in Fig. 5 but with the added tolerance. As expected, the number of neighbors required during the simulation drastically decreases as advanced simulation stages and the fluctuations in <inline-formula><mml:math id="M140" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> are avoided.</p>

      <fig id="F7" specific-use="star"><label>Figure 7</label><caption><p id="d2e2228">Simulation using QS with parameters generated by the automatic calibration.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f07.png"/>

        </fig>

      <fig id="F8"><label>Figure 8</label><caption><p id="d2e2239">Benchmark between QS with an adaptive kernel (Fig. 6) and a uniform (without) kernel (Fig. 3) over 100 simulations for five different metrics.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f08.png"/>

        </fig>

</sec>
<sec id="Ch1.S5.SS3">
  <label>5.3</label><title>Sequential simulation using automatic calibration</title>
      <p id="d2e2256">Figure 7 shows qualitative results using the evolutive parametrization resulting from the proposed autocalibration, using a case study that was published in Gravey and Mariethoz (2020). QS with an adaptive kernel refers to the use of different values of <inline-formula><mml:math id="M141" display="inline"><mml:mi mathvariant="italic">α</mml:mi></mml:math></inline-formula> for the kernel as a function of the simulation progression. In this case, the results are similar to state-of-the-art simulations using a manual calibration. Tests using QS with a uniform kernel fail to reproduce some structures; in particular, the size of the objects is incorrect. Each position map shows few homogenous areas; therefore, realizations are produced with a low rate of verbatim copy.</p>
      <p id="d2e2266">From a quantitative evaluation, Fig. 8 illustrates different metrics (variograms, connectivity as a structural indicator, and the Euler characteristic as noise indicator) (Renard and Allard, 2013) across a set of 100 realizations. The automatic calibration method proposed here allows obtaining better-quality simulations than in Gravey and Mariethoz (2020).</p>
      <p id="d2e2269">Figure 8 shows that variogram and connectivity metrics are well reproduced, although they have not been directly constrained in the calibration process. Indeed, the parameter optimization only considers the simulation of single pixels and never computes global metrics over an entire grid.</p>
</sec>
</sec>
<sec id="Ch1.S6" sec-type="conclusions">
  <label>6</label><title>Discussion and conclusion</title>
      <p id="d2e2281">The proposed method allows for the automatic calibration of QS and potentially similar pixel-based MPS approaches, reaching a quality similar to or better than that of manual parametrization from both quantitative and qualitative points of view. Furthermore, it demonstrates that the optimal parametrization should not remain constant and instead needs to evolve with the simulation progression. The metrics confirm the good reproduction of training patterns, and the method finds a calibration that avoids verbatim copy. One major advantage of our approach is the absence of a complex objective function, which often itself requires calibration.</p>
      <p id="d2e2284">A limitation of our approach is that it cannot be used to determine an optimal simulation path because it focuses on the simulation of a single pixel. It also does not optimize the computational cost required for a simulation.</p>
      <p id="d2e2287">The computation time necessary to identify the appropriate parameters is contingent upon the expected quality. However, the maximum time required for completion is predictable and depends on the number of patterns tested. If required, the calibration can be further refined based on prior outcomes without restarting the entire process; this can be achieved by adjusting <inline-formula><mml:math id="M142" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula>, incorporating additional kernels, or increasing <inline-formula><mml:math id="M143" display="inline"><mml:mrow><mml:mfenced close="|" open="|"><mml:mi>V</mml:mi></mml:mfenced></mml:mrow></mml:math></inline-formula>. In certain instances, adjusting the kernel parameter offers only minor improvements while necessitating a substantial number of computations. Employing a more streamlined parameter space can yield comparable calibration and significantly reduce the computational cost. This streamlined parameter space can be established, for instance, by subsampling the number of neighbors according to a squared function (2, 4, 9, 16, 25, etc.) or by leveraging external or expert knowledge.</p>
      <p id="d2e2306">The proposed methodology was evaluated in multivariate scenarios, resulting in a more expansive parameter space compared to single-variable cases. Although the approach yields satisfactory parameters, the inclusion of extra parameters significantly extends the computation time, rendering the process impractical, particularly when dealing with four or more variables.</p>
      <p id="d2e2310">In the context of testing the generality of our approach, calibration was computed on multiple training images (found in the Appendix). The calibration pattern with two regimes (<inline-formula><mml:math id="M144" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> large, then <inline-formula><mml:math id="M145" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> small) seems to be universal, at least for univariate simulations. While the position of the abrupt transition between regimes seems to vary greatly (between 0.5 % and 20 % of the path), the overall shape remains the same. Therefore, the approach proposed by Baninajar et al. (2019), in which long ranges are not considered, could be extended by using large <inline-formula><mml:math id="M146" display="inline"><mml:mi>n</mml:mi></mml:math></inline-formula> values in the early stages of the simulation.  While we show that it is possible to calibrate a parametric kernel, in future work one can envision the optimization of a nonparametric kernel where the weight of each individual neighbor <inline-formula><mml:math id="M147" display="inline"><mml:mrow><mml:msub><mml:mi>w</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is considered a variable to optimize using <inline-formula><mml:math id="M148" display="inline"><mml:mi mathvariant="italic">ε</mml:mi></mml:math></inline-formula> as an objective function (e.g., using a machine learning regression framework).</p>
      <p id="d2e2355">The study of the evolution of parameters shows a smooth behavior of the average error. Therefore, the use of multivariate fitting approaches to estimate the error surface with fewer evaluations could be an interesting solution to speed up the parametrization. The use of machine learning to take advantage of transfer learning between training images also has a high potential.</p>
</sec>

      
      </body>
    <back><app-group>

<app id="App1.Ch1.S1">
  <label>Appendix A</label><title/>
      <p id="d2e2369">This appendix contains a similar calibration for other training images.</p>
<sec id="App1.Ch1.S1.SS1">
  <label>A1</label><title>Stone</title>

      <fig id="FA1"><label>Figure A1</label><caption><p id="d2e2381">Optimal parameters for QS (<inline-formula><mml:math id="M149" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green and number of neighbors in blue) as a function of the progression, with the associated prediction error (in red). The red line represents the ignorance threshold. The dashed blue line is the average density for the neighborhood considered. The dot-dashed line represents the variability in 1 % of the error.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f09.png"/>

        </fig>

</sec>
<sec id="App1.Ch1.S1.SS2">
  <label>A2</label><title>Strebelle</title>
      <p id="d2e2407">This section studies the application of the proposed method using the Strebelle training image (Strebelle, 2002).</p>

      <fig id="FA2"><label>Figure A2</label><caption><p id="d2e2412">Optimal parameters for QS (<inline-formula><mml:math id="M150" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green and number of neighbors in blue) as a function of the progression, with the associated prediction error (in red). The red line represents the ignorance threshold. The dashed blue line is the average density for the neighborhood considered. The dot-dashed line represents the variability in 1 % of the error.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f10.png"/>

        </fig>

<fig id="FA3"><label>Figure A3</label><caption><p id="d2e2434">Optimal parameters for QS (<inline-formula><mml:math id="M151" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green, number of neighbors in blue, and the best kernel in magenta) as a function of the progression, with the associated prediction error (in red). The dashed blue line is the average density for the neighborhood considered.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f11.png"/>

        </fig>

      <fig id="FA4"><label>Figure A4</label><caption><p id="d2e2454">Simulation using QS using parameters generated by the automatic calibration.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f12.png"/>

        </fig>

<fig id="FA5"><label>Figure A5</label><caption><p id="d2e2468">Benchmark between QS with adaptive kernel (Fig. A3) and uniform (without) kernel (Fig. A2) over 100 simulations for five different metrics.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f13.png"/>

        </fig>

</sec>
<sec id="App1.Ch1.S1.SS3">
  <label>A3</label><title>Lena river delta </title>
      <p id="d2e2487">This section studies the application of the proposed method using the Lena river delta training image (Mahmud et al., 2014).</p>

      <fig id="FA6"><label>Figure A6</label><caption><p id="d2e2492">Optimal parameters for QS (<inline-formula><mml:math id="M152" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green and number of neighbors in blue) as a function of the progression, with the associated prediction error (in red). The red line represents the ignorance threshold. The dashed blue line is the average density for the neighborhood considered. The dot-dashed line represents the variability in 1 % of the error.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f14.png"/>

        </fig>

<fig id="FA7"><label>Figure A7</label><caption><p id="d2e2514">Optimal parameters for QS (<inline-formula><mml:math id="M153" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula> in green, number of neighbors in blue, and the best kernel in magenta) as a function of the progression, with the associated prediction error (in red). The dashed blue line is the average density for the neighborhood considered.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f15.png"/>

        </fig>

      <fig id="FA8"><label>Figure A8</label><caption><p id="d2e2534">Simulation using QS and using parameters generated by the automatic calibration.</p></caption>
          
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f16.png"/>

        </fig>

<fig id="FA9"><label>Figure A9</label><caption><p id="d2e2548">Benchmark between QS with adaptive kernel (Fig. A7) and uniform (without) kernel (Fig. A6) over 100 simulations for five different metrics.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/16/5265/2023/gmd-16-5265-2023-f17.png"/>

        </fig>

</sec>
</app>
  </app-group><notes notes-type="codeavailability"><title>Code availability</title>

      <p id="d2e2562">The source code of the AutoQS algorithm is available as part of the G2S package at <uri>https://github.com/GAIA-UNIL/G2S</uri> (last access: 1 May 2023) under the GPLv3 license, and it is permanently available at <ext-link xlink:href="https://doi.org/10.5281/zenodo.7792833" ext-link-type="DOI">10.5281/zenodo.7792833</ext-link> (Gravey et al., 2023). Platform: Linux/macOS/Windows 10+. Language: C/C++. Interfacing functions in MATLAB, Python3, and R.</p>
  </notes><notes notes-type="dataavailability"><title>Data availability</title>

      <p id="d2e2574">The datasets used in this paper are available at <uri>https://github.com/GAIA-UNIL/TrainingImagesTIFF</uri> (Mariethoz et al., 2023).</p>
  </notes><notes notes-type="authorcontribution"><title>Author contributions</title>

      <p id="d2e2584">MG proposed the idea, implemented and optimized the AutoQS approach, and wrote the article. GM provided supervision and methodological insights and contributed to the editing.</p>
  </notes><notes notes-type="competinginterests"><title>Competing interests</title>

      <p id="d2e2590">The contact author has declared that neither of the authors has any competing interests.</p>
  </notes><notes notes-type="disclaimer"><title>Disclaimer</title>

      <p id="d2e2597">Publisher's note: Copernicus Publications remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.</p>
  </notes><ack><title>Acknowledgements</title><p id="d2e2603">This research was funded by the Swiss National Science Foundation.</p></ack><notes notes-type="financialsupport"><title>Financial support</title>

      <p id="d2e2608">This research has been supported by the Swiss National Science Foundation (grant no. 200021_162882).</p>
  </notes><notes notes-type="reviewstatement"><title>Review statement</title>

      <p id="d2e2614">This paper was edited by Rohitash Chandra and reviewed by Ute Mueller and one anonymous referee.</p>
  </notes><ref-list>
    <title>References</title>

      <ref id="bib1.bib1"><label>1</label><mixed-citation>Abdollahifard, M. J., Baharvand, M., and Mariéthoz, G.: Efficient training image selection for multiple-point geostatistics via analysis of contours, Comput. Geosci., 128, 41–50, <ext-link xlink:href="https://doi.org/10.1016/j.cageo.2019.04.004" ext-link-type="DOI">10.1016/j.cageo.2019.04.004</ext-link>, 2019.</mixed-citation></ref>
      <ref id="bib1.bib2"><label>2</label><mixed-citation>Baninajar, E., Sharghi, Y., and Mariethoz, G.: MPS-APO: a rapid and automatic parameter optimizer for multiple-point geostatistics, Stoch. Environ. Res. Risk Assess., 33, 1969–1989, <ext-link xlink:href="https://doi.org/10.1007/s00477-019-01742-7" ext-link-type="DOI">10.1007/s00477-019-01742-7</ext-link>, 2019.</mixed-citation></ref>
      <ref id="bib1.bib3"><label>3</label><mixed-citation>Boisvert, J. B., Pyrcz, M. J., and Deutsch, C. V.: Multiple Point Metrics to Assess Categorical Variable Models, Nat. Resour. Res., 19, 165–175, <ext-link xlink:href="https://doi.org/10.1007/s11053-010-9120-2" ext-link-type="DOI">10.1007/s11053-010-9120-2</ext-link>, 2010.</mixed-citation></ref>
      <ref id="bib1.bib4"><label>4</label><mixed-citation>Dagasan, Y., Renard, P., Straubhaar, J., Erten, O., and Topal, E.: Automatic Parameter Tuning of Multiple-Point Statistical Simulations for Lateritic Bauxite Deposits, Minerals, 8, 220, <ext-link xlink:href="https://doi.org/10.3390/min8050220" ext-link-type="DOI">10.3390/min8050220</ext-link>, 2018.</mixed-citation></ref>
      <ref id="bib1.bib5"><label>5</label><mixed-citation>Gómez-Hernández, J. J. and Wen, X.-H.: To be or not to be multi-Gaussian? A reflection on stochastic hydrogeology, Adv. Water Resour., 21, 47–61, <ext-link xlink:href="https://doi.org/10.1016/s0309-1708(96)00031-0" ext-link-type="DOI">10.1016/s0309-1708(96)00031-0</ext-link>, 1998.</mixed-citation></ref>
      <ref id="bib1.bib6"><label>6</label><mixed-citation>Gravey, M. and Mariethoz, G.: QuickSampling v1.0: a robust and simplified pixel-based multiple-point simulation approach, Geosci. Model Dev., 13, 2611–2630, <ext-link xlink:href="https://doi.org/10.5194/gmd-13-2611-2020" ext-link-type="DOI">10.5194/gmd-13-2611-2020</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bib7"><label>7</label><mixed-citation>Gravey, M., Wiersma, P., Mariethoz, G., Comuian, A., and Nussbaumer, R.: GAIA-UNIL/G2S: AutoQS-paper (auto-qs-v1), Zenodo [code], <ext-link xlink:href="https://doi.org/10.5281/zenodo.7792833" ext-link-type="DOI">10.5281/zenodo.7792833</ext-link>, 2023.</mixed-citation></ref>
      <ref id="bib1.bib8"><label>8</label><mixed-citation>Guardiano, F. B. and Srivastava, R. M.: Multivariate Geostatistics: Beyond Bivariate Moments, in: Quantitative Geology and Geostatistics, Springer Netherlands, 133–144, <ext-link xlink:href="https://doi.org/10.1007/978-94-011-1739-5_12" ext-link-type="DOI">10.1007/978-94-011-1739-5_12</ext-link>, 1993.</mixed-citation></ref>
      <ref id="bib1.bib9"><label>9</label><mixed-citation>Journel, A. and Zhang, T.: The Necessity of a Multiple-Point Prior Model, Math. Geol., 38, 591–610, <ext-link xlink:href="https://doi.org/10.1007/s11004-006-9031-2" ext-link-type="DOI">10.1007/s11004-006-9031-2</ext-link>, 2006.</mixed-citation></ref>
      <ref id="bib1.bib10"><label>10</label><mixed-citation>Mahmud, K., Mariethoz, G., Caers, J., Tahmasebi, P., and Baker, A.: Simulation of Earth textures by conditional image quilting, Water Resour. Res., 50, 3088–3107, <ext-link xlink:href="https://doi.org/10.1002/2013wr015069" ext-link-type="DOI">10.1002/2013wr015069</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bib11"><label>11</label><mixed-citation>Mariethoz, G. and Caers, J.: Multiple-point geostatistics: stochastic modeling with training images, Wiley, <ext-link xlink:href="https://doi.org/10.1002/9781118662953" ext-link-type="DOI">10.1002/9781118662953</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bib12"><label>12</label><mixed-citation>Mariethoz, G., Renard, P., and Straubhaar, J.: The Direct Sampling method to perform multiple-point geostatistical simulations, Water Resour. Res., 46. W11536, <ext-link xlink:href="https://doi.org/10.1029/2008wr007621" ext-link-type="DOI">10.1029/2008wr007621</ext-link>, 2010.</mixed-citation></ref>
      <ref id="bib1.bib13"><label>13</label><mixed-citation>Mariethoz, G.,    Gravey, M., and Wiersma, P.: GAIA-UNIL/trainingimages, GitHub [data set], <uri>https://github.com/GAIA-UNIL/TrainingImages</uri>, last access: 22 August 2023.</mixed-citation></ref>
      <ref id="bib1.bib14"><label>14</label><mixed-citation>Matheron, G.: The intrinsic random functions and their applications, Adv. Appl. Probab., 5, 439–468, <ext-link xlink:href="https://doi.org/10.2307/1425829" ext-link-type="DOI">10.2307/1425829</ext-link>, 1973.</mixed-citation></ref>
      <ref id="bib1.bib15"><label>15</label><mixed-citation>Meerschman, E., Pirot, G., Mariethoz, G., Straubhaar, J., Van Meirvenne, M., and Renard, P.: A practical guide to performing multiple-point statistical simulations with the Direct Sampling algorithm, Comput. Geosci., 52, 307–324, <ext-link xlink:href="https://doi.org/10.1016/j.cageo.2012.09.019" ext-link-type="DOI">10.1016/j.cageo.2012.09.019</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bib16"><label>16</label><mixed-citation>Pérez, C., Mariethoz, G., and Ortiz, J. M.: Verifying the high-order consistency of training images with data for multiple-point geostatistics, Comput. Geosci., 70, 190–205, <ext-link xlink:href="https://doi.org/10.1016/j.cageo.2014.06.001" ext-link-type="DOI">10.1016/j.cageo.2014.06.001</ext-link>, 2014. </mixed-citation></ref>
      <ref id="bib1.bib17"><label>17</label><mixed-citation>Renard, P. and Allard, D.: Connectivity metrics for subsurface flow and transport, Adv. Water Resour., 51, 168–196, <ext-link xlink:href="https://doi.org/10.1016/j.advwatres.2011.12.001" ext-link-type="DOI">10.1016/j.advwatres.2011.12.001</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bib18"><label>18</label><mixed-citation>Rezaee, H., Mariethoz, G., Koneshloo, M., and Asghari, O.: Multiple-point geostatistical simulation using the bunch-pasting direct sampling method, Comput. Geosci., 54, 293–308, <ext-link xlink:href="https://doi.org/10.1016/j.cageo.2013.01.020" ext-link-type="DOI">10.1016/j.cageo.2013.01.020</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bib19"><label>19</label><mixed-citation>Straubhaar, J., Renard, P., Mariethoz, G., Froidevaux, R., and Besson, O.: An Improved Parallel Multiple-point Algorithm Using a List Approach, Math. Geosci., 43, 305–328, <ext-link xlink:href="https://doi.org/10.1007/s11004-011-9328-7" ext-link-type="DOI">10.1007/s11004-011-9328-7</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bib20"><label>20</label><mixed-citation>Strebelle, S.: Conditional Simulation of Complex Geological Structures Using Multiple-Point Statistics, Math. Geol.,  34, 1–21, <ext-link xlink:href="https://doi.org/10.1023/a:1014009426274" ext-link-type="DOI">10.1023/a:1014009426274</ext-link>, 2002.</mixed-citation></ref>
      <ref id="bib1.bib21"><label>21</label><mixed-citation>Tan, X., Tahmasebi, P., and Caers, J.: Comparing Training-Image Based Algorithms Using an Analysis of Distance, Math. Geosci., 46, 149–169, <ext-link xlink:href="https://doi.org/10.1007/s11004-013-9482-1" ext-link-type="DOI">10.1007/s11004-013-9482-1</ext-link>, 2013.</mixed-citation></ref>

  </ref-list></back>
    <!--<article-title-html>AutoQS v1: automatic parametrization of QuickSampling based on training images analysis</article-title-html>
<abstract-html/>
<ref-html id="bib1.bib1"><label>1</label><mixed-citation>
      
Abdollahifard, M. J., Baharvand, M., and Mariéthoz, G.: Efficient
training image selection for multiple-point geostatistics via analysis of
contours, Comput. Geosci., 128, 41–50,
<a href="https://doi.org/10.1016/j.cageo.2019.04.004" target="_blank">https://doi.org/10.1016/j.cageo.2019.04.004</a>, 2019.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib2"><label>2</label><mixed-citation>
      
Baninajar, E., Sharghi, Y., and Mariethoz, G.: MPS-APO: a rapid and
automatic parameter optimizer for multiple-point geostatistics, Stoch.
Environ. Res. Risk Assess., 33, 1969–1989,
<a href="https://doi.org/10.1007/s00477-019-01742-7" target="_blank">https://doi.org/10.1007/s00477-019-01742-7</a>, 2019.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib3"><label>3</label><mixed-citation>
      
Boisvert, J. B., Pyrcz, M. J., and Deutsch, C. V.: Multiple Point Metrics to
Assess Categorical Variable Models, Nat. Resour. Res., 19, 165–175,
<a href="https://doi.org/10.1007/s11053-010-9120-2" target="_blank">https://doi.org/10.1007/s11053-010-9120-2</a>, 2010.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib4"><label>4</label><mixed-citation>
      
Dagasan, Y., Renard, P., Straubhaar, J., Erten, O., and Topal, E.: Automatic
Parameter Tuning of Multiple-Point Statistical Simulations for Lateritic
Bauxite Deposits, Minerals, 8, 220, <a href="https://doi.org/10.3390/min8050220" target="_blank">https://doi.org/10.3390/min8050220</a>,
2018.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib5"><label>5</label><mixed-citation>
      
Gómez-Hernández, J. J. and Wen, X.-H.: To be or not to be
multi-Gaussian? A reflection on stochastic hydrogeology, Adv. Water
Resour., 21, 47–61, <a href="https://doi.org/10.1016/s0309-1708(96)00031-0" target="_blank">https://doi.org/10.1016/s0309-1708(96)00031-0</a>, 1998.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib6"><label>6</label><mixed-citation>
      
Gravey, M. and Mariethoz, G.: QuickSampling v1.0: a robust and simplified pixel-based multiple-point simulation approach, Geosci. Model Dev., 13, 2611–2630, <a href="https://doi.org/10.5194/gmd-13-2611-2020" target="_blank">https://doi.org/10.5194/gmd-13-2611-2020</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib7"><label>7</label><mixed-citation>
      
Gravey, M., Wiersma, P., Mariethoz, G., Comuian, A., and Nussbaumer, R.: GAIA-UNIL/G2S: AutoQS-paper (auto-qs-v1), Zenodo [code], <a href="https://doi.org/10.5281/zenodo.7792833" target="_blank">https://doi.org/10.5281/zenodo.7792833</a>, 2023.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib8"><label>8</label><mixed-citation>
      
Guardiano, F. B. and Srivastava, R. M.: Multivariate Geostatistics: Beyond
Bivariate Moments, in: Quantitative Geology and Geostatistics, Springer
Netherlands, 133–144,
<a href="https://doi.org/10.1007/978-94-011-1739-5_12" target="_blank">https://doi.org/10.1007/978-94-011-1739-5_12</a>, 1993.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib9"><label>9</label><mixed-citation>
      
Journel, A. and Zhang, T.: The Necessity of a Multiple-Point Prior Model,
Math. Geol., 38, 591–610, <a href="https://doi.org/10.1007/s11004-006-9031-2" target="_blank">https://doi.org/10.1007/s11004-006-9031-2</a>, 2006.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib10"><label>10</label><mixed-citation>
      
Mahmud, K., Mariethoz, G., Caers, J., Tahmasebi, P., and Baker, A.:
Simulation of Earth textures by conditional image quilting, Water Resour.
Res., 50, 3088–3107, <a href="https://doi.org/10.1002/2013wr015069" target="_blank">https://doi.org/10.1002/2013wr015069</a>, 2014.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib11"><label>11</label><mixed-citation>
      
Mariethoz, G. and Caers, J.: Multiple-point geostatistics: stochastic
modeling with training images, Wiley, <a href="https://doi.org/10.1002/9781118662953" target="_blank">https://doi.org/10.1002/9781118662953</a>, 2014.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib12"><label>12</label><mixed-citation>
      
Mariethoz, G., Renard, P., and Straubhaar, J.: The Direct Sampling method to
perform multiple-point geostatistical simulations, Water Resour. Res., 46. W11536,
<a href="https://doi.org/10.1029/2008wr007621" target="_blank">https://doi.org/10.1029/2008wr007621</a>, 2010.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib13"><label>13</label><mixed-citation>
      
Mariethoz, G.,    Gravey, M., and Wiersma, P.: GAIA-UNIL/trainingimages, GitHub [data set], <a href="https://github.com/GAIA-UNIL/TrainingImages" target="_blank"/>, last access: 22 August 2023.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib14"><label>14</label><mixed-citation>
      
Matheron, G.: The intrinsic random functions and their applications,
Adv. Appl. Probab., 5, 439–468,
<a href="https://doi.org/10.2307/1425829" target="_blank">https://doi.org/10.2307/1425829</a>, 1973.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib15"><label>15</label><mixed-citation>
      
Meerschman, E., Pirot, G., Mariethoz, G., Straubhaar, J., Van Meirvenne, M.,
and Renard, P.: A practical guide to performing multiple-point statistical
simulations with the Direct Sampling algorithm, Comput. Geosci., 52, 307–324, <a href="https://doi.org/10.1016/j.cageo.2012.09.019" target="_blank">https://doi.org/10.1016/j.cageo.2012.09.019</a>,
2013.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib16"><label>16</label><mixed-citation>
      
Pérez, C., Mariethoz, G., and Ortiz, J. M.: Verifying the high-order
consistency of training images with data for multiple-point geostatistics,
Comput. Geosci., 70, 190–205,
<a href="https://doi.org/10.1016/j.cageo.2014.06.001" target="_blank">https://doi.org/10.1016/j.cageo.2014.06.001</a>, 2014.


    </mixed-citation></ref-html>
<ref-html id="bib1.bib17"><label>17</label><mixed-citation>
      
Renard, P. and Allard, D.: Connectivity metrics for subsurface flow and
transport, Adv. Water Resour., 51, 168–196,
<a href="https://doi.org/10.1016/j.advwatres.2011.12.001" target="_blank">https://doi.org/10.1016/j.advwatres.2011.12.001</a>, 2013.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib18"><label>18</label><mixed-citation>
      
Rezaee, H., Mariethoz, G., Koneshloo, M., and Asghari, O.: Multiple-point
geostatistical simulation using the bunch-pasting direct sampling method,
Comput. Geosci., 54, 293–308,
<a href="https://doi.org/10.1016/j.cageo.2013.01.020" target="_blank">https://doi.org/10.1016/j.cageo.2013.01.020</a>, 2013.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib19"><label>19</label><mixed-citation>
      
Straubhaar, J., Renard, P., Mariethoz, G., Froidevaux, R., and Besson, O.:
An Improved Parallel Multiple-point Algorithm Using a List Approach, Math.
Geosci., 43, 305–328, <a href="https://doi.org/10.1007/s11004-011-9328-7" target="_blank">https://doi.org/10.1007/s11004-011-9328-7</a>, 2011.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib20"><label>20</label><mixed-citation>
      
Strebelle, S.: Conditional Simulation of Complex Geological Structures Using Multiple-Point Statistics,
Math. Geol.,  34, 1–21,
<a href="https://doi.org/10.1023/a:1014009426274" target="_blank">https://doi.org/10.1023/a:1014009426274</a>, 2002.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib21"><label>21</label><mixed-citation>
      
Tan, X., Tahmasebi, P., and Caers, J.: Comparing Training-Image Based
Algorithms Using an Analysis of Distance, Math. Geosci., 46, 149–169,
<a href="https://doi.org/10.1007/s11004-013-9482-1" target="_blank">https://doi.org/10.1007/s11004-013-9482-1</a>, 2013.

    </mixed-citation></ref-html>--></article>
