reformat
This commit is contained in:
committed by
Corentin Le Molgat
parent
42e3414d5f
commit
91fe48478d
@@ -19,6 +19,7 @@ from ortools.init.python import init
|
||||
|
||||
|
||||
class InitTest(absltest.TestCase):
|
||||
|
||||
def test_logging(self):
|
||||
print("test_logging")
|
||||
init.CppBridge.init_logging("pywrapinit_test.py")
|
||||
|
||||
@@ -416,7 +416,7 @@ class VarArraySolutionPrinter(cp_model.CpSolverSolutionCallback):
|
||||
print(line)
|
||||
|
||||
|
||||
def index_first_solution_true_sample_sat():
|
||||
def index_of_first_bool_at_true_sample_sat():
|
||||
"""Compute the index of the first Boolean variable set to true."""
|
||||
|
||||
# Model.
|
||||
@@ -446,15 +446,14 @@ def index_first_solution_true_sample_sat():
|
||||
|
||||
# Force the solver to follow the decision strategy exactly.
|
||||
solver.parameters.search_branching = cp_model.FIXED_SEARCH
|
||||
# Enumerate all solutions.
|
||||
solver.parameters.enumerate_all_solutions = True
|
||||
|
||||
# Search and print out all solutions.
|
||||
solver.parameters.enumerate_all_solutions = True
|
||||
solution_printer = VarArraySolutionPrinter(index, bool_vars)
|
||||
solver.solve(model, solution_printer)
|
||||
|
||||
|
||||
index_first_solution_true_sample_sat()
|
||||
index_of_first_bool_at_true_sample_sat()
|
||||
```
|
||||
|
||||
This displays the following:
|
||||
|
||||
@@ -33,7 +33,7 @@ class VarArraySolutionPrinter(cp_model.CpSolverSolutionCallback):
|
||||
print(line)
|
||||
|
||||
|
||||
def index_first_solution_true_sample_sat():
|
||||
def index_of_first_bool_at_true_sample_sat():
|
||||
"""Compute the index of the first Boolean variable set to true."""
|
||||
|
||||
# Model.
|
||||
@@ -63,12 +63,11 @@ def index_first_solution_true_sample_sat():
|
||||
|
||||
# Force the solver to follow the decision strategy exactly.
|
||||
solver.parameters.search_branching = cp_model.FIXED_SEARCH
|
||||
# Enumerate all solutions.
|
||||
solver.parameters.enumerate_all_solutions = True
|
||||
|
||||
# Search and print out all solutions.
|
||||
solver.parameters.enumerate_all_solutions = True
|
||||
solution_printer = VarArraySolutionPrinter(index, bool_vars)
|
||||
solver.solve(model, solution_printer)
|
||||
|
||||
|
||||
index_first_solution_true_sample_sat()
|
||||
index_of_first_bool_at_true_sample_sat()
|
||||
|
||||
@@ -19,6 +19,7 @@ from ortools.util.python import sorted_interval_list
|
||||
|
||||
|
||||
class SortedIntervalListTest(absltest.TestCase):
|
||||
|
||||
def testCtorAndGetter(self):
|
||||
bool_domain = sorted_interval_list.Domain(0, 1)
|
||||
self.assertEqual(2, bool_domain.size())
|
||||
|
||||
Reference in New Issue
Block a user