diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 8df87cf6e..48685a2a5 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -76,7 +76,7 @@ jobs: - uses: iiasa/actions/setup-gams@main with: - version: 25.1.1 + version: 41.5.0 - name: Set RETICULATE_PYTHON # Use the environment variable set by the setup-python action, above. diff --git a/ixmp/model/gams.py b/ixmp/model/gams.py index 713f2c413..6cfbd51f5 100644 --- a/ixmp/model/gams.py +++ b/ixmp/model/gams.py @@ -167,6 +167,7 @@ class GAMSModel(Model): "out_file": str(Path("{cwd}", "{model_name}_out.gdx")), "solve_args": ['--in="{in_file}"', '--out="{out_file}"'], # Not formatted + "LP": None, "gams_args": [], "check_solution": True, "comment": None, @@ -252,6 +253,8 @@ def run(self, scenario): # Input and output file names self.in_file = Path(self.format_option("in_file")) self.out_file = Path(self.format_option("out_file")) + # LP solver; only pass if given + self.solve_args.extend([f"LP={self.LP}"] if self.LP else []) # Assemble the full command: executable, model file, model-specific arguments, # and general GAMS arguments diff --git a/ixmp/tests/test_model.py b/ixmp/tests/test_model.py index 8187decff..ef2da09b9 100644 --- a/ixmp/tests/test_model.py +++ b/ixmp/tests/test_model.py @@ -122,13 +122,19 @@ def test_filename_invalid_char(self, dantzig, char): dict(comment=None), dict(equ_list=None, var_list=["x"]), dict(equ_list=["demand", "supply"], var_list=[]), + dict(LP="HiGHS"), ], - ids=["null-comment", "null-list", "empty-list"], + ids=["null-comment", "null-list", "empty-list", "HiGHS"], ) - def test_GAMSModel_solve(test_data_path, dantzig, kwargs): + def test_GAMSModel_solve(self, dantzig, kwargs): """Options to GAMSModel are handled without error.""" dantzig.clone().solve(**kwargs, quiet=True) + def test_solve_highs(self, capfd, test_data_path, dantzig): + dantzig.clone().solve(LP="HiGHS") + captured = capfd.readouterr() + assert "HiGHS run time" in captured.out + def test_error_message(self, test_data_path, test_mp): """GAMSModel.solve() displays a user-friendly message on error.""" # Empty Scenario