Part III — Adaptive behaviour · Chapter 11

Automatic design of robot programs

~50 min read1 interactive widget2 plates

In this chapter

  1. Types of design, and when automatic design pays
  2. The off-line automatic design methodology
  3. The four issues: training, merit factor, simulation, reality gap
  4. Current approaches
  5. AutoMoDe: the design problem made parametric
  6. Study A: machines versus human designers
  7. Chocolate: better search beats the human
  8. Racing: F-Race and irace
  9. The manifesto of automatic off-line design
  10. Fiorella's swarm gardening
  11. Guidelines and the road to DEMIURGE
  12. Check your understanding

1. Types of design, and when automatic design pays

Design of control software can be classified along four axes:

Automatic design is justified when any of the following conditions hold:

Editor note

The third condition is the one Chapter 3 flagged: in Chapter 3 the mission was defined as explicitly sampled from a class — the class is the niche, written down. Here the same idea does the economic work: if every mission is different, designing each one by hand is unaffordable, and the design method itself becomes the product.

2. The off-line automatic design methodology

The lecture gives the methodology in four steps:

  1. The robot program is represented in a formal language (e.g. a finite state machine).
  2. The design problem is encoded into a learning problem.
  3. In the training phase an optimization algorithm is used (e.g. evolutionary techniques).
  4. The program is designed in simulation and then tested in a real setting.
OFF-LINE AUTOMATIC DESIGN — FLOWCHART MISSION sampled from a class of interest AUTOMATIC DESIGN in computer-based simulations DEPLOYED ROBOT in the target environment REALITY GAP — the difference between simulation models and reality
Plate 11.1 — The off-line design loop. A mission is sampled from a class of interest; an automatic design method defines a robot tailored to the sampled mission; once design terminates, the robot is deployed and has to cross the reality gap. The method could generate a robot from scratch for every mission, refine a solution previously generated for a similar one, or combine partial solutions from a catalog of templates predefined by a human expert (Birattari et al., 2019).

In the manifest, the problem is stated more precisely: the design problem is cast into an optimization problem that is solved off-line — before the swarm is deployed in the target environment. An optimization algorithm searches a space of possible designs with the goal of maximising an appropriate mission-specific performance measure; the performance of candidate designs is assessed via computer-based simulations; once the optimization terminates, the selected design is uploaded to the robots.

3. The four issues: training, merit factor, simulation, reality gap

IssueWhat it is
Training and test setsCandidate designs are tuned on a sample of missions; performance must then be assessed on missions not used for tuning — the machine-learning validation distinction of Chapter 15
Merit factorThe objective function (or fitness function) that measures how good a design is; it must quantitatively capture the criteria that matter
SimulationThe physics-based model used to evaluate candidate designs without touching real robots — cheap, fast, repeatable, but approximate
Reality gapThe possibly subtle but inevitable difference between the model and the real system (Brooks 1992; Jakobi et al. 1995) — the most challenging issue in off-line design
For the exam — the four issues as a checklist

Any automatic design study you read (or write) can be graded against these four: Were the missions used for training different from those used for testing? Is the merit factor stated, and does it capture what the user actually wants? Is the simulation described well enough to be reproduced? Is the reality gap assessed by running real robots? The manifesto's guidelines (section 11) are exactly this checklist, made into research norms.

4. Current approaches

Examples named by the lecture, besides evolutionary robotics: AutoMoDe, Boolean network robotics, and online adaptation of nanowire networks — the last two reappear in Chapter 16 as the "hard case" of Chapter 3: adaptation that must happen during operation, on a substrate that cannot be reprogrammed.

5. AutoMoDe: the design problem made parametric

AutoMoDe (Francesca et al., 2014) is an approach in which control software for robot swarms is automatically designed in the form of a probabilistic finite state machine (PFSM), by combining and fine-tuning preexisting parametric modules. The key idea: do not let the search invent the controller from nothing; give it a vocabulary of well-understood behaviours and let it decide which to combine and how to tune them.

The design problem in swarms is the one Chapter 9 left open: requirements are naturally expressed at the collective level, but the designer must eventually define what each individual robot does; no general approach exists to derive individual behaviour from desired collective behaviour, so manual design proceeds by trial and error and completely relies on the intuition and skill of the designer. Automatic design casts the problem into an optimization problem: the solution space comprises instances of control software that conform to a predefined parametric architecture, and an optimization algorithm searches it — which amounts to tuning the free parameters of the architecture.

Vanilla

AutoMoDe-Vanilla is a first method that complies with the AutoMoDe approach, specialised for a version of the e-puck robot. In Vanilla, twelve modules are available for assembly into a probabilistic finite state machine: six behaviours — exploration, stop, phototaxis, anti-phototaxis, attraction, repulsion (all but stop include an obstacle avoidance mechanism) — and six transitions — black-floor, gray-floor, white-floor, neighbour-count, inverted-neighbour-count, fixed-probability. The search space is the space of PFSMs comprising up to four states and up to four outgoing edges from each state.

