2.1. Flowchart of the Algorithm
 A flowchart of the proposed method is displayed in Figure 1, which consists of the following steps.
Figure 1. Flowchart of the proposed pattern-searching-based multiple-point ensemble inverse method. Here d is the distance function value, Nn is the number of grids in each realization, and Nr is the number of realizations.
Download figure to PowerPoint
 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 Nr realizations and each hydraulic conductivity field be discretized into Nn 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.
 Loop on time t begins.
 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.
 Loop on realizations begins.
 Loop on cells begins.
 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 (Ki) in the random path,
 3A. Determine the conditional data pattern of Ki. 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 Ki 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.
Figure 2. A pattern example consisting of conditional hydraulic conductivity and head data. Ki is the value to be simulated.
Download figure to PowerPoint
 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 Ki, 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 dk and dh 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.
Figure 3. Sketch map of the searching strategy. The dashed line indicates the exact location of Ki through the ensemble. The candidates in the 3 by 3 square in each realization are evaluated to find the match consistent with the conditioning hydraulic conductivities and observed piezometric heads.
Download figure to PowerPoint
 3C. Assign the value of Ki. If the distance function value d is less than a predefined threshold (dt), locate the value of K relative to the conditioning pattern in the matching realization and assign it to Ki. If dt = 0, the conditioning data are exactly matched; if dt > 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, dt,k and dt,h. In the present work, hydraulic conductivities are considered as categorical variables (two facies with uniform values) and the corresponding dt,k is set to 0, indicating an exact fit. Normally dt,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 dt,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.
 Loop back to step 3A for generation of the next cell until all cells for the current realization are visited.
 Loop back to step 3 to start the generation of the next realization until all realizations are generated.
 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.  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].
Figure 4. Sketch of filtering out noise. The circled black (white) cell is converted to white (black) so as to be consistent with the values in the neighborhood.
Download figure to PowerPoint
 5. Update the training images. The set of conductivity realizations generated become the new set of training images.
 Loop back to step 2 for the next time step until all transient hydraulic heads have been used.
2.2. Distance Function
 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.
 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].
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.
where dmax is the maximum deviation between and , together with n used to normalize the distance values.
 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.
where hi is the lag distance from the element in the data event to the simulated cell and ai is the same as in equation (3).