Skip to content

Commit

Permalink
Merge pull request #229 from dionysos-dev/clean_problem_optim_adrien
Browse files Browse the repository at this point in the history
`src/problem` and `src/optim` organization improvements
  • Loading branch information
adrienbanse authored Jun 9, 2023
2 parents 5b30746 + e12aa0b commit 1f61a0e
Show file tree
Hide file tree
Showing 11 changed files with 457 additions and 418 deletions.
3 changes: 2 additions & 1 deletion docs/src/examples/DC-DC converter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const OP = DI.Optim
const AB = OP.Abstraction

# ### Definition of the system
# we can import the module containing the DCDC problem like this
Expand All @@ -65,7 +66,7 @@ hu = SVector(1)
input_grid = DO.GridFree(u0, hu)

using JuMP
optimizer = MOI.instantiate(OP.Abstraction.Optimizer)
optimizer = MOI.instantiate(AB.SCOTSAbstraction.Optimizer)
MOI.set(optimizer, MOI.RawOptimizerAttribute("problem"), problem)
MOI.set(optimizer, MOI.RawOptimizerAttribute("state_grid"), state_grid)
MOI.set(optimizer, MOI.RawOptimizerAttribute("input_grid"), input_grid)
Expand Down
21 changes: 11 additions & 10 deletions docs/src/examples/Path planning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ using StaticArrays, Plots
using Dionysos
const DI = Dionysos
const DO = DI.Domain
const OP = DI.Optim
const CO = DI.Control
const UT = DI.Utils
const OP = DI.Optim
const AB = OP.Abstraction

# And the file defining the hybrid system for this problem
include(joinpath(dirname(dirname(pathof(Dionysos))), "problems", "PathPlanning.jl"))
Expand All @@ -73,10 +74,10 @@ u0 = SVector(0.0, 0.0);
h = SVector(0.3, 0.3);
input_grid = DO.GridFree(u0, h);

# We now solve the optimal control problem with the `Abstraction.Optimizer`.
# We now solve the optimal control problem with the `Abstraction.SCOTSAbstraction.Optimizer`.

using JuMP
optimizer = MOI.instantiate(OP.Abstraction.Optimizer)
optimizer = MOI.instantiate(AB.SCOTSAbstraction.Optimizer)
MOI.set(optimizer, MOI.RawOptimizerAttribute("problem"), problem)
MOI.set(optimizer, MOI.RawOptimizerAttribute("state_grid"), state_grid)
MOI.set(optimizer, MOI.RawOptimizerAttribute("input_grid"), input_grid)
Expand Down Expand Up @@ -105,18 +106,18 @@ fig = plot(aspect_ratio=:equal);
##We display the concrete domain
plot!(problem.system.X, color=:yellow, opacity=0.5);

##We display the abstract domain
abstract_system = OP.Abstraction.get_abstract_system(optimizer)
plot!(abstract_system.Xdom, color=:blue, opacity=0.5);
# We display the abstract domain
abstract_system = AB.SCOTSAbstraction.get_abstract_system(optimizer)
plot!(abstract_system.Xdom, color=:blue, opacity=0.5)

##We display the concrete specifications
plot!(problem.initial_set, color=:green, opacity=0.2);
plot!(problem.target_set; dims=[1,2], color=:red, opacity=0.2);

##We display the abstract specifications
abstract_problem = OP.Abstraction.get_abstract_problem(optimizer)
plot!(abstract_problem.initial_set, color=:green);
plot!(abstract_problem.target_set, color=:red);
# We display the abstract specifications
abstract_problem = AB.SCOTSAbstraction.get_abstract_problem(optimizer)
plot!(abstract_problem.initial_set, color=:green)
plot!(abstract_problem.target_set, color=:red)

##We display the concrete trajectory
plot!(fig, UT.DrawTrajectory(x_traj), ms=0.5)
Expand Down
5 changes: 3 additions & 2 deletions docs/src/examples/State-feedback Abstraction PWA System.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const SY = DI.Symbolic
const CO = DI.Control
const PR = DI.Problem
const OP = DI.Optim
const AB = OP.Abstraction

# Let us now define the state space $X$ within which we are searching for a optimal solution.
max_x = 2 # bound on |X|_∞
Expand All @@ -100,10 +101,10 @@ P = (1/n_x)*diagm((X_step./2).^(-2))
state_grid = DO.GridEllipsoidalRectangular(X_origin, X_step, P, rectX)

# At this point, we instantiate the optimizer provided in Dionysos that creates ellipsoidal-based
# abstractions `OptimizerEllipsoids`
# abstractions `EllipsoidsAbstraction.Optimizer`

using JuMP
optimizer = MOI.instantiate(OP.Abstraction.OptimizerEllipsoids) #
optimizer = MOI.instantiate(AB.EllipsoidsAbstraction.Optimizer) #

MOI.set(optimizer, MOI.RawOptimizerAttribute("problem"), problem)
MOI.set(optimizer, MOI.RawOptimizerAttribute("state_grid"), state_grid)
Expand Down
Loading

0 comments on commit 1f61a0e

Please sign in to comment.