DiscoverLearnDocumentationGet OpenPLXSearch Contact

Becomes syntax

When extending from another model it is sometimes useful to specialize the type of one of variables in the parent class. This can be achived with the becomes keyword.

GeneralModel:
    x is Real: 0.0

SpecializedModel is GeneralModel:
    y is Real: 1.1

ParentModel:
    foo is GeneralModel

MyModel is ParentModel:
    foo becomes SpecializedModel

To specialize the type a variable inside a model enter the name of the variable, indented, followed by the becomes keyword and the type. The type must be compatible with the previous type. You can also provide a value expression by entering a : after the type followed by an expression.

Grammar

type_specilization → INDENT? IDENTIFIER "becomes" (IDENTIFIER ".")* IDENTIFIER ("[]")? (":" expression)?