#### 2.1. Flowchart of the Algorithm

[10] A flowchart of the proposed method is displayed in Figure 1, which consists of the following steps.

[11] 1. Generate the prior ensemble of realizations. For the purpose of illustration we will consider that hydraulic conductivity is the parameter of interest. Let the ensemble be composed of *N*_{r} realizations and each hydraulic conductivity field be discretized into *N*_{n} cells. Multiple-point sequential simulation methods are applied to generate the conductivity field ensemble, e.g., using the SNESIM or the DS codes mentioned in the introduction section. A training image is needed for the generation. This training image will not be used again. At this initial stage, no observation state data are considered. The hydraulic conductivity hard data are honored if available. Time is set to zero.

[12] Loop on time *t* begins.

[13] 2. Increase *t* to the next time step. Forecast the dependent state variables. For each realization of the ensemble, the hydraulic head data for the current time *t* are obtained by solving the transient flow equation, from time zero to time *t*, on the hydraulic conductivity field subject to initial and boundary conditions. (We assume that the initial and boundary conditions are known perfectly so that we can focus on the uncertainty caused by hydraulic conductivities.) At this stage we have an ensemble of hydraulic conductivity realizations that mimic the patterns of the training image, and the corresponding ensemble of piezometric head fields. These two ensembles will become now the training images in which to look for joint patterns of both conductivities and piezometric heads that will permit the generation of a new set of conductivity realizations consistent with the piezometric head measurements. Piezometric head data are observed, and become conditioning data.

[14] Loop on realizations begins.

[15] Loop on cells begins.

[16] 3. A new ensemble of realizations will be generated. For each realization, define a random path visiting each cell except those with hydraulic conductivity measurements. For each cell with an unknown value (*K*_{i}) in the random path,

[17] 3A. Determine the conditional data pattern of *K*_{i}. In this work, the data pattern is composed of both hydraulic conductivities and piezometric heads. The conditional hydraulic conductivities include measured hard data, if any, and previously simulated values. A maximum number *M* of conditional hydraulic conductivities and a maximum number *N* of conditional piezometric heads are set. Only the closest *M* hydraulic conductivities and the closest *N* observed heads are stored as conditional data constituting the conditioning pattern. For instance, in Figure 2, the conditioning data pattern for *K*_{i} consists of three hydraulic conductivities and two observed heads. The size of the conditional data pattern is not determined by a maximum search area but instead by the number of conditioning data. The varying-size search neighborhood scheme was proposed by *Mariethoz et al.* [2010a]. Advantages of this pattern configuration are twofold: (1) the size of the conductivity data event in the pattern is influenced by the density of the known conductivities; that is, when the known conductivities are sparse, the pattern will cover a large area to reach the maximum number of conditioning data (*M*). On the other hand, when the known conductivities are dense, the pattern will cover a small area, and only the nearest cells are used to account for the local variety. In other words, the flexible search neighborhood scheme has similar effect as multiple grids [*Mariethoz et al.*, 2010a]. (2) Only hydraulic heads located near the unknown cell (*N* at most) are considered rather than all the heads over the field, which helps to avoid potential spurious correlation between simulated hydraulic conductivities and head observations.

[18] 3B. Given the conditional pattern, start a search in the ensemble of training image couples (hydraulic conductivity–piezometric head) for a match to the conditional pattern. Randomly start from a realization couple in the ensemble and then follow the ensemble sequentially. The search is not conducted on the entire realization, but it is restricted to a close neighborhood around the location of *K*_{i}, this restriction is enforced because hydraulic heads depend not only on hydraulic conductivities but also on the boundary conditions and the presence of sinks or sources. More specifically, in this work, we search only within a 3 by 3 square as shown in Figure 3, i.e., only 9 pattern candidates in a 3 by 3 square are evaluated in each realization. Calculate the distance function (*d*) between the conditioning data and the candidate:

