Skip to content

Config MDEO plugin ​

Contributes the search, solver and runtime sections: which moves the search may make, which algorithm makes them, and what resources the run may use. It also owns the executable section, so this is the plugin that actually starts an optimisation.

At a glance ​

Plugin idconfig-mdeo-service
Display nameConfig MDEO
DescriptionLanguage support for config MDEO sections (search and solver)
Default URL/plugin/config-mdeo
Sourceapp/packages/service-config-mdeo, app/packages/language-config-mdeo
Depends onThe Config and Config Optimization plugins; executions go to optimizer-execution

Languages contributed ​

Language idNameExtensionTextual editorGraphical editorGenerated
config-mdeoConfig MDEO—❌❌✅

The config-mdeo language ​

A generated language with no extension and no editor, used the same way as config-optimization: the config service sends it the fragment of a .config file containing this plugin's sections, and it parses them with a standalone grammar built from the same rules.

Contribution plugins contributed ​

Target languageSectionsExecutable
configsearch, solver, runtimesolver
Contribution plugin idconfig-mdeo
Short namemdeo
Grammar dependenciesconfig-optimization
Section dependenciesproblem from optimization

The section dependency matters: before this plugin can resolve create Annotation or mutate Canvas.layers it has to know which metamodel the problem uses. The config service therefore computes the problem section first and passes its result along.

The search section ​

The operators available to the search: mutation operators, which change one model, and crossover operators, which combine several.

mdeo-config
search {
    mutations {
        using "./match.mt"

        create Annotation
        delete Annotation
        mutate Circle

        add Layer.shapes
        remove Layer.shapes
        mutate Canvas.layers
    }
}
EntryMeaning
using "path.mt"Use a hand-written model transformation as a mutation operator
using "path.mt" with { … }The same, with values for its inputs — see Operator arguments
create ClassGenerate operators that add an object of the class, or of each concrete subclass
delete ClassGenerate an operator that removes an object of the class or of a subclass
add Class.edgeGenerate operators that link objects through the association end
remove Class.edgeGenerate operators that unlink them
mutate Class.edgeBoth of the above
mutate Classcreate, delete and mutate Class.edge for every association end of the class

edge is an association end of the class, declared on it or inherited; attributes are never changed.

A using entry may name a transformation whose metamodel is the problem's metamodel or one the problem's metamodel imports. A callable transformation is a mutation operator if it has no model inputs and every required input — an input without default and with a non-nullable type — is passed by the entry's with { } block. List the transformation that calls the others, not the callees: each listed file is one operator, whatever it calls. Entries may be mixed and repeated in any order. Generated operators are written into the result tree as .mt_gen files, so you can read exactly what the search was allowed to do.

Generated operators ​

Generated operators never break a multiplicity: applied to a model in which every object has an allowed number of links through each association end, they produce a model in which it still does. Refinements from the goal section count as part of the metamodel, so the operators keep the refined bounds too.

Which operators an entry produces depends on the multiplicities at both ends of the association:

OperatorGenerated forWhat it does
ADD_A_e, REMOVE_A_eends where neither side is fixedLink or unlink an A and a B
CHANGE_A_ea fixed end, or a fixed oppositeMove a link to another partner
SWAP_A_ea fixed end, or ends whose bounds can all be reached at onceTwo As exchange a partner
CREATE_A_…every container and combination of repairsAdd an object and link it as its bounds require
DELETE_Athe classRemove an object, moving partners that need a fixed number of links

Generated mutation operators explains each operator, the cases in which none can exist, and how the generator differs from the papers it is based on. Operators that could not be generated, or are limited, are listed in generated-mutations/warnings.md in the results.

Operator arguments ​

A using entry, in mutations and in crossovers, may pass values to the in declarations of its transformation in a with { } block, one name = value per line. One file can so serve as several differently tuned operators:

mdeo-config
search {
    mutations {
        using "./move.mt" with {
            maxLoad = 4
        }
        using "./move.mt" with {
            maxLoad = 100
        }
        using "./swap.mt"
    }
}

The values are literals:

LiteralExamplesPassed to
int4, -1int, long, float, double
long42Llong, float, double
float2.5f, 2.5E-3ffloat, double
double2.5, 1e3, 2.5ddouble
string, boolean"fast", truestring, boolean
enum literalTier.FRONTENDan input of that enum of the problem's metamodel
list[1, 2, 3], [Tier.FRONTEND, Tier.BACKEND], []List<T> and Set<T> inputs, each element as above

Numbers convert as in the transformation language — int to long to float to double — and never the other way round, so a float input takes 2.5f, not 2.5. An int literal must fit an int (write 3000000000L for a long input), and a long literal must lie within ±253, since the configuration travels as JSON numbers. A Set keeps one of equal values. There are no expressions, no references to model elements and no null: leave the argument out instead, and the input takes its default, or null when it is optional.

The validator checks each block against the transformation's declarations: every name must be an input — outputs and unknown names are errors, and so is a name set twice — and only scalar, enum and List / Set-of-scalar or enum inputs can be set. Element inputs (Class, Class?, List<Class>) and model inputs cannot; the optimizer binds the models of a crossover itself. An input the block sets counts as supplied, so in maxLoad: int without default is fine in an operator as long as every entry of the file sets it; an entry that does not is an error naming the input. An empty with { } is redundant and reported as a warning. Completion inside the block offers the inputs that can still be set, and hovering a name shows its declaration.

Arguments are bound exactly as the arguments of a call, before the first statement. Each using entry is an operator of its own — two entries of the same file are two operators in the random choice of operators. The results show each with its arguments, e.g. move.mt (maxLoad = 4).

Crossover operators ​

A crossovers block lists crossover operators: transformations that read further models through model inputs. It only takes using entries, with or without with { }; there are no generated crossover operators.

mdeo-config
search {
    crossovers {
        using "./take-tier.mt"                 // in donor: model         → 2 parents
        using "./take-tier.mt" with {
            tier = Tier.FRONTEND
        }
        using "./follow-donors.mt"             // in donors: List<model>  → any number of parents
    }
}

A crossover operator runs on a copy of one parent, the primary, which becomes the child, and reads the other parents of its group, the donors, through its model inputs. A transformation is a crossover operator when

  • it has at least one model input: either single model inputs — then it takes one parent more than it has model inputs, and the donors are bound to them in declaration order — or exactly one List<model> input and no single one — then it takes any number of parents, and the list holds all donors;
  • every other required input is passed by its with { } block; outputs are ignored;
  • it accepts the configured crossover { parents }: a fixed-arity operator needs exactly parents - 1 model inputs.

A file with model inputs under mutations, or without under crossovers, is an error that names the block it belongs in. Crossover operators only run with variation = genetic; otherwise the block is reported as unused.

The solver section ​

The search algorithm and when to stop. This is the executable section: a config file containing it gets a run action.

mdeo-config
solver {
    algorithm = NSGAII

    parameters {
        population = 40
        variation = genetic

        crossover {
            rate = 0.9
            parents = 2
            strategy = random
        }

        mutation {
            step = interval(1, 5)
            strategy = random
        }
    }

    termination {
        evolutions = 500
    }

    batches = 3
}
KeyValuesMeaning
algorithmNSGAII, IBEA, SPEA2, SMSMOEA (SMS-EMOA), VEGA, PESA2, PAESThe multi-objective algorithm
batchesintegerRun the same configuration this many times independently

parameters ​

KeyValuesMeaning
populationintegerPopulation size
variationmutation, geneticHow offspring are produced: by mutation alone, or by crossover and mutation
bisectionsintegerPESA2 / PAES only
crossover { … }blockCrossover tuning for variation = genetic, see below
mutation { … }blockMutation tuning, see below
archive { size = n }blockPESA2 / PAES only

mutation ​

KeyValuesMeaning
stepn, fixed, fixed(n), interval(lo, hi)How many operators to apply per mutation
strategyrandom, repetitiveHow operators are chosen
selectionrandomHow matches are selected
applicationrandomHow an operator is applied
creditrandomOperator credit assignment
repairdefaultRepair strategy after a mutation

