Repository navigation
docs(initial-guess): check a guess with build_initial_guess; keep the other Init helpers unexported - #980
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #965.
Decision: re-export none of the other initial-guess helpers
build_initial_guessstays the only CTModels initial-guess function exported by OptimalControl.initial_guess,pre_initial_guess,validate_initial_guess,initial_state,initial_control,initial_variableandPreInitialGuessstay unexported. Reasons, helper by helper:validate_initial_guess(ocp, ig)InitialGuessbuild_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)@initand by the named tuple(state=…, control=…, variable=…)given tobuild_initial_guess/solve, both validated. Also, the name equals thesolvekeywordinitial_guess: an exported function of that name would invite confusion withinitial_guess = …in user scripts.pre_initial_guess,PreInitialGuessinitial_state,initial_control,initial_variableinitial_guessinitial_statereads as "x(t₀)" for a user, which it is not. Inspection is covered bystate(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
build_initial_guessraises anIncorrectArgumenton 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/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.[Unreleased].Checks
suite/reexport/test_ctmodels.jl: 325/325 passing.build_initial_guess(ocp2, (state=[-1.0, 0.0, 0.0],))raisesIncorrectArgument: Initial state dimension mismatch (got vector of length 3, expected 2).🤖 Generated with Claude Code