where *d*_{k} and *d*_{h} are the distances between the conditioning data and the candidate pattern corresponding to hydraulic conductivities and heads, respectively, and *ω* is a trade-off coefficient used to balance the influence of the two types of conditioning data. This weight technique has been applied in many inverse methods and a usual choice for the value of *ω* is 0.5 when two types of conditioning data are taken into account and the distance measures are normalized [e.g., *Alcolea and Renard*, 2010; *Capilla and Llopis-Albert*, 2009; *Christiansen et al.*, 2011; *Hendricks Franssen et al.*, 2003]. The expression of the distance function will be discussed later on.

[19] 3C. Assign the value of *K*_{i}. If the distance function value *d* is less than a predefined threshold (*d*_{t}), locate the value of *K* relative to the conditioning pattern in the matching realization and assign it to *K*_{i}. If *d*_{t} = 0, the conditioning data are exactly matched; if *d*_{t} > 0, a certain disagreement is allowed. To explicitly distinguish the misfits related with hydraulic conductivities and heads in the conditioning data pattern, we can define two thresholds, *d*_{t,k} and *d*_{t,h}. In the present work, hydraulic conductivities are considered as categorical variables (two facies with uniform values) and the corresponding *d*_{t,k} is set to 0, indicating an exact fit. Normally *d*_{t,h} is assigned a value larger than 0 to account for measurement errors and the difficulty of fitting exactly a continuous variable (a value of *d*_{t,h} = 0.005 was used, after some trial, in the examples following). If no match is found with distances below the predefined thresholds, the pattern with the smallest distance is used.

[20] Loop back to step 3A for generation of the next cell until all cells for the current realization are visited.

[21] Loop back to step 3 to start the generation of the next realization until all realizations are generated.

[22] 4. Perform postprocessing. Inconsistencies may appear during data assimilation as shown in Figure 4. We can find that the cells indicated by the ellipses are not consistent with their neighboring values and cannot be considered geologically realistic. We simply filter these inconsistent values out similarly as *Henrion et al.* [2010] did. However, this might disturb the facies proportions since no proportion control strategy is applied. In order to reduce the influence of the artificial filtering on facies proportion, we only consider those inconsistent objects consisting of at most three cells. More complex postprocessing methods can be found in image processing algorithms, e.g., kernel principal component analysis [*Kim et al.*, 2005; *Mika et al.*, 1999], or others [*Falivene et al.*, 2009].

[23] 5. Update the training images. The set of conductivity realizations generated become the new set of training images.

[24] Loop back to step 2 for the next time step until all transient hydraulic heads have been used.

#### 2.2. Distance Function

[25] In the proposed method, the distance function plays a key role and it must be defined carefully. The Minkowski distance is a commonly used distance function as defined below [*Borg and Groenen*, 2005; *Duda et al.*, 2001].

where is the distance function between the data event and the conditioning data pattern , *n* indicates the size of and , *x* can be hydraulic conductivity and head data, and *q* is a variable that, if equal to 1, gives rise to the Manhattan distance, and if it is equal to 2, to the Euclidian distance.

[26] 1. Manhattan distance (city block distance) has been used as the dissimilarity measure in SIMPAT, a multiple-point geostatistical simulation algorithm [*Arpat and Caers*, 2007].

Categorical variables

The distance values are normalized into the range [0,1] by dividing by *n*, which makes it convenient to define the threshold values, i.e., threshold values near 0 indicate very low deviation and near 1 very high deviation. It also helps in combining the distances for different attributes.

Continuous variables

where *d*_{max} is the maximum deviation between and , together with *n* used to normalize the distance values.

[27] 2. Weighted Euclidean distance attributes different weights to elements in the data event depending on their distance to the simulated cell, i.e., the nearer to the simulated cell, the more important, while in the unweighted Manhattan distance, all elements share the same weight.

Categorical variables

where *h*_{i} is the lag distance from the element in the data event to the simulated cell and *a*_{i} is the same as in equation (3).