Skip to content

Config Optimization plugin

Contributes the problem and goal sections to the config language: which model is being optimised, and what makes one candidate better than another.

At a glance

Plugin idconfig-optimization-service
Display nameConfig Optimization
DescriptionLanguage support for config optimization sections
Default URL/plugin/config-optimization
Sourceapp/packages/service-config-optimization, app/packages/language-config-optimization
Depends onThe Config, Metamodel and Script plugins

Languages contributed

Language idNameExtensionTextual editorGraphical editorGenerated
config-optimizationConfig Optimization

The config-optimization language

This is a generated language with no file extension and no editor. It exists so the plugin's own grammar can be used as a language in its own right: when the config service needs the problem and goal sections of a file computed, it sends just those sections to this language's service, which parses them with a standalone grammar built from the same rules.

You never create a file in this language. Its syntax is the syntax of the sections below.

Contribution plugins contributed

Target languageSectionsExecutable
configproblem, goalno
Contribution plugin idconfig-optimization
Short nameoptimization
Grammar dependenciesconfig-metamodel, config-script
Section dependenciesnone

The dependencies are what let this grammar refer to things it does not own: metamodel classes and properties come from the metamodel plugin's exported types, script functions from the script plugin's.

The problem section

Names the metamodel and the model the search starts from.

mdeo-config
problem {
    metamodel = "./shapes.mm"
    model = "./shapes.m"
}
KeyTypeMeaning
metamodelpathThe .mm file describing the domain
modelpathThe .m file to start the search from

Both keys are required, may appear in either order, and each may appear only once. Validation checks that the paths resolve, that they point at files of the right language, and that the model actually imports the metamodel you named.

The goal section

States what to optimise.

mdeo-config
goal {
    import { shapeCount, invisibleShapes, emptyLayers } from "./metrics.fn"

    minimize invisibleShapes
    maximize shapeCount
    constraint emptyLayers

    refine Canvas.layers[1..4]
}
EntrySyntaxMeaning
Importimport { a, b as c } from "./file.fn"Bring script functions into scope
Objectiveminimize f / maximize fAdd an objective
Constraintconstraint fAdd a constraint
Refinementrefine Class.property[m]Narrow a multiplicity for the search

Entries may be given in any order and repeated.

Objectives and constraints must refer to script functions that take no parameters and return a numeric type. A constraint returns 0 when satisfied; larger values are the degree of violation. At least one objective is required.

Refinements tighten a multiplicity declared in the metamodel, for the purposes of the search only. refine Canvas.layers[1..4] tells the search that a canvas should have between one and four layers, without changing the metamodel that other files share.

Full example

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

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

    minimize unassignedEffort
    minimize maxOverload
    constraint unassignedHighPriority
}

search {
    mutations {
        using "./assign.mt"
        using "./unassign.mt"
    }
}

solver {
    algorithm = NSGAII

    parameters {
        population = 40
        variation = mutation

        mutation {
            step = 1
            strategy = random
        }
    }

    termination {
        evolutions = 500
    }
}

runtime {
    timeout {
        script = 1000
        transformation = 1000
    }

    resources {
        threads = 4
    }
}

Server-side capabilities

KeyKindContents
astfile dataThe serialised AST of the standalone language
configrequestComputes the section data for the problem and goal sections when the config service asks for it

The plugin declares no executable section, so it never receives an execution. Its computed section data is consumed by Config MDEO, which declares a section dependency on problem.

Released under the terms of the repository licence.