Skip to content

Commit

Permalink
Pass expr and sys in all backends
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Apr 18, 2024
1 parent 4ac3f4f commit ef86271
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 24 deletions.
24 changes: 20 additions & 4 deletions ext/OptimizationFiniteDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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
24 changes: 20 additions & 4 deletions ext/OptimizationReverseDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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
24 changes: 20 additions & 4 deletions ext/OptimizationSparseFiniteDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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
24 changes: 20 additions & 4 deletions ext/OptimizationSparseForwardDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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
24 changes: 20 additions & 4 deletions ext/OptimizationSparseReverseDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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
24 changes: 20 additions & 4 deletions ext/OptimizationZygoteExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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

0 comments on commit ef86271

Please sign in to comment.