Skip to content

Commit

Permalink
cleaning and adding missing modules
Browse files Browse the repository at this point in the history
  • Loading branch information
johnaoga committed Dec 3, 2024
1 parent e6ca02a commit 2f8104b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.1.3"

[deps]
ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d"
CDDLib = "3391f64e-dcde-5f30-b752-e11513730f60"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DiscreteMarkovChains = "8abcb7ef-b365-4f7b-ac38-56893fb62f9f"
Expand All @@ -16,6 +17,7 @@ HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
HybridSystems = "2207ec0c-686c-5054-b4d2-543502888820"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalLinearAlgebra = "92cbe1ac-9c24-436b-b0c9-5f7317aedcd5"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
Expand All @@ -26,6 +28,8 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
MathOptSymbolicAD = "309f4015-3481-4d63-a8f9-aeb13adfe8eb"
MathematicalSystems = "d14a8603-c872-5ed3-9ece-53e0e82e39da"
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
OSQP = "ab2f91bb-94b4-55e3-9ba0-7f65df51de79"
Pavito = "cd433a01-47d1-575d-afb7-6db927ee8d8f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand All @@ -41,6 +45,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[compat]
ArnoldiMethod = "0.2, 0.4"
CDDLib = "0.9.4"
Colors = "0.12, 0.13"
DataStructures = "0.18"
DiscreteMarkovChains = "0.2"
Expand All @@ -52,6 +57,7 @@ HiGHS = "1"
HybridSystems = "0.4"
IntervalArithmetic = "0.20, 0.21, 0.22"
IntervalLinearAlgebra = "0.1"
Ipopt = "1.7.0"
JuMP = "1"
LaTeXStrings = "1"
LazySets = "2"
Expand All @@ -61,6 +67,8 @@ MathOptInterface = "1"
MathOptSymbolicAD = "0.2.1"
MathematicalSystems = "0.11, 0.12, 0.13"
MutableArithmetics = "1"
OSQP = "0.8.1"
Pavito = "0.3.9"
Plots = "1"
Polyhedra = "0.7"
ProgressMeter = "1.4"
Expand Down
17 changes: 8 additions & 9 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,7 @@ function problem(model::Optimizer)
return problem
end

function problem_hybrid(model::Optimizer)
lib = CDDLib.Library()
T::Type = Float64
q_0 = 1 #length(model.modes)
x_0 = [1.0]
N = 11
zero_cost::Bool = true

function problem_hybrid(model::Optimizer, lib, T::Type, x_0 = [1.0], N = 11)
x_idx = state_indices(model)
u_idx = input_indices(model)
_I_ = Dionysos.Utils.HyperRectangle(
Expand All @@ -931,7 +924,13 @@ function problem_hybrid(model::Optimizer)
)

sys = system(model, x_idx, u_idx)
q_0 = length(x_idx)

if q_0 != length(x_0)
error("The initial state must have the same dimension as the state variables {$q_0} != {$length(x_0)}")
end

#TODO: This is a bit of a hack. We should probably have a better way to handle costs properly
state_cost = Fill(Dionysos.Utils.ZeroFunction(), sys.ext[:q_T])
transition_cost = Dionysos.Utils.QuadraticControlFunction(ones(T, 1, 1))

Expand Down Expand Up @@ -1088,7 +1087,7 @@ function MOI.optimize!(model::Optimizer)
"log_level" => 0,
)
model.inner = MOI.instantiate(algo)
MOI.set(model.inner, MOI.RawOptimizerAttribute("problem"), problem_hybrid(model))
MOI.set(model.inner, MOI.RawOptimizerAttribute("problem"), problem_hybrid(model, CDDLib.Library(), Float64))
else # CONTINUOUS or DISCRETE
println(">>Solving the {model.time_type} system")
MOI.set(model.inner, MOI.RawOptimizerAttribute("concrete_problem"), problem(model))
Expand Down

0 comments on commit 2f8104b

Please sign in to comment.