Skip to content

feat: add max, min, ceil & floors operators#179

Closed
aoustry wants to merge 9 commits intomainfrom
claude/add-math-operators-g4pld
Closed

feat: add max, min, ceil & floors operators#179
aoustry wants to merge 9 commits intomainfrom
claude/add-math-operators-g4pld

Conversation

@aoustry
Copy link
Collaborator

@aoustry aoustry commented Mar 20, 2026

No description provided.

claude added 9 commits March 18, 2026 21:45
These operators are needed to parse and evaluate GEMS model expressions
from antares_legacy_models.yml, which uses ceil(p/q), max(0, expr), and
min(a, b) in variable bounds and constraint expressions for thermal unit
commitment models.

Changes:
- Add FloorNode, CeilNode (unary) and MaxNode, MinNode (binary) AST nodes
- Add floor()/ceil() methods on ExpressionNode; maximum()/minimum() factory fns
- Extend Expr.g4 grammar with binaryFunction rule; regenerate ANTLR files
- Update all visitors: abstract ExpressionVisitor, CopyVisitor, PrinterVisitor,
  EvaluationVisitor, ExpressionDegreeVisitor, TimeScenarioIndexingVisitor,
  EqualityVisitor
- Register floor/ceil in _FUNCTIONS and max/min in new _BINARY_FUNCTIONS dict
- Add tests for parsing, evaluation, and printing of the new operators

https://claude.ai/code/session_01VUYEHTGsxtBYVEVm5c7ysC
…ExpressionBuilder

Add ceil, floor, maximum, minimum implementations to all ExpressionVisitor
subclasses that were missing them after the new math operators were added.

https://claude.ai/code/session_01VUYEHTGsxtBYVEVm5c7ysC
floor(x), ceil(x), max(x,y), min(x,y) are not polynomials when their
operands involve variables, so their degree is mathematically undefined
(infinity) rather than equal to the operand degree.

Also widens ExpressionDegreeVisitor and compute_degree from int to
int | float to accommodate math.inf.

https://claude.ai/code/session_01VUYEHTGsxtBYVEVm5c7ysC
…| float

When ExpressionDegreeVisitor is parameterized as ExpressionVisitor[int | float],
visit() returns int | float everywhere, so all methods that call visit() and
were annotated -> int now need -> int | float.

https://claude.ai/code/session_01VUYEHTGsxtBYVEVm5c7ysC
@aoustry aoustry closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants