Add support for IntVar op constant RoutingSolver constraints, and remaining ops - #92
Open
willbryant wants to merge 2 commits into
Open
willbryant wants to merge 2 commits into
willbryant wants to merge 2 commits into
Conversation
willbryant
force-pushed
the
constant_constraints
branch
from
September 15, 2026 00:15
ee95a8f to
cd4210d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
or-tools supports both
IntVar op IntVarandIntVar op int64_tversions of each constraint-factory method. This PR implements that, using a template function to avoid having to write out the ops twice.It also fills in the remaining ops defined in
Expressionand already supported byCpModel.This is the warmup to what I personally need, which is
IntVar - IntVar <= const, or more broadly arbitraryExpressionsupport inRoutingSolver#add, which will be in the final PR.That is supported in the Python wrapper, but not yet this Ruby wrapper.
NB. I've chosen to be explicit about
Constant, becauseIntVaralso responds-to#value, making it hard to duck type. Testing the convertibility of the argument toIntVarfirst is an option, but becomes quite awkward in that last PR when we support otherExpressions. Letting RICE choose using C++ method overloading was the other option, which I tried in my first draft, but again that becomes problematic when trying to addExpressionsupport as there is no type mapping (IntExpr*is the equivalent, but it isn't really possible to convert betweenExpressionandIntExpr*using RICE because you need access to theSolverto register the expression, which doesn't fit the RICE type-conversion idiom).tl;dr handling
Constantspecifically is best.