Private API

This page lists non-exported (internal) symbols of CTSolvers.Strategies.


From CTSolvers.Strategies

_describe_metadata

CTSolvers.Strategies._describe_metadataFunction

Display metadata for strategy types, handling multiple parameters and extensions.

For strategies with multiple parameters, groups options into:

  • Common options (default source, same across parameters)
  • Computed options (per-parameter, shown separately)

_describe_multi_param_metadata

_describe_parameter_registry

_describe_single_metadata

_describe_strategy_registry

_error_unknown_options_strict

CTSolvers.Strategies._error_unknown_options_strictFunction
_error_unknown_options_strict(
    remaining::NamedTuple,
    strategy_type::Type{<:CTSolvers.Strategies.AbstractStrategy},
    meta::CTSolvers.Strategies.StrategyMetadata
)

Throw an error for unknown options in strict mode.

This function generates a detailed error message that includes:

  • List of unrecognized options
  • Available options from metadata
  • Suggestions based on Levenshtein distance
  • Guidance on using permissive mode

Arguments

  • remaining::NamedTuple: Unknown options provided by user
  • strategy_type::Type{<:AbstractStrategy}: Strategy type being configured
  • meta::StrategyMetadata: Strategy metadata with option definitions

Throws

  • Exceptions.IncorrectArgument: Always throws with detailed error message

Example

# Internal use only - called by build_strategy_options()
_error_unknown_options_strict((unknown_opt=123,), Solvers.Ipopt, meta)

See also: build_strategy_options, suggest_options

_find_strategies_using_parameter

CTSolvers.Strategies._find_strategies_using_parameterFunction

Find all strategies in the registry that use a specific parameter type.

Returns a vector of tuples: (strategyid, familytype, strategy_type)

Arguments

  • param_type::Type{<:AbstractStrategyParameter}: The parameter type to search for
  • registry::StrategyRegistry: The registry to search in

Returns

  • Vector{Tuple{Symbol, Type, Type}}: List of (strategyid, family, strategytype) tuples

_find_strategy_in_registry

CTSolvers.Strategies._find_strategy_in_registryFunction

Find a strategy in the registry by its ID.

Returns (family_type, [matched_types...]) where matched_types are all strategy types with the given ID.

Throws IncorrectArgument if the ID is not found.

_strategy_id_set

CTSolvers.Strategies._strategy_id_setFunction
_strategy_id_set(
    registry::CTSolvers.Strategies.StrategyRegistry
) -> Set{Symbol}

Internal helper returning the set of all registered strategy IDs.

This function is used by registry utilities that need to distinguish strategy tokens from other tokens that may appear in a method tuple (e.g. parameter tokens).

Arguments

  • registry::StrategyRegistry: Strategy registry.

Returns

  • Set{Symbol}: Set of all strategy IDs present in the registry.

Notes

  • This function is internal and not part of the public API.

_strategy_type_name

CTSolvers.Strategies._strategy_type_nameFunction
_strategy_type_name(T::DataType) -> String

Extract a clean type name from a DataType by removing module prefixes while preserving parameter structure.

This method handles both parameterized DataTypes (e.g., Exa{CPU}) and non-parameterized DataTypes (e.g., Collocation). For parameterized types, it removes module prefixes from both the base type and parameters while preserving the parameter structure.

Arguments

  • T::DataType: The DataType to format

Returns

  • String: Clean type name without module prefixes (e.g., "Exa{CPU}" or "Collocation")

Examples

julia> using CTSolvers.Strategies

julia> _strategy_type_name(CTSolvers.Modelers.Exa{CTSolvers.Strategies.CPU})
"Exa{CPU}"

julia> _strategy_type_name(Collocation)
"Collocation"

Notes

  • This is the most common case, handling concrete instantiated types
  • For parameterized types, each parameter is formatted recursively

See also: describe, _describe_parameter_registry

_strategy_type_name(T::UnionAll)

Extract a clean type name from a UnionAll type by removing module prefixes.

