From 5f2a24ca712c9ab8b438f7caf0c5a07ce37845df Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 15 Nov 2023 20:55:23 +0530 Subject: [PATCH] fix: use SII instead of explicitly accessing SciMLFunction.syms --- Project.toml | 2 ++ lib/OptimizationMOI/src/nlp.jl | 4 ++-- src/Optimization.jl | 1 + src/function.jl | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 431e82167..1aae2c089 100644 --- a/Project.toml +++ b/Project.toml @@ -17,6 +17,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Requires = "ae029012-a4dd-5104-9daa-d747884805df" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" [weakdeps] @@ -51,6 +52,7 @@ ProgressLogging = "0.1" Reexport = "0.2, 1.0" Requires = "1.0" SciMLBase = "1.79.0, 2" +SymbolicIndexingInterface = "0.3" Symbolics = "5" TerminalLoggers = "0.1" julia = "1.6" diff --git a/lib/OptimizationMOI/src/nlp.jl b/lib/OptimizationMOI/src/nlp.jl index 055bf91d2..e1c30d40e 100644 --- a/lib/OptimizationMOI/src/nlp.jl +++ b/lib/OptimizationMOI/src/nlp.jl @@ -85,7 +85,7 @@ function SciMLBase.get_syms(sol::SciMLBase.OptimizationSolution{ C <: MOIOptimizationNLPCache, } - sol.cache.evaluator.f.syms + variable_symbols(sol.cache.evaluator.f) end function SciMLBase.get_paramsyms(sol::SciMLBase.OptimizationSolution{ T, @@ -99,7 +99,7 @@ function SciMLBase.get_paramsyms(sol::SciMLBase.OptimizationSolution{ C <: MOIOptimizationNLPCache, } - sol.cache.evaluator.f.paramsyms + parameter_symbols(sol.cache.evaluator.f) end function MOIOptimizationNLPCache(prob::OptimizationProblem, diff --git a/src/Optimization.jl b/src/Optimization.jl index da63f8178..4a043ea0d 100644 --- a/src/Optimization.jl +++ b/src/Optimization.jl @@ -13,6 +13,7 @@ end using Logging, ProgressLogging, ConsoleProgressMonitor, TerminalLoggers, LoggingExtras using ArrayInterface, Base.Iterators, SparseArrays, LinearAlgebra +using SymbolicIndexingInterface using Pkg import SciMLBase: OptimizationProblem, OptimizationFunction, ObjSense, diff --git a/src/function.jl b/src/function.jl index 13731a7b0..0b2da5b2f 100644 --- a/src/function.jl +++ b/src/function.jl @@ -68,7 +68,7 @@ function instantiate_function(f, x, ::SciMLBase.NoAD, cons_jac_prototype = cons_jac_prototype, cons_hess_prototype = cons_hess_prototype, expr = expr, cons_expr = cons_expr, - syms = f.syms, paramsyms = f.paramsyms, + sys = f.sys, observed = f.observed) end @@ -97,7 +97,7 @@ function instantiate_function(f, cache::ReInitCache, ::SciMLBase.NoAD, cons_jac_prototype = cons_jac_prototype, cons_hess_prototype = cons_hess_prototype, expr = expr, cons_expr = cons_expr, - syms = f.syms, paramsyms = f.paramsyms, + sys = f.sys, observed = f.observed) end