forked from airbus/discrete-optimization
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Enforce cffi>=1.17 (updated for python 3.12, avoid weird errors for dependencies relying on C code) - Update time limits to avoid errors with ubuntu + python 12: It seems ortools gets slower in its latest release 9.11 on ubuntu... - Fix LP_MRCPSP_GUROBI for python 3.12: we have a crash when using gurobi.Model.addConstrs with a quicksum on a list rather than on a generator. In other words, we need to get rid of []. See https://support.gurobi.com/hc/en-us/community/posts/28192464443281-model-addConstrs-breaking-sometimes-after-Python-version-change for more details. - Add a test dedicated to LP_MRCPSP_GUROBI.
- Loading branch information
Showing
6 changed files
with
65 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2022 AIRBUS and its affiliates. | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import pytest | ||
|
||
from discrete_optimization.generic_tools.cp_tools import ParametersCP | ||
from discrete_optimization.rcpsp.rcpsp_parser import get_data_available, parse_file | ||
from discrete_optimization.rcpsp.solver.cpsat_solver import CPSatRCPSPSolver | ||
from discrete_optimization.rcpsp.solver.rcpsp_lp_solver import LP_MRCPSP_GUROBI | ||
|
||
try: | ||
import gurobipy | ||
except ImportError: | ||
gurobi_available = False | ||
else: | ||
gurobi_available = True | ||
|
||
|
||
@pytest.mark.skipif(not gurobi_available, reason="You need Gurobi to test this solver.") | ||
@pytest.mark.parametrize( | ||
"model", | ||
["j301_1.sm", "j1010_1.mm"], | ||
) | ||
def test_gurobi(model): | ||
files_available = get_data_available() | ||
file = [f for f in files_available if model in f][0] | ||
rcpsp_problem = parse_file(file) | ||
solver = LP_MRCPSP_GUROBI(problem=rcpsp_problem) | ||
|
||
result_storage = solver.solve() | ||
|
||
# test warm start | ||
parameters_cp = ParametersCP.default() | ||
parameters_cp.time_limit = 20 | ||
start_solution = ( | ||
CPSatRCPSPSolver(problem=rcpsp_problem) | ||
.solve(parameters_cp=parameters_cp) | ||
.get_best_solution_fit()[0] | ||
) | ||
|
||
# first solution is not start_solution | ||
assert result_storage[0][0].rcpsp_schedule != start_solution.rcpsp_schedule | ||
|
||
# warm start at first solution | ||
solver = LP_MRCPSP_GUROBI(problem=rcpsp_problem) | ||
solver.init_model() | ||
solver.set_warm_start(start_solution) | ||
# force first solution to be the hinted one | ||
result_storage = solver.solve() | ||
assert result_storage[0][0].rcpsp_schedule == start_solution.rcpsp_schedule |
File renamed without changes.