From ef86271483791a56eb9ad94eae3d4d17df08c1b7 Mon Sep 17 00:00:00 2001 From: Vaibhav Dixit Date: Wed, 17 Apr 2024 23:44:05 -0400 Subject: [PATCH] Pass expr and sys in all backends --- ext/OptimizationFiniteDiffExt.jl | 24 ++++++++++++++++++++---- ext/OptimizationReverseDiffExt.jl | 24 ++++++++++++++++++++---- ext/OptimizationSparseFiniteDiff.jl | 24 ++++++++++++++++++++---- ext/OptimizationSparseForwardDiff.jl | 24 ++++++++++++++++++++---- ext/OptimizationSparseReverseDiff.jl | 24 ++++++++++++++++++++---- ext/OptimizationZygoteExt.jl | 24 ++++++++++++++++++++---- 6 files changed, 120 insertions(+), 24 deletions(-) diff --git a/ext/OptimizationFiniteDiffExt.jl b/ext/OptimizationFiniteDiffExt.jl index 6dc6f48..d5b0f13 100644 --- a/ext/OptimizationFiniteDiffExt.jl +++ b/ext/OptimizationFiniteDiffExt.jl @@ -114,7 +114,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, @@ -229,7 +233,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x, @@ -337,7 +345,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, @@ -446,7 +458,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end end diff --git a/ext/OptimizationReverseDiffExt.jl b/ext/OptimizationReverseDiffExt.jl index 83b6400..9d0f791 100644 --- a/ext/OptimizationReverseDiffExt.jl +++ b/ext/OptimizationReverseDiffExt.jl @@ -148,7 +148,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, @@ -285,7 +289,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x, @@ -422,7 +430,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, @@ -559,7 +571,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end end diff --git a/ext/OptimizationSparseFiniteDiff.jl b/ext/OptimizationSparseFiniteDiff.jl index 9963248..ece8c63 100644 --- a/ext/OptimizationSparseFiniteDiff.jl +++ b/ext/OptimizationSparseFiniteDiff.jl @@ -122,7 +122,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = getfield.(conshess_caches, :sparsity), cons_hess_colorvec = getfield.(conshess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, @@ -252,7 +256,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = getfield.(conshess_caches, :sparsity), cons_hess_colorvec = getfield.(conshess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x, @@ -384,7 +392,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = getfield.(conshess_caches, :sparsity), cons_hess_colorvec = getfield.(conshess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, @@ -511,5 +523,9 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = getfield.(conshess_caches, :sparsity), cons_hess_colorvec = getfield.(conshess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end diff --git a/ext/OptimizationSparseForwardDiff.jl b/ext/OptimizationSparseForwardDiff.jl index 97cde29..4841d9e 100644 --- a/ext/OptimizationSparseForwardDiff.jl +++ b/ext/OptimizationSparseForwardDiff.jl @@ -102,7 +102,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x, cons_jac_prototype = cons_jac_prototype, cons_hess_prototype = getfield.(cons_hess_caches, :sparsity), cons_hess_colorvec = getfield.(cons_hess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, @@ -210,7 +214,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = getfield.(cons_hess_caches, :sparsity), cons_hess_colorvec = getfield.(cons_hess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x, @@ -318,7 +326,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x cons_jac_prototype = cons_jac_prototype, cons_hess_prototype = getfield.(cons_hess_caches, :sparsity), cons_hess_colorvec = getfield.(cons_hess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, @@ -429,5 +441,9 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, cons_jac_prototype = cons_jac_prototype, cons_hess_prototype = getfield.(cons_hess_caches, :sparsity), cons_hess_colorvec = getfield.(cons_hess_caches, :colors), - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end diff --git a/ext/OptimizationSparseReverseDiff.jl b/ext/OptimizationSparseReverseDiff.jl index 1f32574..a52346f 100644 --- a/ext/OptimizationSparseReverseDiff.jl +++ b/ext/OptimizationSparseReverseDiff.jl @@ -171,7 +171,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = conshess_sparsity, cons_hess_colorvec = conshess_colors, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, @@ -370,7 +374,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = conshess_sparsity, cons_hess_colorvec = conshess_colors, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x, @@ -546,7 +554,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = conshess_sparsity, cons_hess_colorvec = conshess_colors, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, @@ -723,5 +735,9 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, cons_jac_colorvec = cons_jac_colorvec, cons_hess_prototype = conshess_sparsity, cons_hess_colorvec = conshess_colors, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end diff --git a/ext/OptimizationZygoteExt.jl b/ext/OptimizationZygoteExt.jl index 26f9e21..60a5478 100644 --- a/ext/OptimizationZygoteExt.jl +++ b/ext/OptimizationZygoteExt.jl @@ -81,7 +81,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, @@ -159,7 +163,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x, @@ -240,7 +248,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, @@ -323,7 +335,11 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, hess_prototype = f.hess_prototype, cons_jac_prototype = f.cons_jac_prototype, cons_hess_prototype = f.cons_hess_prototype, - lag_h, f.lag_hess_prototype) + lag_h = lag_h, + lag_hess_prototype = f.lag_hess_prototype, + sys = f.sys, + expr = f.expr, + cons_expr = f.cons_expr) end end