一、报错问题
ValueError: Custom function inv is not defined in `extra_sympy_mappings`. You can define it with, e.g., `model.set_params(extra_sympy_mappings={'inv': lambda x: 1/x})`, where `lambda x: 1/x` is a valid SymPy function defining the operator. You can also define these at initialization time.
二、解决方式
在model里面inv这个函数是不存在的,需要extra_sympy_mappings
来定义在 SymPy 中定义额外函数或操作符的字典。
报错代码:
unary_operators = ["cos","exp","sin","sqrt","inv(x) = 1/x"],
修改为:
extra_sympy_mappings = {'inv':lambda x:1/x},unary_operators = ["cos","exp","sin","sqrt",],
则可正常运行