  We present a novel application of the extended Fast Action Minimization
method (eFAM) aimed at assessing the role of the environment in shaping galaxy
evolution. We validate our approach by testing eFAM predictions against the
Magneticum hydrodynamical simulation. We consider the z~0 snapshot of the
simulation as our observed catalogue and use the reconstructed trajectories of
galaxies to model the evolution of cosmic structures. At the statistical level,
the fraction of volume (VFF) occupied by voids, sheets, filaments, and clusters
in the reconstructed catalogues agrees within $1\sigma$ with the VFF estimated
from the high-redshift snapshots of the simulation. The local accuracy of eFAM
structures is evaluated by computing their purity with respect to the simulated
catalogues, P, at the cells of a regular grid. Up to z=1.2, clusters have
0.58<P<0.93, filaments vary in 0.90<P<0.99, sheets show 0.78<P<0.92, and voids
are best identified with 0.90<P<0.92. As redshift increases, comparing
reconstructed tracers and simulated galaxies becomes more difficult due to
their different biases and number densities and the purity decreases to P~0.6.
We retrieve the environmental history of individual galaxies by tracing their
trajectories through the cosmic web and relate their observed gas fraction,
$f_\mathrm{gas}$, with the time spent within different structures. For galaxies
in clusters and filaments, eFAM reproduces the variation of $f_\mathrm{gas}$ as
a function of the redshift of accretion/infall as traced by the simulations
with a 1.5 $\sigma$ statistical agreement (which decreases to 2.5 $\sigma$
statistical agreement for low-mass galaxies in filaments). These results
support the application of eFAM to observational data to study the
environmental dependence of observed galaxy properties, offering a
complementary approach to that based on light-cone observations.
