-
Notifications
You must be signed in to change notification settings - Fork 590
Remove expression _args_ tuple
#4022
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
Open
jsiirola
wants to merge
21
commits into
Pyomo:main
Choose a base branch
from
jsiirola:expr-remove-args-tuple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
74b1098
Remove standard expression _args_ attribute
jsiirola fab9989
Update logical ._args from list to tuple
jsiirola 7fed39b
Misc doc updates
jsiirola 0e58a97
Deprecate UnaryBooleanExpression and BinaryBooleanExpression
jsiirola 3b11a57
Standardize on `_args` over `_args_`
jsiirola e1da1dc
Move BooleanConstant.value to be a property
jsiirola 8416e7f
Merge branch 'main' into expr-remove-args-tuple
jsiirola 5aa86be
Merge branch 'main' into expr-remove-args-tuple
jsiirola f7eeffd
Resolve import errors
jsiirola 9677f3b
Rework grb_nl_to_pyo_expr to not require private attribute access
jsiirola 0ccd6e2
Update tests to reflect more accurate grb_nl_to_pyo_expr handling
jsiirola 336c442
Propagate use of Unary, Binary, and Nary mixins into CP expressions
jsiirola 3867b15
Deprecate NaryBooleanExpression
jsiirola 348aac8
Resolve typos
jsiirola 9f3953d
Update FBBT tests to create proper expression nodes
jsiirola d36f738
Update PrecedenceExpression internal storage to verify number of args
jsiirola fd8c93c
Abstract the variable-lenth argument logic out of SumExpression
jsiirola d06e471
Rework step functions to leverage standard expression mixins
jsiirola d37caf6
Reduce external access to private attributes
jsiirola d4bf24b
Remove unused code
jsiirola 85e9f88
Merge remote-tracking branch 'refs/remotes/me/expr-remove-args-tuple'…
jsiirola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,11 @@ | |
| # software. This software is distributed under the 3-clause BSD License. | ||
| # ____________________________________________________________________________________ | ||
|
|
||
| from pyomo.core.expr.base import BinaryExpression_Mixin, UnaryExpression_Mixin | ||
| from pyomo.core.expr.logical_expr import BooleanExpression | ||
|
|
||
|
|
||
| class NoOverlapExpression(BooleanExpression): | ||
| class NoOverlapExpression(UnaryExpression_Mixin, BooleanExpression): | ||
| """ | ||
| Expression representing that none of the IntervalVars in a SequenceVar overlap | ||
| (if they are scheduled) | ||
|
|
@@ -19,14 +20,13 @@ class NoOverlapExpression(BooleanExpression): | |
| args (tuple): Child node of type SequenceVar | ||
| """ | ||
|
|
||
| def nargs(self): | ||
| return 1 | ||
| __slots__ = ('_arg',) | ||
|
|
||
| def _to_string(self, values, verbose, smap): | ||
| return "no_overlap(%s)" % values[0] | ||
|
|
||
|
|
||
| class FirstInSequenceExpression(BooleanExpression): | ||
| class FirstInSequenceExpression(BinaryExpression_Mixin, BooleanExpression): | ||
| """ | ||
| Expression representing that the specified IntervalVar is the first in the | ||
| sequence specified by SequenceVar (if it is scheduled) | ||
|
|
@@ -36,14 +36,13 @@ class FirstInSequenceExpression(BooleanExpression): | |
| SequenceVar | ||
| """ | ||
|
|
||
| def nargs(self): | ||
| return 2 | ||
| __slots__ = ('_l_arg', '_r_arg') | ||
|
|
||
| def _to_string(self, values, verbose, smap): | ||
| return "first_in(%s, %s)" % (values[0], values[1]) | ||
|
|
||
|
|
||
| class LastInSequenceExpression(BooleanExpression): | ||
| class LastInSequenceExpression(BinaryExpression_Mixin, BooleanExpression): | ||
| """ | ||
| Expression representing that the specified IntervalVar is the last in the | ||
| sequence specified by SequenceVar (if it is scheduled) | ||
|
|
@@ -53,9 +52,6 @@ class LastInSequenceExpression(BooleanExpression): | |
| SequenceVar | ||
| """ | ||
|
|
||
| def nargs(self): | ||
| return 2 | ||
|
|
||
| def _to_string(self, values, verbose, smap): | ||
| return "last_in(%s, %s)" % (values[0], values[1]) | ||
|
|
||
|
|
@@ -65,14 +61,26 @@ class BeforeInSequenceExpression(BooleanExpression): | |
| Expression representing that one IntervalVar occurs before another in the | ||
| sequence specified by the given SequenceVar (if both are scheduled) | ||
|
|
||
| args: | ||
| args (tuple): Child nodes, the IntervalVar that must be before, the | ||
| IntervalVar that must be after, and the SequenceVar | ||
| Parameters | ||
| ---------- | ||
| args : tuple["IntervalVar", "IntervalVar", "SequenceVar"] | ||
|
|
||
| The child nodes, consisting of the predecessor IntervalVar, the successor | ||
| IntervalVar, and the SequenceVar | ||
| """ | ||
|
|
||
| __slots__ = ('_before', '_after', '_sequence') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You use before/after here but predecessor/successor in L#95. It would be better to pick one probably, considering that you are referring to them in the same way? |
||
|
|
||
| def __init__(self, args): | ||
| self._before, self._after, self._sequence = args | ||
|
|
||
| def nargs(self): | ||
| return 3 | ||
|
|
||
| @property | ||
| def args(self): | ||
| return self._before, self._after, self._sequence | ||
|
|
||
| def _to_string(self, values, verbose, smap): | ||
| return "before_in(%s, %s, %s)" % (values[0], values[1], values[2]) | ||
|
|
||
|
|
@@ -82,14 +90,27 @@ class PredecessorToExpression(BooleanExpression): | |
| Expression representing that one IntervalVar is a direct predecessor to another | ||
| in the sequence specified by the given SequenceVar (if both are scheduled) | ||
|
|
||
| args: | ||
| args (tuple): Child nodes, the predecessor IntervalVar, the successor | ||
| IntervalVar, and the SequenceVar | ||
| Parameters | ||
| ---------- | ||
| args : tuple["IntervalVar", "IntervalVar", "SequenceVar"] | ||
|
|
||
| The child nodes, consisting of the predecessor IntervalVar, the successor | ||
| IntervalVar, and the SequenceVar | ||
|
|
||
| """ | ||
|
|
||
| __slots__ = ('_predecessor', '_successor', '_sequence') | ||
|
|
||
| def __init__(self, args): | ||
| self._predecessor, self._successor, self._sequence = args | ||
|
|
||
| def nargs(self): | ||
| return 3 | ||
|
|
||
| @property | ||
| def args(self): | ||
| return self._predecessor, self._successor, self._sequence | ||
|
|
||
| def _to_string(self, values, verbose, smap): | ||
| return "predecessor_to(%s, %s, %s)" % (values[0], values[1], values[2]) | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
leftandright?