Skip to content

Commit

Permalink
Merge pull request #148 from control-toolbox/prefixmodel
Browse files Browse the repository at this point in the history
foo
  • Loading branch information
ocots authored Jun 10, 2024
2 parents f594793 + d1ba101 commit f6c3284
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/CTBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export BoundaryConstraint, StateConstraint, ControlConstraint, MixedConstraint,
# model
export OptimalControlModel
export Model
export __OCPModel # redirection to Model to avoir confusion with other Model functions from other packages. Due to @def macro
export variable!, time!, constraint!, dynamics!, objective!, state!, control!, remove_constraint!, constraint
export is_time_independent, is_time_dependent, is_min, is_max, is_variable_dependent, is_variable_independent
export nlp_constraints, constraints_labels
Expand Down
13 changes: 9 additions & 4 deletions src/onepass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ p_bolza!(p, ocp, e1, e2, type; log=false) = begin
end, p.lnum, p.line)
end

# redirection to Model() to avoid confusion with other functions Model from other packages
function __OCPModel(args...; kwargs...)
return CTBase.Model(args...; kwargs...)
end

"""
$(TYPEDSIGNATURES)
Expand Down Expand Up @@ -464,10 +469,10 @@ macro def(ocp, e, log=false)
p = ParsingInfo(); p.t_dep = p0.t_dep; p.v = p0.v
code = parse!(p, ocp, e; log=log)
init = @match (__t_dep(p), __v_dep(p)) begin
(false, false) => :( $ocp = Model() )
(true , false) => :( $ocp = Model(autonomous=false) )
(false, true ) => :( $ocp = Model(variable=true) )
_ => :( $ocp = Model(autonomous=false, variable=true) )
(false, false) => :( $ocp = __OCPModel() )
(true , false) => :( $ocp = __OCPModel(autonomous=false) )
(false, true ) => :( $ocp = __OCPModel(variable=true) )
_ => :( $ocp = __OCPModel(autonomous=false, variable=true) )
end
ee = QuoteNode(e)
code = Expr(:block, init, code, :( $ocp.model_expression=$ee ), :( $ocp )) # todo: remove returned ocp value?
Expand Down

0 comments on commit f6c3284

Please sign in to comment.