Skip to content

docs(initial-guess): check a guess with build_initial_guess; keep the other Init helpers unexported - #980

Merged
ocots merged 3 commits into
mainfrom
965-initial-guess-helpers
Oct 13, 2026
Merged

ocots merged 3 commits into
mainfrom
965-initial-guess-helpers

Conversation

@ocots

@ocots ocots commented Oct 13, 2026

Copy link
Copy Markdown
Member

Closes #965.

Decision: re-export none of the other initial-guess helpers

build_initial_guess stays the only CTModels initial-guess function exported by OptimalControl. initial_guess, pre_initial_guess, validate_initial_guess, initial_state, initial_control, initial_variable and PreInitialGuess stay unexported. Reasons, helper by helper:

Helper What it does Why not exported
validate_initial_guess(ocp, ig) checks dimensions of an InitialGuess build_initial_guess(ocp, data) already validates: it is "the single entry point that guarantees a validated initial guess" (its docstring). Checking a guess before solving = building it. A second name for the same check adds surface, not capability.
initial_guess(ocp; state, control, variable) builds an unvalidated guess covered by @init and by the named tuple (state=…, control=…, variable=…) given to build_initial_guess / solve, both validated. Also, the name equals the solve keyword initial_guess: an exported function of that name would invite confusion with initial_guess = … in user scripts.
pre_initial_guess, PreInitialGuess an internal intermediate before dimensions are known no use case a named tuple does not cover.
initial_state, initial_control, initial_variable per-component builders used by initial_guess implementation details. initial_state reads as "x(t₀)" for a user, which it is not. Inspection is covered by state(ig), control(ig), variable(ig).

Users who still want one of them can call it qualified (CTModels.Init.validate_initial_guess): nothing is hidden, only not exported.

Changes

  • Docs, page "Initial guess": the section "Inspect a guess" becomes "Inspect or check a guess". It now shows that build_initial_guess raises an IncorrectArgument on a component of the wrong dimension, so it is the way to check a guess before solving. The example is executed and checked by a hidden @assert.
  • Test, test/suite/reexport/test_ctmodels.jl: the seven names are asserted not exported. The decision is then recorded in the suite, and a future re-export has to update this test on purpose.
  • CHANGELOG entry under [Unreleased].

Checks

  • suite/reexport/test_ctmodels.jl: 325/325 passing.
  • The doc example, run by hand: build_initial_guess(ocp2, (state=[-1.0, 0.0, 0.0],)) raises IncorrectArgument: Initial state dimension mismatch (got vector of length 3, expected 2).
  • Docs build not run locally.

🤖 Generated with Claude Code

ocots and others added 2 commits October 13, 2026 15:42
…t the other Init helpers stay unexported (#965)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ocots
ocots merged commit d19b9a1 into main Oct 13, 2026
6 checks passed
@ocots
ocots deleted the 965-initial-guess-helpers branch October 13, 2026 14:20
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.

Decide which CTModels initial-guess helpers OptimalControl re-exports

1 participant