Compiler-Like Architecture and Model Transformation
A compiler-like architecture organizes business expressions, mathematical representations, backend execution, and business results. The analogy explains separation of responsibilities; it does not make modeling synonymous with text compilation or solving with code generation.
1. Frontends, intermediate representations, and backends
| Layer | Retained information | Responsibility |
|---|---|---|
| Business frontend | Entities, parameters, rule identities, units, contexts | Bind business definitions to mathematics |
| Symbolic and modeling layer | Variables, expressions, function symbols, constraints, objectives | Compose, check, and organize semantics |
| Solver-level representation | Domains and relations for a target model class | Explicit transformations and executable auxiliary structures |
| Backend adapter | Solver-specific objects and settings | Match capabilities, load models, solve, read status |
| Result mapping | Original identities and transformation mappings | Return solutions and diagnostics to business objects |
There need not be a single intermediate representation. Sparse linear coefficients, quadratic terms, and native CP relations differ; not every model should become a linear matrix first.
2. Internal DSLs do not reparse host code
Kotlin/Rust syntax is already handled by the host compiler. Modeling DSLs normally construct expressions through objects and operations, without lexing their source strings again.
Model-level semantic checks remain necessary: references must belong to this run, types and domains must agree, linearity must be established, and logical or global constraints need a suitable execution path. These checks differ from successful host-language compilation.
Symbolic Expressions carry mathematical structure; units, permissions, and provenance need additional bindings.
3. Running example: a production-shortfall penalty
Overview, concepts, and variables
A production context chooses integer quantity
Intermediate value and original objective
Define shortage:
Total cost combines production and shortage:
The production domain already imposes capacity. Here
Transformed constraints
Introduce a continuous auxiliary
and minimize
This is not an unconditional formulation of the function graph: nonoptimal transformed points can have
Result
For
4. Preserve provenance through transformation
A function symbol can generate several rows and auxiliary columns. Record their relationships to original symbols, variables, and constraints. Public reports use business identities rather than mutable row and column positions.
Solution mapping differs from diagnostic mapping. The former retrieves original variables and evaluates intermediates; the latter explains why internal constraints exist and which business rule they implement. Renaming a low-level IIS does not establish original-constraint-level minimality.
5. Equivalence, relaxation, and approximation
An exact transformation should state whether it preserves projected feasibility, objective values, or optimal solutions. Auxiliary variables change the dimension, so equality of feasible sets in different spaces is not the right claim.
A relaxation typically enlarges feasibility and can provide bounds; its solutions may violate the original model. Piecewise approximation changes a function and needs a stated interval and error. Expression simplification rewrites representation during construction; it is not optimization solving.
If a backend lacks a semantic feature, select an explicit transformation or reject the model. Do not silently drop terms, relax integrality, or approximate while claiming to solve the unchanged model.
6. Backend independence and capability boundaries
Backend independence means business rules do not directly depend on vendor objects, not that all backends have identical features. Model classes, domains, logic, time controls, and diagnostics need capability matching.
Remote execution can transport versioned model representations, but process-local addresses are not cross-machine identities. Manage models, parameters, transformation policies, and solver settings separately; see Remote Solving.
7. Connections to other chapters
The Domain Language explains composition, DDD business ownership, and this chapter transformation and execution. Formal Design and Verification develops correctness arguments; Critical Constraint Analysis uses reverse evidence mapping to explain objective limits.