Skip to content

Modified _parse_gdx_results in GAMS.py to replace _parse_special_value and Updated Import Statement #3642

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AnhTran01
Copy link

Fixes #3624

Summary/Motivation:

When parsing the results of a model after it has been solved, the level and dual value are obtained through a series of if statements in _parse_special_values that may cause slowdowns. This PR added GAMS existing functions to handle data parser for these special values in _parse_gdx_results.

Changes proposed in this PR:

  • Replaced _parse_special_values with GAMS special value parser in _parse_gdx_results.
  • Updated attempt_import to have fallback to pre-GAMS-45.0 API if gams.core.gdx is not available.

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@blnicho blnicho moved this from Todo to Review In Progress in July 2025 Release Jun 24, 2025
@blnicho blnicho requested a review from jsiirola June 24, 2025 18:39
Comment on lines 42 to +43
from pyomo.common.dependencies import attempt_import
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a hard dependency on numpy. Importing numpy from dependencies will keep this as a "soft" dependency:

Suggested change
from pyomo.common.dependencies import attempt_import
import numpy as np
from pyomo.common.dependencies import attempt_import, numpy as np

It will still make numpy a hard dependency if you are going to use GAMS, but that is OK (although GAMS's available() should probably check both numpy_available and gdxcc_available)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review In Progress
Development

Successfully merging this pull request may close these issues.

Updating the Import Statement to Use GAMS new API
2 participants