Reusing non-constant integer variables was causing constraints to
propagate in unintended ways, resulting in incorrect restrictions on the
solver's output.
This should not be an issue for constants, as they are already
restricted to one value.
Intermediate variables should not be necessary if the equivalent
expression is a constant or a variable with the same bounds.
This change reduces the total number of variables in the model.
The documentation of BoneMarketModel.NewIntermediateIntVar has been
tweaked to allow for any number of constraints.
For the sake of maintainability, it is very important the parameters and
results of the helper functions are spelled out explicitly.
Union type hints are being left until Python 3.10 is supported.
This function has been obsoleted by the ability to pass partial methods
as parameters to helper functions.
Use of this function has been replaced with partial methods accordingly.
In addition, the following code style has been applied: partial methods that
contain a nested partial method have the function arguments broken into
distinct lines. This means that the bottom partial method is formatted in the
same manner as a partial method without any nesting.
This function has been obsoleted by the ability to pass partial methods
as parameters to helper functions.
Use of this function has been replaced with partial methods accordingly.
This has allowed some intermediate variables to be removed entirely,
allowing for further simplification.
Intermediate integer variables can now be created for compatible partial
methods, which massively increases the expressiveness of each helper
function.
This change should allow the compound helper functions, such as
AddDivisionMultiplicationEquality, to be removed entirely. It will also
allow even the most complex buyers to avoid intermediate variables.
This update, despite ostensibly being a minor version, includes breaking
changes that must be accounted for.
Overflow is much more strictly checked, so the magnitude of certain
constants has been decreased.
CP-SAT's default number of workers has been changed to reflect the
default of this script. As such, the script no longer needs to change
that parameter unless a specific number of workers has been specified.
In light of the breaking changes, the OR-Tools version is now pinned at
9.1 instead of being permitted to use future minor versions.
This method allows a series of constraints to be applied all at once
using the same enforcement literal, which can substantially improve
readability and writability.
The replacement method, BoolExpression, accepts a
BoundedLinearExpression directly, and uses memoization to reuse Boolean
variables. This technique is unsuitable for other methods, as
constraints need to be applied separately, but in this case it is fine.
The new method is much easier to understand, and far easier to read at
call sites.
Variable names are generated from the expression, rather than being
explicitly specified.
The new subclass, BoneMarketModel, overrides CpModel's methods with
improvements such as default parameters and support for enforcement
literals.
This should allow substantial improvements to the readability of the
solver in the future.
In addition, various lists have been replaced with tuples where
appropriate.