Skip to content

Add rich show methods for all problem components#54

Merged
aarontrowbridge merged 5 commits intomainfrom
feature/improved-show-methods
Feb 24, 2026
Merged

Add rich show methods for all problem components#54
aarontrowbridge merged 5 commits intomainfrom
feature/improved-show-methods

Conversation

@aarontrowbridge
Copy link
Copy Markdown
Member

Summary

  • Add informative Base.show methods 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)
  • Replace the minimal DirectTrajOptProblem display with a hierarchical view showing trajectory details, weighted objective breakdown, dynamics integrators, and constraint summary grouped by type
  • Export show_problem_details helper for use by downstream packages (e.g. Piccolo.jl's QuantumControlProblem)

Example output

DirectTrajOptProblem
  Trajectory
    Timesteps: 51
    Duration:  10.0
    Knot dim:  14
    Variables: Ũ⃗ (8), u (2), du (2), ddu (2), Δt (1), t (1)
    Controls:  u, du, ddu, Δt
  Objective (4 terms)
       100.0 * KnotPointObjective on [:Ũ⃗] at t = [51]
        0.01 * QuadraticRegularizer on :u (R = [0.01, 0.01], all)
        0.01 * QuadraticRegularizer on :du (R = [0.01, 0.01], all)
        0.01 * QuadraticRegularizer on :ddu (R = [0.01, 0.01], all)
  Dynamics (3 integrators)
    BilinearIntegrator: :Ũ⃗ = exp(Δt G(:u)) :Ũ⃗  (dim = 8)
    DerivativeIntegrator: :u += Δt * :du  (dim = 2)
    DerivativeIntegrator: :du += Δt * :ddu  (dim = 2)
  Constraints (8 total: 2 equality, 4 bounds, 1 time consistency, 1 other)
    EqualityConstraint: "initial value of Ũ⃗"
    BoundsConstraint: "bounds on u"
    BoundsConstraint: "bounds on ddu"
    BoundsConstraint: "bounds on Δt"
    TimeConsistencyConstraint: t_{k+1} = t_k + Δt_k
    ...

Test plan

  • Run existing test suite to verify no regressions
  • Create a problem in REPL and verify display output

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.show methods for all objectives (8 types), constraints (10 types), and integrators (3 types)
  • Replaced minimal DirectTrajOptProblem display with comprehensive hierarchical view
  • Exported show_problem_details helper 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 if times equals the full range 1: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 default 1:n range 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.

github-actions Bot and others added 4 commits February 19, 2026 15:01
- 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.
@aarontrowbridge aarontrowbridge merged commit 780139f into main Feb 24, 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.

3 participants