|
17 | 17 | # Action option defaults (single source of truth) |
18 | 18 | # ---------------------------------------------------------------------------- |
19 | 19 |
|
| 20 | +""" |
| 21 | + _DEFAULT_DISPLAY::Bool |
| 22 | +
|
| 23 | +Default value for the `display` action option in solve functions. |
| 24 | +
|
| 25 | +When `true`, the solve configuration and method information will be displayed |
| 26 | +to the user during the solving process. |
| 27 | +
|
| 28 | +# Value |
| 29 | +- `true`: Display solve configuration (default) |
| 30 | +- `false`: Suppress configuration display |
| 31 | +
|
| 32 | +See also: [`_route_descriptive_options`](@ref), [`solve`](@ref) |
| 33 | +""" |
20 | 34 | const _DEFAULT_DISPLAY::Bool = true |
| 35 | + |
| 36 | +""" |
| 37 | + _DEFAULT_INITIAL_GUESS::Nothing |
| 38 | +
|
| 39 | +Default value for the `initial_guess` action option in solve functions. |
| 40 | +
|
| 41 | +When `nothing`, no initial guess is provided and the solver will use its |
| 42 | +default initialization strategy. |
| 43 | +
|
| 44 | +# Value |
| 45 | +- `nothing`: No initial guess provided (default) |
| 46 | +
|
| 47 | +See also: [`_route_descriptive_options`](@ref), [`solve`](@ref) |
| 48 | +""" |
21 | 49 | const _DEFAULT_INITIAL_GUESS::Nothing = nothing |
22 | 50 |
|
23 | 51 | # Aliases for initial_guess (single source of truth) |
24 | 52 | # _INITIAL_GUESS_ALIASES_ONLY : used in OptionDefinition (name is separate) |
25 | 53 | # _INITIAL_GUESS_ALIASES : used in _extract_action_kwarg (includes primary name) |
| 54 | + |
| 55 | +""" |
| 56 | + _INITIAL_GUESS_ALIASES_ONLY::Tuple{Symbol} |
| 57 | +
|
| 58 | +Aliases for the `initial_guess` parameter, excluding the primary name. |
| 59 | +
|
| 60 | +Used in `CTSolvers.OptionDefinition` where the primary name is specified separately. |
| 61 | +
|
| 62 | +# Value |
| 63 | +- `(:init,)`: Alias for `initial_guess` |
| 64 | +
|
| 65 | +See also: [`_INITIAL_GUESS_ALIASES`](@ref), [`_route_descriptive_options`](@ref) |
| 66 | +""" |
26 | 67 | const _INITIAL_GUESS_ALIASES_ONLY::Tuple{Symbol} = (:init,) |
| 68 | + |
| 69 | +""" |
| 70 | + _INITIAL_GUESS_ALIASES::Tuple{Symbol, Symbol} |
| 71 | +
|
| 72 | +All valid names for the initial guess parameter, including the primary name and aliases. |
| 73 | +
|
| 74 | +Used in `_extract_action_kwarg` to extract the initial guess from keyword arguments. |
| 75 | +
|
| 76 | +# Value |
| 77 | +- `(:initial_guess, :init)`: Primary name and alias |
| 78 | +
|
| 79 | +See also: [`_INITIAL_GUESS_ALIASES_ONLY`](@ref), [`_extract_action_kwarg`](@ref) |
| 80 | +""" |
27 | 81 | const _INITIAL_GUESS_ALIASES::Tuple{Symbol, Symbol} = (:initial_guess, :init) |
28 | 82 |
|
29 | 83 | # Unwrap an OptionValue (from route_all_options) to its raw value. |
30 | 84 | # Falls back to `fallback` if `opt` is not an OptionValue. |
| 85 | + |
| 86 | +""" |
| 87 | + _unwrap_option(opt, fallback) |
| 88 | +
|
| 89 | +Unwrap an `CTSolvers.OptionValue` to its raw value, with fallback support. |
| 90 | +
|
| 91 | +If `opt` is an `OptionValue`, returns `opt.value`. Otherwise, returns `opt` if it's not `nothing`, |
| 92 | +or `fallback` if `opt` is `nothing`. |
| 93 | +
|
| 94 | +# Arguments |
| 95 | +- `opt`: Either an `CTSolvers.OptionValue` or a raw value |
| 96 | +- `fallback`: Default value to use when `opt` is `nothing` |
| 97 | +
|
| 98 | +# Returns |
| 99 | +- The unwrapped value or the fallback |
| 100 | +
|
| 101 | +# Example |
| 102 | +```julia |
| 103 | +julia> opt_val = CTSolvers.OptionValue(42, :user) |
| 104 | +OptionValue(42, :user) |
| 105 | +
|
| 106 | +julia> _unwrap_option(opt_val, 0) |
| 107 | +42 |
| 108 | +
|
| 109 | +julia> _unwrap_option(nothing, 0) |
| 110 | +0 |
| 111 | +``` |
| 112 | +
|
| 113 | +See also: [`_route_descriptive_options`](@ref), [`CTSolvers.OptionValue`](@ref) |
| 114 | +""" |
31 | 115 | _unwrap_option(opt::CTSolvers.OptionValue, fallback) = opt.value |
32 | 116 | _unwrap_option(opt, fallback) = opt === nothing ? fallback : opt |
33 | 117 |
|
|
0 commit comments