Skip to content

Commit

Permalink
Tracking errors using the new frame (#393)
Browse files Browse the repository at this point in the history
Tracking if the user doesn't specify the state_grid, input_grid, or a dynamic
  • Loading branch information
johnaoga authored Nov 10, 2024
2 parents 33bfbf6 + 5b81899 commit 4f8733c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ function input_indices(model::Optimizer)
end

function setup!(model::Optimizer)
if all(isnothing, model.dynamic)
error("Missing dynamics. i.e. ∂(x) = f(x, u) or Δ(x) = f(x, u)")
end

println(">>Setting up the model")
input_index = 0
state_index = 0
model.nlp_model = MOI.Nonlinear.Model()
Expand All @@ -420,6 +425,7 @@ function setup!(model::Optimizer)
vars = MOI.VariableIndex.(eachindex(model.lower))
model.evaluator = MOI.Nonlinear.Evaluator(model.nlp_model, backend, vars)
MOI.initialize(model.evaluator, Symbol[])
println(">>Model setup complete")
return
end

Expand Down
8 changes: 8 additions & 0 deletions src/optim/abstraction/uniform_grid_abstraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ function discretized_system(
end

function build_abstraction(concrete_system, model)
if isnothing(model.state_grid)
error("Please set the `state_grid`.")
end

if isnothing(model.input_grid)
error("Please set the `input_grid`.")
end

Xfull = DO.DomainList(model.state_grid)
DO.add_set!(Xfull, concrete_system.X, DO.INNER)
Ufull = DO.DomainList(model.input_grid)
Expand Down

0 comments on commit 4f8733c

Please sign in to comment.