This method handles generic types that have not been fully instantiated, preserving the type parameter variable name.

Arguments

  • T::UnionAll: The UnionAll type to format

Returns

  • String: Clean type name with generic parameter (e.g., "Exa{P}" where P is the type variable)

Notes

  • This is a fallback for generic types that are not yet instantiated
  • Less common than the DataType method in typical usage

See also: _strategy_type_name(::DataType)

_strategy_type_name(T::Type) -> String

Extract a string representation from any other Type.

This is the most general fallback method for types that don't match more specific methods.

Arguments

  • T::Type: Any type that doesn't match other methods

Returns

  • String: String representation of the type

Notes

  • This is the ultimate fallback for edge cases
  • Simply converts the type to a string representation

See also: _strategy_type_name(::DataType), _strategy_type_name(::UnionAll)

_supertype_chain

CTSolvers.Strategies._supertype_chainFunction

Build a supertype chain from a type up to (and including) a stop type.

Returns a vector of types representing the inheritance chain.

Arguments

  • T::Type: Starting type
  • stop_at::Type: Type to stop at (inclusive)

Returns

  • Vector{Type}: Chain of types from T to stop_at

Example

chain = _supertype_chain(ADNLP{CPU}, AbstractStrategy)
# Returns: [ADNLP{CPU}, AbstractNLPModeler, AbstractStrategy]

_warn_unknown_options_permissive

CTSolvers.Strategies._warn_unknown_options_permissiveFunction
_warn_unknown_options_permissive(
    remaining::NamedTuple,
    strategy_type::Type{<:CTSolvers.Strategies.AbstractStrategy}
)

Warn about unknown options in permissive mode.

This function generates a warning message that informs the user that unvalidated options will be passed directly to the backend without validation.

Arguments

  • remaining::NamedTuple: Unknown options provided by user
  • strategy_type::Type{<:AbstractStrategy}: Strategy type being configured

Example

# Internal use only - called by build_strategy_options()
_warn_unknown_options_permissive((custom_opt=123,), Solvers.Ipopt)

See also: build_strategy_options, _error_unknown_options_strict

extract_global_parameter_from_method

CTSolvers.Strategies.extract_global_parameter_from_methodFunction
extract_global_parameter_from_method(
    method::Tuple{Vararg{Symbol}},
    registry::CTSolvers.Strategies.StrategyRegistry
) -> Union{Nothing, Type{<:CTSolvers.Strategies.AbstractStrategyParameter}}

Extract the global strategy parameter from a method tuple.

The method tuple may contain at most one parameter token (e.g. :cpu, :gpu). If present, it is resolved to a parameter type using registry.parameters.

If any of the selected strategies in the method are parameterized, then a parameter token is required and must be supported by each parameterized strategy.

Arguments

  • method::Tuple{Vararg{Symbol}}: Method tuple containing strategy IDs and optionally one parameter token.
  • registry::StrategyRegistry: Strategy registry.

Returns

  • Union{Nothing, Type{<:AbstractStrategyParameter}}: The extracted parameter type, or nothing if none is present.

Throws

  • Exceptions.IncorrectArgument: If more than one parameter token is present, if a parameter is missing but required, if a parameter is unsupported, or if a parameter token is provided but no selected strategy is parameterized.

See also: available_parameters, Strategies.AbstractStrategyParameter

levenshtein_distance

CTSolvers.Strategies.levenshtein_distanceFunction
levenshtein_distance(s1::String, s2::String) -> Int64

Compute the Levenshtein distance between two strings.

The Levenshtein distance is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into another.

Arguments

  • s1::String: First string
  • s2::String: Second string

Returns

  • Int: Levenshtein distance between the two strings

Example

julia> levenshtein_distance("kitten", "sitting")
3

julia> levenshtein_distance("max_iter", "max_it")
2

Algorithm

Uses dynamic programming with O(m*n) time and space complexity, where m and n are the lengths of the input strings.

See also: suggest_options