AUTOMODE — PFSM IN THE MODULE VOCABULARY EXPLORATION + obstacle avoid. PHOTOTAXIS + obstacle avoid. ATTRACTION + obstacle avoid. STOP no avoidance gray floor neighbor > 2 black floor fixed prob 0.05 inverted neighbor < 1 every module is parametric: probabilities, thresholds and speeds are free parameters tuned by the optimizer
Plate 11.2 — An AutoMoDe controller is a labelled graph, not a neural network. The design problem has been made tractable by restricting it: the architecture is fixed, the modules are meaningful behaviours, and the optimizer only has to decide topology and parameters.

6. Study A: machines versus human designers

In Study A, Vanilla and EvoStick (a design method that uses an evolutionary algorithm to optimize a neural network) are compared with human designers on five swarm robotics tasks — different from those on which Vanilla and EvoStick were previously tested. The tasks were defined by researchers who, at the moment of defining them, were neither aware of the functioning of the two methods nor informed on which design methods were included in the study: the definition of the tasks was neutral, granting no a priori advantage to any method. The versions of Vanilla and EvoStick were exactly those of the original paper, with no modification to adapt them to the new tasks.

Two manual design methods complete the comparison:

Results of Study A:

For the exam — the diagnosis

Since Vanilla and C-Human operate on the same set of modules, the performance gap cannot be blamed on the architecture. The difference is to be ascribed to the mechanism adopted to combine and fine-tune the modules: the optimization algorithm. The study is a controlled experiment: same design space, different search engines, and the search engine lost. The fix is therefore to change the search engine — which is exactly what Chocolate does.

7. Chocolate: better search beats the human

AutoMoDe-Chocolate differs from Vanilla in a single aspect: the optimization algorithm used to explore the design space. Vanilla adopts F-Race (with the default parameters of the irace package); Chocolate adopts Iterated F-Race — a more effective instance of the same racing family, which repeatedly runs races and uses the results to bias the sampling of new candidate configurations toward promising regions.

In Study B, the working hypotheses were: (i) by adopting a more advanced optimization algorithm, Chocolate improves over Vanilla; and (ii) the improvement is such that, under the experimental conditions considered, Chocolate outperforms C-Human. Both hypotheses were confirmed. The empirical campaign is unprecedented in the domain: 350 runs with a swarm of 20 robots, five methods tested on five tasks. Chocolate is the first automatic design method for robot swarms that, at least under specific experimental conditions, is shown to outperform a human designer.

Editor note

Notice what the result does not say: the conditions are specific, the tasks belong to a class, and the humans were constrained by the same module vocabulary in the decisive comparison. The claim is a controlled, quantitative one — and the experimental protocol itself (neutral task definition, no task-specific modification, multiple tasks, multiple methods under the same conditions) is a contribution that Chapter 15 will generalise into a methodology.

8. Racing: F-Race and irace

The engine behind AutoMoDe is algorithm configuration: a metaheuristic is a general algorithmic template whose components need to be instantiated and properly tuned to yield a fully functioning algorithm; an instantiation is a configuration, and the configuration problem is the problem of selecting the optimal one. Birattari, Stützle, Paquete and Varrentrapp (2002) formalised it: given the finite set of candidate configurations Θ, the possibly infinite set of instances I with an unknown probability measure PI, the computation time t(i) allocated to each instance, and the random cost c(θ, i) of the best solution found by running θ on i for t(i) seconds, the problem is to find

θ* = arg min C(θ)   with   C(θ) = E[ c(θ, i) ]

where the expectation is taken over both the instance distribution and the stochasticity of the run. The measures are not explicitly available, so the integrals are estimated in a Monte Carlo fashion on a training set of instances — the problem is one of generalisation, exactly as in machine learning.

The naive brute-force approach — run every candidate on a large fixed set of instances — wastes computation on bad candidates. A racing method instead evaluates the candidate configurations iteratively on new sampled instances and discards bad ones as soon as statistically sufficient evidence is gathered against them, so that computation concentrates on the promising ones. The lecture's summary:

F-Race in one sentence

Given all candidate configurations θ1, θ2, ..., θm, run them iteratively on new sampled problem instances and progressively discard the configurations that are statistically significantly worse; this way we do not waste computational time testing bad configurations. The R implementation is the irace package. Iterated F-Race (used by Chocolate) goes further: it runs several races, and each race uses the results of the previous ones to sample new candidate configurations in the most promising regions of the design space. A related family member named in the slides: CMA-ES (Covariance Matrix Adaptation Evolution Strategy), where parameters are variables of an optimization problem whose objective function is the performance of the resulting control program, and the variables are iteratively sampled according to a distribution adapted on the basis of the most promising previous samples.

