You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BREAKING.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,30 @@ The old function names were misleading because they returned the dimension of du
32
32
33
33
The functions `dim_*_constraints_box(ocp::Model)` (for Model, not Solution) remain unchanged and still refer to constraint dimension in the model.
34
34
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
+
35
59
### Non-Breaking Changes
36
60
37
61
This release also introduces consistent variable and control checking functions without breaking existing functionality:
#### 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
+
30
68
#### Consistent Variable and Control Checking Functions
31
69
32
70
-**New functions**: Added `is_variable()` and `is_control_free()` for checking problem properties
0 commit comments