pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

Expression "ctype"

Open michaelbynum opened this issue 2 years ago • 0 comments

Summary

I'm wondering if we should add a method to all expression types indicating the type of expression. This would be similar to the component ctype.

Rationale

Many pyomo-based expression walkers use the type of the expression as the key in a dictionary of "handlers". If we instead used some enumeration indicating the type of expression, then integrating expressions that inherit from pyomo expressions would be much easier.

Description

class ExpressionType(enum.Enum):
    variable = enum.auto()
    parameter = enum.auto()
    sum = enum.auto()
    product = enum.auto()
    ...

class SumExpression(NumericExpression):
    ...
    def expr_type(self):
        return ExpressionType.sum
    ...

michaelbynum avatar Jan 29 '24 15:01 michaelbynum