The execution context in which pervasive systems or mobile
computing run changes continuously. Hence, applications for these systems
should be adapted at run-time according to the current context.
In order to implement a context-aware dynamic reconfiguration service,
most approaches usually require to model at design-time both the list of
all possible configurations and the plans to switch among them. In this
paper we present an alternative approach for the automatic run-time generation
of application configurations and the reconfiguration plans. The
generated configurations are optimal regarding di erent criteria, such as
functionality or resource consumption (e.g. battery or memory). This is
achieved by: (1) modelling architectural variability at design-time using
Common Variability Language (CVL), and (2) using a genetic algorithm
that finds at run-time nearly-optimal configurations using the information
provided by the variability model. We also specify a case study
and we use it to evaluate our approach, showing that it is efficient and
suitable for devices with scarce resources.