Skip to content

Commit

Permalink
refactor: update for MTKv9
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jan 29, 2024
1 parent 4da7756 commit 4c47599
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ForwardDiff = "0.10.26"
LinearAlgebra = "1.10"
Logging = "1.10"
LoggingExtras = "0.4, 1"
ModelingToolkit = "8.74"
ModelingToolkit = "8.74, 9"
Pkg = "1"
Printf = "1.10"
ProgressLogging = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion lib/OptimizationMOI/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Ipopt_jll = "=300.1400.400"
Juniper = "0.9"
MathOptInterface = "1"
ModelingToolkit = "8.74"
ModelingToolkit = "9"
Optimization = "3.21"
Reexport = "1.2"
SymbolicIndexingInterface = "0.3"
Expand Down
8 changes: 4 additions & 4 deletions lib/OptimizationMOI/src/OptimizationMOI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using MathOptInterface
using Optimization.SciMLBase
using SymbolicIndexingInterface
using SparseArrays
import ModelingToolkit: parameters, states, varmap_to_vars, mergedefaults, toexpr
import ModelingToolkit: parameters, unknowns, varmap_to_vars, mergedefaults, toexpr
import ModelingToolkit
const MTK = ModelingToolkit
using Symbolics
Expand Down Expand Up @@ -182,12 +182,12 @@ end
"""
convert_to_expr(eq, sys; expand_expr = false, pairs_arr = expr_map(sys))
Converts the given symbolic expression to a Julia `Expr` and replaces all symbols, i.e. states and
Converts the given symbolic expression to a Julia `Expr` and replaces all symbols, i.e. unknowns and
parameters with `x[i]` and `p[i]`.
# Arguments:
- `eq`: Expression to convert
- `sys`: Reference to the system holding the parameters and states
- `sys`: Reference to the system holding the parameters and unknowns
- `expand_expr=false`: If `true` the symbolic expression is expanded first.
"""
function convert_to_expr(eq, expr_map; expand_expr = false)
Expand All @@ -206,7 +206,7 @@ function convert_to_expr(eq, expr_map; expand_expr = false)
end

function get_expr_map(sys)
dvs = ModelingToolkit.states(sys)
dvs = ModelingToolkit.unknowns(sys)
ps = ModelingToolkit.parameters(sys)
return vcat([ModelingToolkit.toexpr(_s) => Expr(:ref, :x, i)
for (i, _s) in enumerate(dvs)],
Expand Down

0 comments on commit 4c47599

Please sign in to comment.