as_numeric

(函数来自 pyomo.core.expr.numvalue)

pyomo.core.expr.numvalue.as_numeric(obj)[source]

一个创建NumericConstant对象的函数,该对象包装Python数值。

此函数还管理一个常量缓存。

NOTE: This function is only intended for use when

数据被添加到一个组件中。

Parameters:

obj – 可能被包装的数值。

Raises: TypeError if the object is in native_types and not in

native_numeric_types

返回:一个NumericConstant对象或原始对象。