Skip to content

Commit c53adb0

Browse files
committed
docs: update BREAKING.md and CHANGELOG.md for definition refactor in 0.9.15
1 parent 573e4cb commit c53adb0

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

BREAKING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@ The old function names were misleading because they returned the dimension of du
3232

3333
The functions `dim_*_constraints_box(ocp::Model)` (for Model, not Solution) remain unchanged and still refer to constraint dimension in the model.
3434

35+
### Breaking Changes: Definition Getter Removal on PreModel
36+
37+
The `definition` and `expression` getters on `PreModel` have been removed to maintain consistency with the rest of the codebase where `PreModel` fields are accessed directly.
38+
39+
#### Migration Guide
40+
41+
```julia
42+
# Before (removed getters)
43+
d = definition(pre) # No longer available
44+
e = expression(pre) # No longer available
45+
46+
# After (direct field access)
47+
d = pre.definition # Access the field directly
48+
e = expression(pre.definition) # Pass the definition to expression()
49+
```
50+
51+
#### Rationale
52+
53+
The removal aligns with the existing pattern in CTModels where `PreModel` fields are accessed directly (e.g., `pre.state`, `pre.control`, `pre.variable`) rather than through getter functions. Getters on `Model` remain unchanged.
54+
55+
#### Note
56+
57+
The `definition(ocp::Model)` and `expression(ocp::Model)` getters remain available and unchanged. Only the `PreModel` variants were removed.
58+
3559
### Non-Breaking Changes
3660

3761
This release also introduces consistent variable and control checking functions without breaking existing functionality:

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- **Display improvement**: Dual variables only displayed if model has declared constraints
2828
- **New exports**: `dim_dual_state_constraints_box`, `dim_dual_control_constraints_box`, `dim_dual_variable_constraints_box`
2929

30+
#### Optional Definition with EmptyDefinition Sentinel
31+
32+
- **Type hierarchy**: Introduced `AbstractDefinition` with concrete types `Definition(expr::Expr)` and `EmptyDefinition` (sentinel)
33+
- **Optional definition**: `PreModel.definition` defaults to `EmptyDefinition()` instead of `nothing`
34+
- **Model parametric**: `Model` is now parametric on `DefinitionType<<:AbstractDefinition`
35+
- **Expression getter**: Added `expression()` function to extract `Expr` from `AbstractDefinition`
36+
- **Build relaxation**: Removed precondition requiring definition in `build()`
37+
- **Display refactor**: Split `Display/print.jl` into 5 focused files by responsibility
38+
- **Code organization**: Moved definition setters to `Components/definition.jl`, Model getters to `Building/model.jl`
39+
40+
#### API Enhancements
41+
42+
```julia
43+
# Definition is now optional
44+
pre = PreModel()
45+
pre.definition isa EmptyDefinition # true by default
46+
47+
# Set definition via setter (auto-wraps Expr)
48+
definition!(pre, quote
49+
t [0, 1], time
50+
x R, state
51+
u R, control
52+
(t) == u(t)
53+
(0.5u(t)^2) min
54+
end)
55+
56+
# Extract expression
57+
expr = expression(pre.definition) # Returns the Expr
58+
59+
# Build without definition is now valid
60+
model = build(pre) # Works even without definition
61+
```
62+
63+
#### Breaking Changes
64+
65+
- **PreModel getters removed**: `definition(pre::PreModel)` and `expression(pre::PreModel)` removed; use `pre.definition` and `expression(pre.definition)` instead
66+
- **Model getters unchanged**: `definition(model::Model)` and `expression(model::Model)` remain available
67+
3068
#### Consistent Variable and Control Checking Functions
3169

3270
- **New functions**: Added `is_variable()` and `is_control_free()` for checking problem properties

0 commit comments

Comments
 (0)