Add rich show methods for all problem components#54
Merged
aarontrowbridge merged 5 commits intomainfrom Feb 24, 2026
Merged
Conversation
Add informative Base.show methods to objectives, constraints, integrators, and DirectTrajOptProblem. The new display shows trajectory details (dims, variables, controls), weighted objective breakdown, dynamics integrators, and constraint summary grouped by type. A shared show_problem_details helper is exported for use by downstream packages (e.g. Piccolo.jl). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances the display output for trajectory optimization problems by adding informative Base.show methods to all problem components. The changes transform the minimal problem display into a hierarchical, readable summary that shows trajectory details, weighted objectives, dynamics integrators, and grouped constraints.
Changes:
- Added
Base.showmethods for all objectives (8 types), constraints (10 types), and integrators (3 types) - Replaced minimal
DirectTrajOptProblemdisplay with comprehensive hierarchical view - Exported
show_problem_detailshelper for downstream package reuse (e.g., Piccolo.jl)
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/problems.jl | Added show_problem_details function with hierarchical display of trajectory, objectives, dynamics, and constraints; exported for downstream use |
| src/objectives/regularizers.jl | Added show methods for QuadraticRegularizer and LinearRegularizer with R values and time coverage |
| src/objectives/minimum_time_objective.jl | Added show method for MinimumTimeObjective displaying D parameter |
| src/objectives/knot_point_objectives.jl | Added show method for KnotPointObjective displaying variables and time points |
| src/objectives/global_objectives.jl | Added show methods for GlobalObjective and GlobalKnotPointObjective with global variable info |
| src/objectives/_objectives.jl | Enhanced CompositeObjective show method to display all terms with weights; added NullObjective show method |
| src/integrators/bilinear_integrator.jl | Added show method displaying integration formula and dimension |
| src/integrators/derivative_integrator.jl | Added show method displaying derivative integration formula |
| src/integrators/time_dependent_bilinear_integrator.jl | Added show method with time-dependent formula and spline order |
| src/constraints/nonlinear/knot_point_constraint.jl | Added show method displaying variables, equality/inequality type, and times |
| src/constraints/nonlinear/global_knot_point_constraint.jl | Added show method for global knot point constraints |
| src/constraints/nonlinear/global_constraint.jl | Added show method for global constraints |
| src/constraints/linear/total_constraint.jl | Added show method displaying constraint label |
| src/constraints/linear/time_consistency_constraint.jl | Added show method with consistency formula |
| src/constraints/linear/symmetry_constraint.jl | Added show method displaying symmetry type and components |
| src/constraints/linear/l1_slack_constraint.jl | Added show method with L1 constraint formula |
| src/constraints/linear/equality_constraint.jl | Added show method displaying constraint label |
| src/constraints/linear/bounds_constraint.jl | Added show method displaying constraint label |
| src/constraints/linear/all_equal_constraint.jl | Added show method displaying constraint label |
Comments suppressed due to low confidence (2)
src/objectives/regularizers.jl:69
- The logic for determining "all" times may be misleading when times is a contiguous range starting from 1 but doesn't cover all trajectory timesteps. For example, if
times = [1, 2, 3]on a trajectory with 100 timesteps, this would display "all" instead of "3 times". Consider checking iftimesequals the full range1:traj.N, but this requires storing a reference to the trajectory size or revising the display logic to be more conservative (e.g., only show "all" if times appears to be the default1:nrange and add a comment noting this limitation).
times_str = (!isempty(reg.times) && first(reg.times) == 1 && last(reg.times) == n) ? "all" : "$n times"
src/objectives/regularizers.jl:226
- Same issue as in QuadraticRegularizer: the logic for determining "all" times may be misleading when times is a contiguous range starting from 1 but doesn't cover all trajectory timesteps. Consider using the same fix applied to QuadraticRegularizer for consistency.
times_str = (!isempty(reg.times) && first(reg.times) == 1 && last(reg.times) == n) ? "all" : "$n times"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Updated README.md to reflect stable documentation link and improved descriptions of features and installation instructions. - Revised problem formulation documentation to use consistent notation for state and control variables. - Enhanced example scripts with additional outputs for better understanding of problem setup and solutions. - Removed outdated explanation.jl file and consolidated relevant content into other documentation sections. - Improved clarity in tutorials by adding comments and restructuring content for better readability. - Added detailed docstrings for integrators and constraints to enhance code documentation. - Updated solver options documentation to provide clearer descriptions and examples for users.
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.
Summary
Base.showmethods to all objectives (QuadraticRegularizer, LinearRegularizer, KnotPointObjective, MinimumTimeObjective, GlobalObjective, GlobalKnotPointObjective, CompositeObjective, NullObjective), constraints (EqualityConstraint, BoundsConstraint, TimeConsistencyConstraint, L1SlackConstraint, SymmetryConstraint, AllEqualConstraint, TotalConstraint, NonlinearKnotPointConstraint, NonlinearGlobalConstraint, NonlinearGlobalKnotPointConstraint), and integrators (BilinearIntegrator, DerivativeIntegrator, TimeDependentBilinearIntegrator)DirectTrajOptProblemdisplay with a hierarchical view showing trajectory details, weighted objective breakdown, dynamics integrators, and constraint summary grouped by typeshow_problem_detailshelper for use by downstream packages (e.g. Piccolo.jl'sQuantumControlProblem)Example output
Test plan
🤖 Generated with Claude Code