The Language of Operations Research
OSPF modeling interfaces can be understood as an internal domain-specific language (DSL): valid Kotlin or Rust programs express mathematical models while making business concepts nameable, composable, and reusable. This chapter explains that language without requiring knowledge of solver algorithms.
1. Primitives, composition, and abstraction
A modeling language needs three layers. Primitives introduce constants, parameters, and decision variables. Composition forms arithmetic expressions, logical relations, constraints, and objectives. Abstraction names recurring expressions so they can be used as units.
| Element | Mathematical meaning | Not the same as |
|---|---|---|
| Parameter | Data known before this model is built | A solver-selected variable |
| Variable | An unknown value in a specified domain | Its value in an incumbent |
| Expression | A relation built from parameters, variables, and operations | A completed numerical calculation |
| Intermediate value | A named expression with business meaning | A freely chosen independent variable |
| Constraint | A condition restricting feasible plans | An assertion checking input data |
| Objective | A preference among feasible plans | A mandatory feasibility condition |
Linear and polynomial expressions are only part of the language. Logical relations, finite domains, and CP global constraints have their own semantics; they are not all inequalities between polynomials.
2. Running model: compartment loading
Overview, concepts, and sets
A loading context decides where cargo goes and limits compartment weight, area loading, and loading per unit length. This is a simplified static uniform-loading model, not a structural-strength analysis.
Let
Variables and predicates
The dimensionless variable
Intermediate values
Compartment weight sums the mass assigned to it:
Area and line loading both derive from that weight:
These are not three independent decisions. Once
Data assertions and constraints
Positive areas and lengths are input assertions checked before constructing expressions, not choices left to the solver. Load each item at most once and respect all three compartment limits:
Objective and result
Maximize loaded mass:
Take one compartment with
3. Why intermediate values matter
If every constraint repeats
An intermediate value can appear like a variable in composition while remaining mathematically bound to its definition. An arithmetic intermediate may be expanded; a function symbol may require auxiliary variables and constraints. A name need not create a solver column, nor be mere textual substitution. See Compiler-Like Architecture and Model Transformation.
Sharing belongs to an explicit model or business context, not to process-global state. Reusing a symbol from an old model in a new one can break identity and lifetime assumptions.
4. Indices, bulk expressions, and the host language
An internal DSL uses host-language functions, types, collections, and operators to construct expressions. Ordinary host-language branches run during model construction. Conditions depending on unknown decisions must become symbolic logic, not ordinary Boolean branches that prematurely choose an outcome.
5. From language to business components
A loading context can expose
Continue with The Modeling and Solving Workflow for assembly, and Using Domain-Driven Design for collaboration across business contexts.