Skip to content

Expression "ctype" #3111

Open
Open
@michaelbynum

Description

@michaelbynum

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
    ...

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions