Trufl

Optimizing adaptive sampling using Multiple-Criteria Decision-Making

Trufl helps you decide where to sample next in a survey that runs over several rounds. At each round, it ranks areas, such as administrative units, by how much they need more samples. It then splits your sampling budget across the areas according to their rank. The ranking uses multiple-criteria decision-making (MCDM) on criteria that you choose, computed from the measurements collected so far and from prior knowledge such as an airborne survey.

Trufl was built to plan soil surveys of farmland contaminated after a nuclear accident. The same approach works for any phenomenon you monitor over time against several criteria, such as legacy contaminants.

trufl is part of the ecosystem of DSS4NAFA, a decision support system for nuclear emergencies affecting food and agriculture. Where trufl comes from describes the research behind trufl and how it works with DSS4NAFA.

Why trufl

Sampling theory and the research literature already cover multi-stage and adaptive spatial sampling well. Their methods rest on assumptions, such as a planned probability sampling design or a known model of spatial variation. In a nuclear emergency, the data rarely meet those assumptions. Measurements arrive over time from many sources, such as airborne surveys, laboratory analyses and samples taken where it was convenient to take them. They cover different locations at different resolutions. Sound statistical inference from such data is difficult. Decisions still have to be made, and you can’t ignore the data you have. trufl takes a pragmatic approach and uses all of it.

The reasons to sample one area before another also vary, and they change during an emergency. They include the levels measured so far, the uncertainty that remains, prior knowledge, land use and population. trufl ranks areas on criteria that you choose, with weights that you set. You can change both from one round to the next.

Like DSS4NAFA, trufl is not a black box. Each rank follows from the state of the area, the criteria, the weights and the scoring method. You can inspect each of them, and adjust them as the situation develops.

You can also use trufl to prepare for an emergency. Simulate a campaign over several rounds on a map of a possible contamination, and compare sampling strategies before you need them.

Install

pip install trufl

Example

This example plans one sampling round over a simulated contamination map, split into a 10 x 10 grid of areas:

import pandas as pd
import geopandas as gpd

from trufl.utils import gridder
from trufl.callbacks import State, PriorCB
from trufl.optimizer import Optimizer
from trufl.sampler import Sampler, rank_to_sample
fname_raster = './files/ground-truth-01-4326-simulated.tif'
gdf_grid = gridder(fname_raster, nrows=10, ncols=10)

Before any measurement, the state of each area is its prior: the mean of the map over the area. Calling a State computes it:

no_samples = gpd.GeoDataFrame(index=pd.Index([], name='loc_id'), geometry=None, data={'value': None})
state = State(no_samples, gdf_grid, cbs=[PriorCB(fname_raster)])()
state.head()
Prior
loc_id
0 0.108520
1 0.133123
2 0.161802
3 0.195281
4 0.213253

With the prior as the only criterion, an area with a higher prior gets a higher sampling priority. Rank 1 is the highest:

ranks = Optimizer(state).get_rank(is_benefit_x=[True], w_vector=[1], s_method='CP')
ranks.head()
rank
loc_id
92 1
93 2
84 3
91 4
83 5

rank_to_sample splits a budget of 600 samples across the areas by rank, with at least one sample in each area (min=1). A Sampler then picks the sample locations in each area:

n = rank_to_sample(ranks['rank'].sort_index().values, budget=600, min=1, policy='quantiles')
sample_locs = Sampler(gdf_grid).sample(n, method='uniform')
sample_locs.head()
geometry
loc_id
0 MULTIPOINT ((-1.21424 43.26782))
1 MULTIPOINT ((-1.21193 43.27661))
2 MULTIPOINT ((-1.21097 43.28611))
3 MULTIPOINT ((-1.22039 43.29371))
4 MULTIPOINT ((-1.21795 43.30186))

In the next round, you compute the state from the values measured at these locations, and rank the areas again.

Documentation

Acknowledgements

trufl started within the IAEA Coordinated Research Project D15019, “Monitoring and Predicting Radionuclide Uptake and Dynamics for Optimizing Remediation of Radioactive Contamination in Agriculture”, led by the Joint FAO/IAEA Centre of Nuclear Techniques in Food and Agriculture. It is actively maintained.

It builds on the PhD research of Floris Abrams at SCK CEN and KU Leuven. Floris Abrams and Franck Albinet wrote the package. Where trufl comes from describes the research and how trufl works with DSS4NAFA.