Widget — F-Race, live

Ten candidate configurations with hidden true means. Each "instance" gives every surviving candidate a noisy observation. As soon as a candidate's observations are statistically worse than the current best (a simplified pairwise criterion), it is eliminated. Watch computation concentrate on the leaders.

round 0

9. The manifesto of automatic off-line design

Birattari, Ligot, Bozhinoski, Brambilla, Francesca, Garattoni, Garzón Ramos, Hasselmann, Kegeleirs, Kuckling, Pagnozzi, Roli, Salman and Stützle (2019) wrote the manifesto of the automatic off-line design of robot swarms — the reference that frames this whole chapter. Its core definitions:

The assumption that missions are sampled according to a probability measure gives a formal meaning to the notion of expected performance and to any other statistics describing the aggregate behaviour of a design method across the missions of interest.

What the manifesto criticises

With few exceptions, existing methods were studied following protocols not conceived to address the core research questions: focus on a single mission; the design method is not the protagonist of the study and is not given a name; no comparison with alternatives; control software tested only in simulation with no assessment of the reality gap; and the frequent presence of an iterative human-in-the-loop process (run, inspect, modify the objective function, rerun) that is never reported in the article and cannot be repeated — so robustness and repeatability are not assessed.

10. Fiorella's swarm gardening

The manifesto illustrates the approach with a running example. Fiorella owns a robot-swarm gardening business in the Brussels area, offering individually tailored service: every day she visits three or four customers with her swarm. Customers book via a form, asking for interventions (cutting grass, watering flowers...) and providing information on their garden (size, shape, orientation). The interventions and garden characteristics specify the mission; since the list of possible interventions and characteristics is huge, the class of possible missions is overwhelmingly large and diverse.

Fiorella relies on an automatic off-line method that designs and fine-tunes the behaviours of her swarm specifically for each mission — while she drives to the customer's garden, her powerful computers run simulations using the customer's information. The design must complete within the time of the ride: as she arrives, the selected design is uploaded and the swarm deployed. No per-mission human intervention and no test on the robots before deployment — both would increase costs dramatically.

For the exam — the three reasons the example matters

First, it makes the class of missions concrete: the form, the gardens and the interventions define a distribution, and expected performance is defined over it. Second, it fixes the economic condition for automatic design: the investment in the method pays off only if design is repeated many times. Third, it makes the no-intervention constraint vivid: the design process runs while Fiorella drives, with no opportunity to inspect or adjust — the only condition for the process to qualify as automatic off-line design is that initial (partial) solutions are selected without per-mission human intervention and without recourse to tests in the target environment.

11. Guidelines and the road to DEMIURGE

The manifesto closes with the tenets and guidelines for a healthy development of the domain. The two tenets: (i) automatic off-line design methods should not be mission-specific and should address a whole class of missions without modification; (ii) once a mission is specified, human intervention is not provided for in any phase of the design process. Researchers should therefore:

  1. provide a clear and thorough description of the design methods they propose, including the value of all parameters;
  2. precisely characterise the platforms for which the methods can generate control software;
  3. clearly identify and name methods for future reference;
  4. publish implementations;
  5. test methods on multiple missions;
  6. identify — at least informally — the class of missions a method is intended to address;
  7. perform comparative studies in which the methods under analysis are tested under the same conditions;
  8. run robot experiments to assess robustness to the reality gap.

The vision: in a relatively close future, automatic off-line design will be a practically relevant way of realising robot swarms — likely not the only one (manual, semi-automatic, automatic on-line and hybrid approaches will keep their roles), but a major one. The long-term horizon is the DEMIURGE project (Chapter 9): an intelligent system able to design and realise robot swarms in a totally integrated and automatic way — hardware and control software — starting from requirements expressed in an appropriate specification language.

Editor note — the course's two answers, connected

Chapter 9 ended with the design problem: requirements live at the collective level, the designer must decide the individual behaviour, and no general derivation exists. This chapter is the answer: cast design into optimization (FSA optimisation being one instance), search with racing, validate statistically (Chapter 15), and let the swarm itself be evaluated as a whole. Evolutionary robotics (Chapter 10) supplies the search machinery; automatic design supplies the framing. The two meet in DEMIURGE — and the "no best controller" lesson of Chapter 4 is what makes the whole enterprise compulsory rather than optional.

Check your understanding

Give the four axes along which design of control software is classified, and the conditions that justify automatic design.

Axes: manual / semi-automatic / automatic; off-line / on-line; simulation / real robots; software / hardware / both. Automatic design is justified when: manual or semi-automatic techniques are not effective, efficient or too costly; the design has to be repeated many times; the mission cannot be precisely defined because it is sampled from a distribution; the designer wants to explore new solutions.

Describe the off-line automatic design methodology.

