Class AstPrinter
this, parent and dref. The output is a Clafer
model, which the Clafer compiler reads with -f (the names are already
UIDs) and -l (no layout). Two models print the same when they have
the same clafers, constraints, objectives and assertions, so the output can
be compared, e.g., between two compilers of the same Clafer model. The
scopes, all of them, go to the model's .cfr-scope file
(ScopeFile). The solver options (e.g., branching
priorities) are not printed.
The clafers, their children and their constraints are printed in the order
they were added, which is the order of the source and of the instances,
abstract and concrete clafers interleaved (see sourceOrder(List, List)).
Source spans are not printed.
Nesting is in braces, as in Clafer without layout: every clafer has its
block, {} if it is empty. The indentation is only for reading;
whitespace and line breaks carry no meaning.
Values are printed as they apply, declarations where they are declared. A
group card and a multiplicity are values: a clafer without its own group
card has its super clafer's, as chocosolver solves it, and 0..* if
no super clafer has one; an abstract clafer's multiplicity is 0..*.
Children, constraints and references are declarations: they stay under the
clafer that declares them. A reference is printed only where it is declared
or redefined, since in Clafer a reference written on a sub clafer redefines
the inherited one, even with the same target.
Expressions are fully parenthesized, except for navigation (.),
which binds tightest. sum and product take a set of clafers
and add (multiply) the dref of each instance, so two instances with
the same value count twice; this is printed as in Clafer, e.g.,
sum c0_Phone.c0_cost.dref. An explicit dereference inside would
print as .dref.dref.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringPrints an expression.static StringPrints the clafers and constraints of a model.static StringPrints a model with its objectives and assertions, as an explicit model:ExplicitHeader, then the model.
-
Field Details
-
ExplicitHeader
The first line of an explicit model, which declares it to the Clafer compiler (its options -f -k -l --ss=none) and to chocosolver (read withToAst, not compiled by clafer).- See Also:
-
-
Method Details
-
print
Prints a model with its objectives and assertions, as an explicit model:ExplicitHeader, then the model. Its scopes go to a separate file, seeScopeFile.print(AstModel, Scope).- Parameters:
model- the modelobjectives- the objectivesassertions- the assertions- Returns:
- the model as text, one line per clafer, constraint, objective and assertion
-
print
-
print
-