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
docs: improve bypass documentation and fix GPU examples
- Reorganize explicit mode docs to emphasize bypass/force as primary method
- Relegate permissive mode to brief info note (rarely used)
- Fix GPU documentation examples to use OptimalControl prefixes
- Remove unnecessary Draft meta blocks
- Update introspection examples to use correct option names
This manual explains the **explicit mode** of the [`solve`](@ref) function, where you pass typed strategy instances directly instead of symbolic tokens. This gives you full control over component configuration and validation.
8
4
9
5
For basic usage with symbolic tokens, see [Solve a problem](@ref manual-solve).
@@ -15,7 +11,6 @@ In explicit mode, you create strategy instances with their options, then pass th
@@ -122,19 +117,19 @@ All options are passed when creating the strategy instance:
122
117
123
118
```@example explicit
124
119
# Configure Collocation
125
-
disc = Collocation(
120
+
disc = OptimalControl.Collocation(
126
121
grid_size=150,
127
122
scheme=:gauss_legendre_2
128
123
)
129
124
130
125
# Configure ADNLP
131
-
mod = ADNLP(
126
+
mod = OptimalControl.ADNLP(
132
127
backend=:optimized,
133
128
show_time=true
134
129
)
135
130
136
131
# Configure Ipopt
137
-
sol = Ipopt(
132
+
sol = OptimalControl.Ipopt(
138
133
max_iter=1000,
139
134
tol=1e-8,
140
135
print_level=5,
@@ -143,30 +138,39 @@ sol = Ipopt(
143
138
nothing # hide
144
139
```
145
140
146
-
### Validation modes
141
+
### Passing undeclared options
147
142
148
-
Strategies support two validation modes:
143
+
By default, strategies use **strict validation**: any option not declared in the strategy metadata raises an error. This prevents typos and ensures you're using valid options.
149
144
150
-
-**`:strict`** (default): Rejects unknown options with a detailed error message
151
-
-**`:permissive`**: Accepts unknown options with a warning, stores them with `:user` source
145
+
However, NLP solvers have many options, and not all of them are declared in OptimalControl's strategy metadata. For example, Ipopt has an option `mumps_print_level` for controlling MUMPS debug output, which is not in the Ipopt strategy metadata.
152
146
153
-
```@example explicit
154
-
# Strict mode (default) - will error on unknown options
To pass undeclared options, use `bypass()` (or its alias `force()`):
156
148
157
-
# Permissive mode - accepts unknown options
158
-
solver_permissive = Ipopt(
149
+
```@example explicit
150
+
# Bypass validation for mumps_print_level
151
+
solver = OptimalControl.Ipopt(
159
152
max_iter=500,
160
153
print_level=0,
161
-
custom_option=42; # Unknown option
162
-
mode=:permissive
154
+
mumps_print_level=bypass(1) # Undeclared option
163
155
)
164
156
nothing # hide
165
157
```
166
158
167
-
!!! warning "Permissive mode"
159
+
!!! note "Alias: force = bypass"
160
+
You can use `force` as an alias for `bypass`: `mumps_print_level=force(1)`
161
+
162
+
!!! warning "Use bypass sparingly"
168
163
169
-
Use `:permissive` mode only when you need to pass options that aren't declared in the strategy metadata (e.g., experimental solver options). The option will be passed to the underlying solver without validation.
164
+
The `bypass` mechanism skips validation for the wrapped option. Use it only when:
165
+
166
+
- You need to pass an option to the underlying solver that isn't declared in the strategy metadata
167
+
- You're certain the option name and value are correct
168
+
169
+
Bypassed options are passed directly to the solver without type checking or validation.
170
+
171
+
!!! info "Alternative: permissive mode"
172
+
173
+
If you have many undeclared options, you can use `mode=:permissive` to disable validation globally. However, this is not recommended as it will also ignore typos in valid option names.
170
174
171
175
### No routing needed
172
176
@@ -178,85 +182,23 @@ In explicit mode, there's no option routing or ambiguity:
178
182
179
183
```@example explicit
180
184
# Each component gets its own options directly
181
-
disc = Collocation(grid_size=100)
182
-
sol = Ipopt(max_iter=500, tol=1e-6, print_level=0)
185
+
disc = OptimalControl.Collocation(grid_size=100)
186
+
sol = OptimalControl.Ipopt(max_iter=500, tol=1e-6, print_level=0)
183
187
184
188
result = solve(ocp; discretizer=disc, solver=sol, display=false)
185
189
nothing # hide
186
190
```
187
191
188
-
## When to use explicit mode
189
-
190
-
Explicit mode is useful when you:
191
-
192
-
1.**Pre-configure and reuse components** across multiple solves:
0 commit comments