The robot program is represented in a formal language (e.g. FSM); the design problem is encoded into a learning problem; in the training phase an optimization algorithm is used (e.g. evolutionary techniques); the program is designed in simulation and then tested in a real setting. The design problem is cast into an optimization problem solved off-line, before deployment, maximising a mission-specific performance measure assessed via simulations.

List the four issues of off-line automatic design.

Training and test sets (tuning vs assessment on different missions); merit factor (the objective/fitness function capturing the criteria that matter); simulation (the model used to evaluate candidates); reality gap (the difference between simulation models and reality — among the most challenging issues in automatic off-line design).

What is AutoMoDe, and what is the vocabulary of Vanilla?

AutoMoDe is an approach in which control software for robot swarms is automatically designed in the form of a probabilistic finite state machine by combining and fine-tuning preexisting parametric modules. Vanilla specialises it for the e-puck: twelve modules — six behaviours (exploration, stop, phototaxis, anti-phototaxis, attraction, repulsion; all but stop include obstacle avoidance) and six transitions (black-floor, gray-floor, white-floor, neighbour-count, inverted-neighbour-count, fixed-probability). The search space comprises PFSMs with up to four states and four outgoing edges per state.

What was Study A of the AutoMoDe-Chocolate paper, and what did it show?

Vanilla and EvoStick (evolutionary neural-network design) were compared with human designers (U-Human, unconstrained; C-Human, constrained to the same modules as Vanilla) on five tasks defined neutrally by researchers unaware of the methods. Results: Vanilla outperforms EvoStick; Vanilla outperforms U-Human; Vanilla performs worse than C-Human. Since Vanilla and C-Human share the module vocabulary, the difference is ascribed to the optimization algorithm.

What is Chocolate, and what did Study B establish?

Chocolate differs from Vanilla in a single aspect: it adopts Iterated F-Race instead of F-Race to explore the design space. Study B confirmed both working hypotheses: the more effective optimization algorithm improves over Vanilla, and under the experimental conditions considered Chocolate outperforms C-Human — making it the first automatic design method for robot swarms shown to outperform a human designer (350 runs, swarm of 20 robots, five methods on five tasks).

Formalise the metaheuristic configuration problem.

Θ is the finite set of candidate configurations; I the set of instances with probability measure PI; t(i) the computation time allocated to instance i; c(θ,i) the random cost of the best solution found by running θ on i for t(i) seconds. The problem is θ* = arg min C(θ) with C(θ) = E[c(θ,i)], the expectation over both instance distribution and run stochasticity, estimated on a training set of instances — a problem of generalisation, as in machine learning.

Explain the racing idea and how F-Race and Iterated F-Race differ.

A racing method evaluates candidate configurations iteratively on new sampled instances and discards bad ones as soon as statistically sufficient evidence is gathered against them, so computation is not wasted on bad configurations. F-Race is the basic procedure; Iterated F-Race (adopted by Chocolate, via the irace R package) performs several races and uses the results of previous races to sample new candidates in the most promising regions of the design space. CMA-ES is a related approach that adapts a sampling distribution to the most promising previous samples.

State the definitional core of the automatic off-line design manifesto.

The design problem is cast into an optimization problem solved off-line, before deployment: an optimization algorithm searches a space of possible designs to maximise a mission-specific performance measure, assessed via simulations; the selected design is then uploaded and deployed, crossing the reality gap. The method must operate on missions sampled from a class of interest without mission-specific adjustments or per-mission human intervention. The class of missions — a set of missions with a probability measure — gives formal meaning to expected performance.

Explain Fiorella's swarm gardening and what it illustrates.

Fiorella runs a robot-swarm gardening business; customers specify interventions and garden characteristics, defining a mission sampled from a huge class. While she drives to the customer, her computers automatically design and fine-tune the swarm's behaviour for that specific mission; on arrival the design is uploaded and deployed, with no per-mission human intervention or testing. The example illustrates the class-of-missions notion, the economic condition (design repeated many times), and the no-intervention constraint that qualifies a process as automatic off-line design.

List the eight guidelines of the manifesto.

(1) Clear and thorough description of methods including all parameter values; (2) precise characterisation of the platforms; (3) identify and name methods; (4) publish implementations; (5) test on multiple missions; (6) identify the class of missions addressed; (7) comparative studies under the same conditions; (8) robot experiments to assess robustness to the reality gap.

How do evolutionary robotics (Chapter 10) and automatic design relate?

ER is the historical core of automatic design: it optimises robots by evolution. Automatic design generalises it: the design problem is cast into an optimization problem over a parametric controller architecture, and any optimization algorithm can be used — evolutionary techniques are one option, FSA optimisation, behaviour-tree configuration and Boolean networks are others. The same design problem (collective requirements, individual behaviour) is attacked; the search machinery differs.