control-toolbox / control-toolbox/CTParser.jl

`@def name … end true` (trace mode) prints the parsed model twice

Open
#344 1 comment 0 reactions 1 assignee Claimed by @jbcaillau View on GitHub
bug
Dominant language
Julia
Stars
3
Forks
0
Avg merge
4h 22m
Merged PRs (30d)
2

Description

## Context

Found while making OptimalControl's `docs/src/modelling/abstract-syntax.md` executable
(control-toolbox/OptimalControl.jl#913). The page has a `!!! hint` block demonstrating
trace mode; once executed, its output shows the parsed model **twice**.

## Reproduce

```julia
using OptimalControl # CTParser 0.9.4-beta, CTBase 0.30.2-beta, CTModels 0.19.2-beta

c(t) = 1.0

@def damped_integrator begin
tf ∈ R, variable
t ∈ [0, tf], time
x = (q, v) ∈ R², state
u ∈ R, control
q̇ = v(t)
v̇ = u(t) - c(t)
ẋ(t) == [q̇, v̇]
∫(u(t)^2) → min
end true
```

Output (abridged — the whole block is printed twice, identical apart from gensym numbers):

```
variable: tf, dim: 1
time: t, initial time: 0, final time: var"tf##4005"[1]
state: x, dim: 2
control: u, dim: 1
alias: q̇ = (x[2])(t)
alias: v̇ = (var"u##4006"[1])(t) - c(t)
dynamics: ∂(x)(t) == [(x[2])(t), (var"u##4006"[1])(t) - c(t)]
objective (Lagrange): ∫((var"u##4006"[1])(t) ^ 2) → min
variable: tf, dim: 1
time: t, initial time: 0, final time: var"tf##4025"[1]
state: x, dim: 2
control: u, dim: 1
alias: q̇ = (x[2])(t)
alias: v̇ = (var"u##4029"[1])(t) - c(t)
dynamics: ∂(x)(t) == [(x[2])(t), (var"u##4029"[1])(t) - c(t)]
objective (Lagrange): ∫((var"u##4029"[1])(t) ^ 2) → min
```

## Expected

The trace is printed once.

## Impact

Cosmetic, but noisy in the docs and in interactive use — a reader could think the double
output signals a problem with their definition.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.