step = interval(1, 5) draws uniformly from [1, 5) on every call; fixed with no argument means one. step = 0 (or fixed(0)) applies no operator: offspring are then copies of their parents, or with variation = genetic exactly what the crossover made. The initial population is made by mutating the start model with the same step, so with step = 0 it consists of copies of the start model, and crossovers between them change nothing until the models differ.

crossover ​

KeyValuesDefaultMeaning
ratenumber in [0, 1]0.9Probability that a group of parents is crossed over
parentsinteger ≥ 22Parents per crossover; every crossover yields one child per parent
strategyrandomrandomHow a crossover operator is chosen

Each key may appear once. The block only applies with variation = genetic and is reported as unused otherwise; without it, genetic uses the defaults.

How variation = genetic makes offspring ​

variation = mutation produces every offspring by mutating a copy of one parent. variation = genetic needs a non-empty crossovers block, and makes offspring from groups of parents parents that the algorithm selects:

  1. Rate. Whether a group is crossed over is drawn once per group, with probability rate, on the node that coordinates the run. A group that is not crossed over yields a copy of each parent.
  2. One child per parent. A group of parents parents yields parents children — two for the default. Child i has parent i as its primary parent and the others as donors, in cyclic order starting after i: with parents A, B, C, the children are A ← (B, C), B ← (C, A) and C ← (A, B).
  3. Operator choice. Each child picks a crossover operator on its own, uniformly among the operators that accept the group's parent count, and runs it on a copy of its primary parent with the donors as model inputs. An operator applies when the transformation succeeds or stops — so a for match that finds nothing applies without changing the child. When it fails, or kills, its changes are undone and another untried operator is tried; when all fail, the child is a copy of its primary parent.
  4. Mutation. Every child — crossed over or copied — is then mutated with the mutation { step, strategy } settings, exactly as an offspring of variation = mutation.
  5. Evaluation. The child's objectives and constraints are evaluated as usual.

Neither parent is changed. The optimizer remembers which mutation operators failed on a model so it can skip them on unchanged copies (the skipped transformations of the metrics); a crossover's outcome depends on its donors as much as on the child, so crossover failures are never remembered. With rate = 0, genetic behaves like mutation. In a run spread over several nodes, a child is made on the node holding its primary parent; donors held by other nodes are copied there for that generation and dropped afterwards.

How the children enter the population depends on the algorithm. When population is not a multiple of parents, the last group of a generation makes up to parents - 1 children more than the population size — the overshoot.

AlgorithmChildren of a generation
NSGAIIGroups are selected by binary tournament until at least population children exist. All are evaluated — the overshoot too — and compete with the population; non-dominated sorting and crowding distance cut the union back to population.
SPEA2As NSGA-II; the union is cut back by strength fitness and density.
IBEAAs NSGA-II; the indicator-worst solution is removed until population remain.
SMSMOEASteady state: each step inserts one child and removes the worst solution. The children of a group are evaluated together and inserted over parents consecutive steps, so every child enters the population (the parents selected in those steps are not used). Children still waiting when the run ends were evaluated but not inserted.
VEGANot elitist: the population is rebuilt from the children of consecutive groups, and parents do not survive. Children beyond population are dropped before they are evaluated.
PESA2The population is rebuilt every generation from groups selected from the archive by region, until at least population children exist; all are evaluated and offered to the archive, whose size bounds what survives.
PAESNot supported: PAES evolves one solution with one mutation per step, so variation = genetic with PAES is an error.

The population size stays population for every algorithm. The evolutions of the termination block are counted in evaluations — evolutions × population of them — so overshooting children count too.

In the results, summary.md lists the mutation and the crossover operators separately, each with its arguments, and plots per generation how many children crossed over successfully and how many fell back to a copy, and how often each crossover operator applied. report.json holds the same under operators.crossovers and, per generation, crossover { attempted, succeeded, fellBack, perOperator }, counted per child; perOperator is keyed by the operator's id in operators.crossovers.

termination ​

KeyMeaning
evolutionsStop after this many generations (evolutions × population evaluations)
timeStop after this many seconds
deltaStop when the improvement stays below this threshold
iterationsNumber of non-improving iterations tolerated before stopping

Several conditions combine with OR — the first one to trigger ends the run.

The runtime section ​

