Skip to content

[Dev] v1.1 #532

Open
Open
@jbcaillau

Description

@jbcaillau

@ocots @PierreMartinon @gergaud some refactoring after adding new discretisation towards ExaModels (runs on GPU)

  • keep track of the original expression (= Julia source code captured by @def) at all levels
  • having the info allows enhanced actions (for solving, plotting...) - this is already what is done in CTModels, CTDirect, CTFlows
  • parsing (syntactic + semantic) by @def creates an OptimalControl.Model that gives access to the standard getters (on state dim, dynamics, objective, etc.)
  • essentially 4 actions : discretise, flow, solve, plot; some can be called at different steps (e.g. solve just after @def, or after discretise, or after flow...); see use cases below
  • should be not breaking wrt. what is currently implemented in v1.0 (*)

(*) @PierreMartinon may be one suggested change: when discretising towards an nlp, rather than a model (ADNLP...) generate a function parametrised by grid_size, scheme, init... that, when evaluated, returns such a model (see use case no. 3 below; see also https://github.com/control-toolbox/CTParser.jl/blob/6bdf969c1140ea1497b305901218cd2eb7f6bfe6/src/onepass.jl#L1026) this allows in particular to have a PRAGMA in the generated (see naive example here) and is in line with what is often done in practice. to be discussed

# use case no.1

ocp = @def e
sol = solve(ocp)
plot(sol)

# use case no. 2

ocp = @def e
dx = dynamics(ocp)(t, x, u, v)
docp = discretise(ocp)
sol = solve(docp)
plot(sol)

# use case no. 3

ocp = @def e
docp = discretise(ocp; model = :exa)
nlp = docp(; grid_size = 200)
sol = madnlp(nlp)

# use case no. 4

ocp = @def e
f = flow(ocp, u)
sol = f((t0, tf), x0, p0)
plot(sol)

Metadata

Metadata

Assignees

Labels

internal devModification to the code is requested and should not affect user experiment

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions