-
Notifications
You must be signed in to change notification settings - Fork 517
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
contrib.cp: Adding SequenceVar and other logical expressions for scheduling #3227
Conversation
…e when I collect components in the docplex writer
…want error checking
…rs hit for convoluted reasons--but basically because they have no kwd args named 'rule'
…ith the docplex model
…n expressions right now
…to do it better later
…fixing the monomial expression tests
…s magic for automatic registration.
def __init__(self): | ||
def __init__(self, *args, **kwd): | ||
# TODO: adding args and kwd above made Reference work, but we | ||
# probably shouldn't just swallow them, right? | ||
super().__init__(ctype=IntervalVarPresence) |
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.
@jsiirola, I made this change to make Reference(interval_var[:].is_present)
work, but I don't really understand what I did or know if this is the right fix.
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.
I don't know why this was necessary. We should probably make a note to go back and look into why this was necessary. It makes me a bit nervous to accept and silently discard the arguments here.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3227 +/- ##
==========================================
+ Coverage 88.40% 88.41% +0.01%
==========================================
Files 847 850 +3
Lines 95285 95459 +174
==========================================
+ Hits 84232 84400 +168
- Misses 11053 11059 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
m.iv = IntervalVar( | ||
[1, 2, 3], start=start_rule, length=length_rule, optional=True | ||
) | ||
m.whole_enchilada = IntervalVar() |
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.
How dare you make me laugh like this.
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.
I have a number of questions / things we should look farther into, but I am OK deferring all of that to a subsequent PR
|
||
def __init__(self, *args, **kwargs): | ||
self._init_rule = Initializer(kwargs.pop('rule', None)) | ||
self._init_expr = kwargs.pop('expr', None) |
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.
Why do you not use an Initializer here?
if self._init_expr is not None and self._init_rule is not None: | ||
raise ValueError( | ||
"Cannot specify both rule= and expr= for SequenceVar %s" % (self.name,) | ||
) |
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.
There is a method (self._pop_from_kwargs()
that can combine this logic and the two pop() above. See constraint.py:660
# We'll demand expr be a list for now--it needs to be ordered so this | ||
# doesn't seem like too much to ask |
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.
This is technically not requiring a list
(which is good). But, should there be a check for passing in a non-deterministic Sequence (e.g., set
)?
Jenkins failures are due to the license server for gurobi being unavailable. Merging. |
Fixes # .
Summary/Motivation:
This adds
SequenceVar
components and a number of associated and related expressions for modeling logical constraints on IntervalVars in constraint programming scheduling models. It also sneaks in a number of small bug fixes that I found along the way.NOTE: this does sneak in a small change to core by removing a (very) old deprecation warning in Block.
Changes proposed in this PR:
SequenceVar
component to contrib.cpfirst_in_sequence
,last_in_sequence
,before_in_sequence
,predecessor_to
, andno_overlap
expressions for SequenceVarsalternative
,spans
, andsynchronize
expressions for scheduling logicLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: