Skip to content

Commit

Permalink
Jc/standardize trajectories 2 (#316)
Browse files Browse the repository at this point in the history
* suppress Control folder

* standardize trajectories

* format
  • Loading branch information
JulienCalbert authored Oct 19, 2023
1 parent f2f50cb commit 7256c40
Show file tree
Hide file tree
Showing 48 changed files with 309 additions and 299 deletions.
7 changes: 3 additions & 4 deletions docs/src/examples/DC-DC converter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const OP = DI.Optim
const AB = OP.Abstraction

Expand Down Expand Up @@ -82,12 +81,12 @@ concrete_controller = MOI.get(optimizer, MOI.RawOptimizerAttribute("concrete_con
# as well as the true initial state `x0` which is contained in the initial state-space defined previously.
nstep = 300
x0 = SVector(1.2, 5.6)
x_traj, u_traj =
CO.get_closed_loop_trajectory(concrete_system.f, concrete_controller, x0, nstep)
control_trajectory =
ST.get_closed_loop_trajectory(concrete_system.f, concrete_controller, x0, nstep)

fig = plot(; aspect_ratio = :equal);
plot!(concrete_system.X);
plot!(UT.DrawTrajectory(x_traj))
plot!(control_trajectory)

# ### References
# 1. A. Girard, G. Pola and P. Tabuada, "Approximately Bisimilar Symbolic Models for Incrementally Stable Switched Systems," in IEEE Transactions on Automatic Control, vol. 55, no. 1, pp. 116-126, Jan. 2010.
Expand Down
1 change: 0 additions & 1 deletion docs/src/examples/Getting Started.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const DI = Dionysos
const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const CO = DI.Control
const SY = DI.Symbolic

# Additionally, we will short the submodules accondingly
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/Gol, Lazar & Belta (2013).jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Ipopt
using Dionysos
const DI = Dionysos
const UT = DI.Utils
const CO = DI.Control
const ST = DI.System
const OP = DI.Optim

# And the file defining the hybrid system for this problem
Expand Down Expand Up @@ -86,7 +86,7 @@ objective_value = MOI.get(optimizer, MOI.ObjectiveValue())
@test objective_value 11.38 atol = 1e-2 #src

# and recover the corresponding continuous trajectory
xu = MOI.get(optimizer, CO.ContinuousTrajectoryAttribute());
xu = MOI.get(optimizer, ST.ContinuousTrajectoryAttribute());

# ## A little bit of data visualization now:

Expand Down
14 changes: 8 additions & 6 deletions docs/src/examples/Hierarchical-abstraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const PR = DI.Problem
const OP = DI.Optim
const AB = OP.Abstraction
Expand Down Expand Up @@ -160,9 +159,12 @@ println("Solved : ", optimizer.solved)

# ## Simulation
x0 = UT.get_center(concrete_problem.initial_set)
x_traj, u_traj, cost_traj = AB.HierarchicalAbstraction.simulate_trajectory(optimizer, x0)
cost = sum(cost_traj);
println("Goal set reached: $(x_traj[end]concrete_problem.target_set)")
cost_control_trajectory =
AB.HierarchicalAbstraction.get_closed_loop_trajectory(optimizer, x0)
cost = sum(cost_control_trajectory.costs.seq);
println(
"Goal set reached: $(ST.get_state(cost_control_trajectory, ST.length(cost_control_trajectory))concrete_problem.target_set)",
)
println("Cost:\t $(cost)")

# ## Display the results
Expand All @@ -180,7 +182,7 @@ plot!(concrete_problem.initial_set; color = :green, opacity = 0.8);
plot!(concrete_problem.target_set; dims = [1, 2], color = :red, opacity = 0.8);

#We display the concrete trajectory
plot!(UT.DrawTrajectory(x_traj); ms = 0.5)
plot!(cost_control_trajectory; ms = 0.5)

# # Display the lazy abstraction
fig = plot(; aspect_ratio = :equal);
Expand All @@ -191,4 +193,4 @@ plot!(
heuristic = false,
fine = true,
)
plot!(UT.DrawTrajectory(x_traj); ms = 0.5)
plot!(cost_control_trajectory; ms = 0.5)
7 changes: 3 additions & 4 deletions docs/src/examples/Lazy-Ellipsoids-Abstraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const PR = DI.Problem
const OP = DI.Optim
const AB = OP.Abstraction
Expand Down Expand Up @@ -73,7 +72,7 @@ reached(x) = x ∈ concrete_problem.target_set
nstep = typeof(concrete_problem.time) == PR.Infinity ? 100 : concrete_problem.time; # max num of steps
# We simulate the closed loop trajectory
x0 = concrete_problem.initial_set.c
x_traj, u_traj, cost_traj = CO.get_closed_loop_trajectory(
cost_control_trajectory = ST.get_closed_loop_trajectory(
concrete_system.f_eval,
concrete_controller,
cost_eval,
Expand All @@ -83,7 +82,7 @@ x_traj, u_traj, cost_traj = CO.get_closed_loop_trajectory(
noise = true,
)
cost_bound = concrete_lyap_fun(x0)
cost_true = sum(cost_traj);
cost_true = sum(cost_control_trajectory.costs.seq);
println("Goal set reached")
println("Guaranteed cost:\t $(cost_bound)")
println("True cost:\t\t $(cost_true)")
Expand Down Expand Up @@ -141,6 +140,6 @@ for obs in concrete_system.obstacles
plot!(obs; color = :black)
end
plot!(abstract_system; arrowsB = false, cost = true);
plot!(UT.DrawTrajectory(x_traj); color = :black)
plot!(cost_control_trajectory; color = :black)

@test cost_true <= cost_bound #src
7 changes: 3 additions & 4 deletions docs/src/examples/Lazy-abstraction-reachability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const PR = DI.Problem
const OP = DI.Optim
const AB = OP.Abstraction
Expand Down Expand Up @@ -148,7 +147,7 @@ reached(x) = x ∈ concrete_problem.target_set
nstep = typeof(concrete_problem.time) == PR.Infinity ? 100 : concrete_problem.time; # max num of steps
# We simulate the closed loop trajectory
x0 = UT.get_center(concrete_problem.initial_set)
x_traj, u_traj, cost_traj = CO.get_closed_loop_trajectory(
cost_control_trajectory = ST.get_closed_loop_trajectory(
concrete_system.f_eval,
concrete_controller,
cost_eval,
Expand All @@ -159,7 +158,7 @@ x_traj, u_traj, cost_traj = CO.get_closed_loop_trajectory(
)

cost_bound = concrete_lyap_fun(x0)
cost_true = sum(cost_traj);
cost_true = sum(cost_control_trajectory.costs.seq);
println("Goal set reached")
println("Guaranteed cost:\t $(cost_bound)")
println("True cost:\t\t $(cost_true)")
Expand All @@ -178,7 +177,7 @@ plot!(concrete_problem.initial_set; color = :green, opacity = 0.8);
plot!(concrete_problem.target_set; dims = [1, 2], color = :red, opacity = 0.8);

#We display the concrete trajectory
plot!(UT.DrawTrajectory(x_traj); ms = 0.5)
plot!(cost_control_trajectory; ms = 0.5)

# # Display the abstraction and Lyapunov-like function
fig = plot(; aspect_ratio = :equal);
Expand Down
5 changes: 2 additions & 3 deletions docs/src/examples/Path planning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const PR = DI.Problem
const OP = DI.Optim
const AB = OP.Abstraction
Expand Down Expand Up @@ -102,7 +101,7 @@ function reached(x)
end
end
x0 = SVector(0.4, 0.4, 0.0)
x_traj, u_traj = CO.get_closed_loop_trajectory(
control_trajectory = ST.get_closed_loop_trajectory(
concrete_system.f,
concrete_controller,
x0,
Expand Down Expand Up @@ -133,7 +132,7 @@ plot!(
);

# We display the concrete trajectory
plot!(UT.DrawTrajectory(x_traj); ms = 0.5)
plot!(control_trajectory; ms = 0.5)

# ### References
# 1. G. Reissig, A. Weber and M. Rungger, "Feedback Refinement Relations for the Synthesis of Symbolic Controllers," in IEEE Transactions on Automatic Control, vol. 62, no. 4, pp. 1781-1796.
Expand Down
7 changes: 3 additions & 4 deletions docs/src/examples/State-feedback Abstraction PWA System.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const SY = DI.Symbolic
const CO = DI.Control
const PR = DI.Problem
const OP = DI.Optim
const AB = OP.Abstraction
Expand Down Expand Up @@ -148,7 +147,7 @@ end

# We simulate the closed loop trajectory
x0 = concrete_problem.initial_set
x_traj, u_traj, cost_traj = CO.get_closed_loop_trajectory(
cost_control_trajectory = ST.get_closed_loop_trajectory(
f_eval1,
concrete_controller,
cost_eval,
Expand All @@ -157,7 +156,7 @@ x_traj, u_traj, cost_traj = CO.get_closed_loop_trajectory(
stopping = reached,
)
cost_bound = concrete_lyap_fun(x0)
cost_true = sum(cost_traj);
cost_true = sum(cost_control_trajectory.costs.seq);
println("Goal set reached")
println("Guaranteed cost:\t $(cost_bound)")
println("True cost:\t\t $(cost_true)")
Expand Down Expand Up @@ -224,7 +223,7 @@ xlabel!("\$x_1\$");
ylabel!("\$x_2\$");
title!("Trajectory and Lyapunov-like Fun.");
plot!(abstract_system; arrowsB = false, cost = true, lyap_fun = optimizer.lyap);
plot!(UT.DrawTrajectory(x_traj); color = :black)
plot!(cost_control_trajectory; color = :black)

@test cost_bound 2.35825 rtol = 1e-3 #src
@test cost_true <= cost_bound #src
Expand Down
4 changes: 2 additions & 2 deletions docs/src/reference/System.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Dionysos.System.AffineController

## SHOULD BE REMOVED
```@docs
Dionysos.Control.DiscreteTrajectory
Dionysos.Control.ContinuousTrajectory
Dionysos.System.DiscreteTrajectory
Dionysos.System.ContinuousTrajectory
```
1 change: 0 additions & 1 deletion problems/dc_dc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const UT = DI.Utils
const DO = DI.Domain
const PB = DI.Problem
const ST = DI.System
const CO = DI.Control
const SY = DI.Symbolic

function dynamicofsystem(
Expand Down
1 change: 0 additions & 1 deletion problems/gol_lazar_belta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module GolLazarBelta
import Dionysos
const DI = Dionysos
const UT = DI.Utils
const CO = DI.Control
const PR = DI.Problem

using FillArrays
Expand Down
2 changes: 0 additions & 2 deletions problems/non_linear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ using StaticArrays, LinearAlgebra, Symbolics, IntervalArithmetic
using MathematicalSystems, HybridSystems

import Dionysos
using Dionysos.Control
using Dionysos.Problem
const DI = Dionysos
const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const CO = DI.Control
const SY = DI.Symbolic
const PR = DI.Problem

Expand Down
1 change: 0 additions & 1 deletion problems/path_planning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ using MathematicalSystems, HybridSystems
using Dionysos
const UT = Dionysos.Utils
const DO = Dionysos.Domain
const CO = Dionysos.Control
const PB = Dionysos.Problem
const ST = Dionysos.System

Expand Down
2 changes: 0 additions & 2 deletions problems/pwa_sys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ using MathematicalSystems, HybridSystems
using FillArrays, CDDLib

import Dionysos
using Dionysos.Control
using Dionysos.Problem
const DI = Dionysos
const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const CO = DI.Control
const SY = DI.Symbolic
const PR = DI.Problem

Expand Down
2 changes: 0 additions & 2 deletions problems/simple_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ using StaticArrays, LinearAlgebra, Symbolics, IntervalArithmetic
using MathematicalSystems, HybridSystems

import Dionysos
using Dionysos.Control
using Dionysos.Problem
const DI = Dionysos
const UT = DI.Utils
const DO = DI.Domain
const ST = DI.System
const CO = DI.Control
const SY = DI.Symbolic
const PR = DI.Problem

Expand Down
1 change: 0 additions & 1 deletion src/Dionysos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include("utils/utils.jl")
include("domain/domain.jl")
include("system/system.jl")
include("symbolic/symbolic.jl")
include("control/control.jl")
include("problem/problem.jl")
include("optim/optim.jl")
include("mapping/mapping.jl")
Expand Down
18 changes: 0 additions & 18 deletions src/control/control.jl

This file was deleted.

Loading

0 comments on commit 7256c40

Please sign in to comment.