Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test usability of HiGHS solver through GAMSModel #472

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions ixmp/model/gams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions ixmp/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down