Commit Graph

7 Commits

Author SHA1 Message Date
Jeremy Saklad 9671190059
Add BoneMarketModel.AddDivisionApproximateExponentiationEquality
This method combines two common operations, avoiding the need for
intermediate variables at the call site.
2021-10-16 10:22:31 -05:00
Jeremy Saklad 110f524f62
Update OR-Tools to v9.1
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.
2021-10-15 21:32:55 -05:00
Jeremy Saklad 1bf18fe8e1
Add BoneMarketModel.AddDivisionMultiplicationEquality
This method combines two common operations, avoiding the need for
intermediate variables at the call site.
2021-10-15 15:05:17 -05:00
Jeremy Saklad 46edfcb35b
Override CpModel.AddDivisionEquality
The overridden method supports enforcement literals using indirection.
2021-10-15 15:05:07 -05:00
Jeremy Saklad 6f0e0ac379
Add BoneMarketModel.AddIf method
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.
2021-10-15 15:04:37 -05:00
Jeremy Saklad 17add382ec
Replace BoneMarketModel.NewIntermediateBoolVar
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.
2021-10-15 15:04:37 -05:00
Jeremy Saklad 3d90d61deb
Replace helper functions with subclass
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.
2021-10-15 15:03:55 -05:00