Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression "ctype" #3111

Open
michaelbynum opened this issue Jan 29, 2024 · 0 comments
Open

Expression "ctype" #3111

michaelbynum opened this issue Jan 29, 2024 · 0 comments

Comments

@michaelbynum
Copy link
Contributor

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
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants