Skip to content

Commit b6b2d8f

Browse files
committed
refactor: reorganize solve files to avoid name redundancy
- Rename files to remove 'solve' prefix: - solve_mode.jl → mode.jl - solve_canonical.jl → canonical.jl - solve_explicit.jl → explicit.jl - solve_descriptive.jl → descriptive.jl - Delete redundant test files: - test_solve_dispatch.jl (functionality moved to test_explicit.jl) - test_solve_mode.jl (functionality moved to test_mode.jl) - Update includes in src/OptimalControl.jl This makes the file structure cleaner and avoids naming redundancy while maintaining the same functionality.
1 parent a49bd54 commit b6b2d8f

8 files changed

Lines changed: 48 additions & 111 deletions

File tree

src/OptimalControl.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module OptimalControl
99

1010
using DocStringExtensions
1111
using Reexport
12+
using CTBase
1213

1314
# Imports
1415
include(joinpath(@__DIR__, "imports", "ctbase.jl"))
@@ -29,11 +30,11 @@ include(joinpath(@__DIR__, "helpers", "strategy_builders.jl"))
2930
include(joinpath(@__DIR__, "helpers", "component_completion.jl"))
3031

3132
# solve
32-
include(joinpath(@__DIR__, "solve", "solve_mode.jl"))
33+
include(joinpath(@__DIR__, "solve", "mode.jl"))
3334
include(joinpath(@__DIR__, "solve", "mode_detection.jl"))
34-
include(joinpath(@__DIR__, "solve", "solve_dispatch.jl"))
35-
include(joinpath(@__DIR__, "solve", "solve_canonical.jl"))
36-
include(joinpath(@__DIR__, "solve", "solve_explicit.jl"))
35+
include(joinpath(@__DIR__, "solve", "canonical.jl"))
36+
include(joinpath(@__DIR__, "solve", "explicit.jl"))
37+
include(joinpath(@__DIR__, "solve", "descriptive.jl"))
3738

3839
export methods # non useful since it is already in Base
3940
export get_strategy_registry

src/solve/descriptive.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
$(TYPEDSIGNATURES)
3+
4+
Stub for descriptive mode resolution.
5+
6+
Raises [`CTBase.NotImplemented`](@ref) until `solve_descriptive` is implemented.
7+
This stub allows testing the orchestration layer (mode detection, dispatch routing)
8+
before the descriptive mode handler exists.
9+
10+
The `description` vararg will be forwarded to `solve_descriptive` when implemented.
11+
12+
# Arguments
13+
- `ocp`: The optimal control problem to solve
14+
- `description`: Symbolic description tokens (e.g., `:collocation`, `:adnlp`, `:ipopt`)
15+
- `initial_guess`: Normalized initial guess (processed by Layer 1)
16+
- `display`: Whether to display configuration information
17+
- `registry`: Strategy registry
18+
- `kwargs...`: Strategy-specific options
19+
20+
# Throws
21+
- `CTBase.NotImplemented`: Always — descriptive mode is not yet implemented
22+
23+
# See Also
24+
- [`DescriptiveMode`](@ref): The dispatch sentinel type
25+
- [`CommonSolve.solve`](@ref): The entry point that dispatches here
26+
"""
27+
function _solve(
28+
::DescriptiveMode,
29+
ocp::CTModels.AbstractModel,
30+
description::Symbol...;
31+
initial_guess::CTModels.AbstractInitialGuess,
32+
display::Bool,
33+
registry::CTSolvers.Strategies.StrategyRegistry,
34+
kwargs...
35+
)::CTModels.AbstractSolution
36+
37+
throw(CTBase.NotImplemented(
38+
"Descriptive mode is not yet implemented",
39+
suggestion="Use explicit mode: solve(ocp; discretizer=..., modeler=..., solver=...)",
40+
context="_solve(::DescriptiveMode, ...)"
41+
))
42+
end
Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using CTBase
2-
31
"""
42
$(TYPEDSIGNATURES)
53
@@ -53,47 +51,4 @@ function _solve(
5351
components.solver;
5452
display=display
5553
)
56-
end
57-
58-
"""
59-
$(TYPEDSIGNATURES)
60-
61-
Stub for descriptive mode resolution.
62-
63-
Raises [`CTBase.NotImplemented`](@ref) until `solve_descriptive` is implemented.
64-
This stub allows testing the orchestration layer (mode detection, dispatch routing)
65-
before the descriptive mode handler exists.
66-
67-
The `description` vararg will be forwarded to `solve_descriptive` when implemented.
68-
69-
# Arguments
70-
- `ocp`: The optimal control problem to solve
71-
- `description`: Symbolic description tokens (e.g., `:collocation`, `:adnlp`, `:ipopt`)
72-
- `initial_guess`: Normalized initial guess (processed by Layer 1)
73-
- `display`: Whether to display configuration information
74-
- `registry`: Strategy registry
75-
- `kwargs...`: Strategy-specific options
76-
77-
# Throws
78-
- `CTBase.NotImplemented`: Always — descriptive mode is not yet implemented
79-
80-
# See Also
81-
- [`DescriptiveMode`](@ref): The dispatch sentinel type
82-
- [`CommonSolve.solve`](@ref): The entry point that dispatches here
83-
"""
84-
function _solve(
85-
::DescriptiveMode,
86-
ocp::CTModels.AbstractModel,
87-
description::Symbol...;
88-
initial_guess::CTModels.AbstractInitialGuess,
89-
display::Bool,
90-
registry::CTSolvers.Strategies.StrategyRegistry,
91-
kwargs...
92-
)::CTModels.AbstractSolution
93-
94-
throw(CTBase.NotImplemented(
95-
"Descriptive mode is not yet implemented",
96-
suggestion="Use explicit mode: solve(ocp; discretizer=..., modeler=..., solver=...)",
97-
context="_solve(::DescriptiveMode, ...)"
98-
))
99-
end
54+
end

src/solve/solve_explicit.jl

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)