(function from pyomo.core.base.indexed_component)
pyomo.core.base.indexed_component
Wrap a rule with another function
This utility method provides a way to wrap a function (rule) with another function while preserving the original function signature. This is important for rules, as the Initializer() argument processor relies on knowing the number of positional arguments.
Initializer()
rule (function) – The original rule being wrapped
wrapping_fcn (function or Dict) – The wrapping function. The wrapping_fcn will be called with (rule, *args, **kwargs). For convenience, if a dict is passed as the wrapping_fcn, then the result of rule_result_substituter(wrapping_fcn)() is used as the wrapping function.
(rule, *args, **kwargs)
rule_result_substituter(wrapping_fcn)()
positional_arg_map (iterable[int]) – An iterable of indices of rule positional arguments to expose in the wrapped function signature. For example, positional_arg_map=(2, 0) and rule=fcn(a, b, c) would produce a wrapped function with a signature wrapper_function(c, a)