Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable #119

Closed
ocots opened this issue Oct 4, 2023 · 2 comments
Closed

Variable #119

ocots opened this issue Oct 4, 2023 · 2 comments
Assignees

Comments

@ocots
Copy link
Member

ocots commented Oct 4, 2023

This definition is not authorized:

α = 5
@def ocp begin
    t  [ 0, 1 ], time
    v  R, variable
    x  R², state
    u  R, control
    x(0) == [ -1, 0 ]
    x(1) == [ 0, v ]
    (t) == [ x₂(t), x₁(t) + α*x₁(t)^2 + u(t) ]
    v^2 + ( 0.5u(t)^2 )  min
end

Why?

Here is the error message:

Line 6: x(1) == [0, v]
UndefVarError: `v` not defined

Stacktrace:
 [1] macro expansion
   @ [~/.julia/packages/CTBase/rsUEs/src/onepass.jl:50](https://file+.vscode-resource.vscode-cdn.net/Users/ocots/Boulot/recherche/logiciels/dev/control-toolbox/OptimalControl/docs/src/~/.julia/packages/CTBase/rsUEs/src/onepass.jl:50) [inlined]
 [2] top-level scope
   @ [~/Boulot/recherche/logiciels/dev/control-toolbox/OptimalControl/docs/src/init.ipynb:8](https://file+.vscode-resource.vscode-cdn.net/Users/ocots/Boulot/recherche/logiciels/dev/control-toolbox/OptimalControl/docs/src/~/Boulot/recherche/logiciels/dev/control-toolbox/OptimalControl/docs/src/init.ipynb:8)
@jbcaillau
Copy link
Member

et oui, hi hi 🫢

@jbcaillau
Copy link
Member

jbcaillau commented Oct 5, 2023

@ocots Right-hand sides or, more generally, lower and upper values of box contraints, must be evaluable by Julia (must not contain variables, etc.) So this problem should be defined according to:

α = 5
@def ocp begin
    t  [ 0, 1 ], time
    v  R, variable
    x  R², state
    u  R, control
    x(0) == [ -1, 0 ]
    x(1) - [ 0, v ] == [ 0, 0 ]
    (t) == [ x₂(t), x₁(t) + α*x₁(t)^2 + u(t) ]
    v^2 + ( 0.5u(t)^2 )  min
end

See also

This issue

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

No branches or pull requests

2 participants