control-toolbox / control-toolbox/LossControl.jl

[Dev] First parsing

Open
#36 1 comment 0 reactions 2 assignees Claimed by @ocots View on GitHub
internal dev
Dominant language
Julia
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

@AnasXbouali This idea is to convert this

```julia
ocp = @loss_def begin

t ∈ [ 0, tf ], time
x ∈ R^2, state
u ∈ R, control

0.5 ≤ x₂(t) ≤ 3.5, loss_region

x₁(0) == 0
x₂(0) == 0
x₂(tf) == 4

-π/2 ≤ u(t) ≤ π/2

∂x₁ = x₂(t) + cos(u(t))
∂x₂ = sin(u(t))

ẋ(t) == [ ∂x₁, ∂x₂ ]

-x₁(tf) → min

end
```

to

```julia
ocp = @loss_def begin

t ∈ [ 0, tf ], time
x ∈ R^2, state
u ∈ R, control

x₁(0) == 0
x₂(0) == 0
x₂(tf) == 4

-π/2 ≤ u(t) ≤ π/2

∂x₁ = x₂(t) + cos(u(t))
∂x₂ = sin(u(t))

ẋ(t) == [ ∂x₁, ∂x₂ ]

-x₁(tf) → min

end
```

and then, to parse it with `@def` from `CTBase.jl`.

- Remove all the lines with `loss_region` tag.
- Parse the new expression with `@def`.

>[!WARNING]
> It is important to add some unit tests [here](https://github.com/control-toolbox/LossControl.jl/tree/main/test).

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.