Execution limits.

mdeo-config
runtime {
    timeout {
        script = 1000
        transformation = 1000
    }

    backend = MDEO

    resources {
        threads = 10
        nodes = 4
        threadsPerNode = 3
    }
}
KeyMeaning
timeout.scriptMilliseconds a single objective or constraint evaluation may take
timeout.transformationMilliseconds a single transformation application may take
backendMDEO (default) or Tinker — the graph representation used during search
resources.threadsUpper bound on total worker threads
resources.nodesUpper bound on execution nodes taking part
resources.threadsPerNodeUpper bound on threads per node

All fields are optional and act as upper bounds against what the deployment actually offers.

Full example ​

mdeo-config
// Which model is optimised, and against which metamodel.
// Contributed by the Config Optimization plugin.
problem {
    metamodel = "./shapes.mm"
    model = "./shapes.m"
}

// What "better" means. Contributed by the Config Optimization plugin.
goal {
    import { shapeCount, invisibleShapes, emptyLayers } from "./metrics.fn"

    minimize invisibleShapes
    maximize shapeCount
    constraint emptyLayers

    refine Canvas.layers[1..4]
}

// How new candidate models are derived. Contributed by the Config MDEO plugin.
search {
    mutations {
        using "./match.mt"
        using "./control-flow.mt"

        create Annotation
        delete Annotation
        mutate Circle

        add Layer.shapes
        remove Layer.shapes
        mutate Canvas.layers
    }
}

// Which search algorithm runs, and for how long. Contributed by the Config MDEO plugin.
solver {
    algorithm = NSGAII

    parameters {
        population = 40
        variation = mutation

        mutation {
            step = interval(1, 5)
            strategy = random
            selection = random
            application = random
            credit = random
            repair = default
        }
    }

    termination {
        evolutions = 500
        time = 600
        delta = 5
        iterations = 3
    }

    batches = 3
}

// Execution limits for the run. Contributed by the Config MDEO plugin.
runtime {
    timeout {
        script = 1000
        transformation = 1000
    }

    backend = MDEO

    resources {
        threads = 10
        nodes = 4
        threadsPerNode = 3
    }
}

Example with crossover ​

A deployment of components on servers, optimised with mutation and crossover operators. The crossover operators are shown under Model inputs.

mdeo-config
problem {
    metamodel = "./deployment.mm"
    model = "./deployment.m"
}

goal {
    import { usedServers, maxOverload } from "./objectives.fn"

    minimize usedServers
    minimize maxOverload
}

search {
    mutations {
        // one file, two operators: small moves and moves of any component
        using "./move.mt" with {
            maxLoad = 4
        }
        using "./move.mt" with {
            maxLoad = 100
        }
        using "./swap.mt"
    }
    crossovers {
        using "./take-tier.mt"
        using "./take-tier.mt" with {
            tier = Tier.FRONTEND
        }
        using "./follow-donors.mt"
    }
}

solver {
    algorithm = NSGAII

    parameters {
        population = 40
        variation = genetic

        crossover {
            rate = 0.9
            parents = 2
            strategy = random
        }

        mutation {
            step = interval(1, 3)
            strategy = random
        }
    }

    termination {
        evolutions = 200
    }
}
mt
using "./deployment.mm"

// Mutation: moves a component to another server. `maxLoad` has no default, so every
// configuration that lists this operator passes it in a `with { }` block.
in maxLoad: int

match {
    component: Component {
        load <= maxLoad
    }
    current: Server { }
    target: Server { }
    delete component.host -- current
    create component.host -- target
}

Server-side capabilities ​

KeyKindContents
astfile dataThe serialised AST of the standalone language
configrequestComputes the section data for search, solver and runtime
config-executionrequestStarts an optimisation run
config-execution-get-summaryrequestThe markdown summary of a run
config-execution-get-file-treerequestThe result file tree
config-execution-get-file / -get-filesrequestResult file contents
config-execution-cancelrequestCancel a running optimisation
config-execution-deleterequestDelete a finished run and its results

Execution requests are forwarded to the optimizer-execution service, which is the component that scales across nodes. See Reading the results for what comes back.

Released under the terms of the repository licence.