Skip to content

Options aliases#105

Merged
ocots merged 2 commits intomainfrom
options-aliases
Mar 17, 2026
Merged

Options aliases#105
ocots merged 2 commits intomainfrom
options-aliases

Conversation

@ocots
Copy link
Copy Markdown
Member

@ocots ocots commented Mar 17, 2026

Summary

This PR adds cross-solver option aliases to enable interchangeable option names across all 5 solvers (Ipopt, Knitro, MadNCL, MadNLP, Uno). Users can now use any solver's option names with any other solver, making the API more consistent and user-friendly.

Features

Cross-Solver Aliases Added

Maximum iterations - All 5 solvers now support:

  • :max_iter (canonical in Ipopt, MadNCL, MadNLP)
  • :maxit (canonical in Knitro) ← NEW
  • :maxiter, :max_iterations (existing aliases)

Maximum wall time - All 5 solvers now support:

  • :max_wall_time (canonical in Ipopt, MadNCL, MadNLP)
  • :maxtime (canonical in Knitro) ← NEW
  • :max_time (existing alias in MadNCL/MadNLP) ← NEW
  • :time_limit (canonical in Uno) ← NEW

Acceptable tolerance - 3 solvers now support:

  • :acceptable_tol (canonical in Ipopt, MadNCL, MadNLP)
  • :acc_tol (existing alias in MadNCL/MadNLP) ← NEW for Ipopt

Implementation

  • StrategyOptions: Added alias_map field for O(1) alias resolution
  • build_strategy_options: Constructs alias map from strategy metadata
  • Access methods: getindex, haskey, option now resolve aliases automatically
  • Preservation: Aliases remain accessible after solver construction

Examples

# Before: Different names per solver
ipopt = Solvers.Ipopt(max_iter=500, max_wall_time=3600.0)
knitro = Solvers.Knitro(maxit=500, maxtime=3600.0)  
uno = Solvers.Uno(max_iterations=500, time_limit=3600.0)

# After: Any names work with any solver
ipopt = Solvers.Ipopt(maxit=500, maxtime=3600.0)  # Knitro names with Ipopt
knitro = Solvers.Knitro(max_iter=500, max_wall_time=3600.0)  # Ipopt names with Knitro
uno = Solvers.Uno(maxit=500, max_wall_time=3600.0)  # Mixed names with Uno

# Access via any alias after construction
opts = ipopt.options
opts[:maxit]        # ✅ 500 (Knitro name)
opts[:maxtime]      # ✅ 3600.0 (Knitro name)  
opts[:time_limit]   # ✅ 3600.0 (Uno name)

- Add aliases for max_iter, max_wall_time, acceptable_tol across all solvers
- Implement alias preservation in StrategyOptions with alias_map
- Add comprehensive tests for alias resolution
- Enable interchangeable option names between solvers

Cross-solver aliases added:
- max_iter: maxit, maxiter, max_iterations
- max_wall_time: maxtime, max_time, time_limit
- acceptable_tol: acc_tol

Modified files:
- ext/CTSolversIpopt.jl: Add maxit, time aliases, acc_tol
- ext/CTSolversKnitro.jl: Add wall time aliases
- ext/CTSolversMadNCL.jl: Add maxit, time aliases
- ext/CTSolversMadNLP.jl: Add maxit, time aliases
- ext/CTSolversUno.jl: Add maxit, time aliases
- src/Strategies/contract/strategy_options.jl: Add alias_map field and resolution
- src/Strategies/api/configuration.jl: Build alias_map from metadata
- test/suite/strategies/test_strategy_options.jl: Add alias resolution tests
- test/suite/strategies/test_alias_integration.jl: New cross-solver tests
- test
- Add aliases for max_iter, max_wall_time, acceptaAdd- Implement alias preservation in StrategyOptions with alias_map
- Add comppt- Add comprehensive tests for alias resolution
@ocots ocots merged commit 7659711 into main Mar 17, 2026
7 checks passed
@ocots ocots deleted the options-aliases branch March 17, 2026 10:26
@ocots ocots mentioned this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant