Merge branch 'master' of github.com:google/or-tools

This commit is contained in:
Laurent Perron
2021-04-14 14:46:48 +02:00
2 changed files with 31 additions and 3 deletions

View File

@@ -671,11 +671,33 @@ class CpModelTest(unittest.TestCase):
model = cp_model.CpModel()
# Creates the variables.
v0 = model.NewBoolVar("buggyVarIndexToVarProto")
v1 = model.NewBoolVar("v1")
v0 = model.NewBoolVar('buggyVarIndexToVarProto')
v1 = model.NewBoolVar('v1')
self.assertEqual(model.VarIndexToVarProto(0).name, v0.Name())
def testWrongBoolEvaluation(self):
print('testWrongBoolEvaluation')
model = cp_model.CpModel()
# Creates the variables.
v0 = model.NewIntVar(0, 10, 'v0')
v1 = model.NewIntVar(0, 10, 'v1')
v2 = model.NewIntVar(0, 10, 'v2')
if v0 == 2:
print('== passed')
if v0 >= 3:
print('>= passed')
model.Add(v2 == min(v0, v1))
print('min passed')
if v0:
print('bool passed')
if __name__ == '__main__':
unittest.main(verbosity=2)

View File

@@ -1180,7 +1180,13 @@ KnapsackSolver::~KnapsackSolver() {}
void KnapsackSolver::Init(const std::vector<int64_t>& profits,
const std::vector<std::vector<int64_t>>& weights,
const std::vector<int64_t>& capacities) {
const std::vector<int64_t>& capacities) {
for (const std::vector<int64_t>& w : weights) {
CHECK_EQ(profits.size(), w.size())
<< "Profits and inner weights must have the same size (#items)";
}
CHECK_EQ(capacities.size(), weights.size())
<< "Capacities and weights must have the same size (#bins)";
time_limit_ = absl::make_unique<TimeLimit>(time_limit_seconds_);
is_solution_optimal_ = false;
additional_profit_ = 0LL;