python: Fix tests when SCIP and COINOR are disabled (#3261)

This commit is contained in:
Corentin Le Molgat
2022-06-03 17:09:29 +02:00
parent fd9820265d
commit 1ba0177af5
32 changed files with 91 additions and 132 deletions

View File

@@ -116,8 +116,9 @@ def AggregateItemCollectionsOptimally(item_collections, max_num_collections,
- and its associated "num_selections" is the number of times it was
selected.
"""
solver = pywraplp.Solver('Select',
pywraplp.Solver.SCIP_MIXED_INTEGER_PROGRAMMING)
solver = pywraplp.Solver.CreateSolver('SCIP')
if not solver:
return []
n = len(ideal_item_ratios)
num_distinct_collections = len(item_collections)
max_num_items_per_collection = 0
@@ -238,10 +239,12 @@ def solve_appointments(_):
print()
print('%d installations planned' % installed)
for a in demand:
name = a[1]
per_type = installed_per_type[name]
print((' %d (%.2f%%) installations of type %s planned' %
(per_type, per_type * 100.0 / installed, name)))
name = a[1]
per_type = installed_per_type[name]
if installed != 0:
print(f' {per_type} ({per_type * 100.0 / installed}%) installations of type {name} planned')
else:
print(f' {per_type} installations of type {name} planned')
# [END print_solution]

View File

@@ -705,8 +705,9 @@ def steel_mill_slab_with_mip_column_generation(problem):
# create model and decision variables.
start_time = time.time()
solver = pywraplp.Solver('Steel',
pywraplp.Solver.SCIP_MIXED_INTEGER_PROGRAMMING)
solver = pywraplp.Solver.CreateSolver('SCIP')
if not solver:
return
selected = [
solver.IntVar(0.0, 1.0, 'selected_%i' % i) for i in all_valid_slabs
]