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

Add support of JuMP variable/constraint names on GAMS level #12

Closed
MartinBonde opened this issue Jan 20, 2022 · 6 comments
Closed

Add support of JuMP variable/constraint names on GAMS level #12

MartinBonde opened this issue Jan 20, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@MartinBonde
Copy link

I am sending a JuMP model to CONOPT4 using GAMS.jl and get an error/warning:
** Error in Square System: A variable tries to exceed its bound.

This is perfectly familiar and I get more information by looking in the generated moi.lst file
to find out which variable is the culprit:

**** ERRORS/WARNINGS IN VARIABLE x382
1 error(s): The variable tries to exceed its bound.

Is there any way of identifying what “x382” refers to in the above?

miles.lubin on discourse suggested opening an issue since "JuMP does provide the capability to pass variable names down to the solver."

@renkekuhlmann
Copy link
Member

Yeah, there is currently no feature to look up the autogenerated names. I agree that it would be useful to use the JuMP variable names on the GAMS level. I'll look into it. Thanks for the feature request.

@renkekuhlmann renkekuhlmann self-assigned this Jan 21, 2022
@renkekuhlmann renkekuhlmann added the enhancement New feature or request label Jan 21, 2022
@renkekuhlmann renkekuhlmann changed the title Identifying variables in GAMS.jl errors (how do I look up JuMP variables from auto-generated name x..) Add support of JuMP variable/constraint names on GAMS level Jan 21, 2022
@renkekuhlmann
Copy link
Member

I added writing the variable and constraint (only linear and quadratic) names that the user passes to the generated GAMS model with v0.3.0 - along with some other updates. Note however, that GAMS is very restrictive when it comes to variable naming and that something like x[1,2] or β is not allowed in GAMS source. Therefore, forbidden characters are replaced by _. I can then happen that the name is invalid because it will start with _, e.g. if you are using unicode symbols. In that case GAMS.jl should fall back to generic names. I hope this solution is fine for debugging. The generated files were never meant to be beautiful 😉

Version 0.3.0 should be available in a moment.

@MartinBonde
Copy link
Author

Thanks! That should work except for the issue with not just illegal characters, but also case insensitivity of GAMS. Would it be possible to access some mapping (e.g. a dict) between the two? The users can easily do a search and replace of any error message or LST file if needed.

@renkekuhlmann
Copy link
Member

Right, I forgot about this. I guess I should revert back to the generated names then, because otherwise the possibility of provoking GAMS compilation errors is too high. Instead, I will introduce Attributes in order to get the mapping, e.g.:

MOI.get(model, GAMS.GeneratedVariableName(), x[1,1])
MOI.get(model, GAMS.OriginalVariableName("x1"))

@renkekuhlmann renkekuhlmann reopened this Jan 27, 2022
@renkekuhlmann
Copy link
Member

Okay, done with the latest commit, see https://github.com/GAMS-dev/gams.jl#gams-names-vs-jump-names. Version 0.3.1 will be available soon.

@MartinBonde
Copy link
Author

Looks great! I did not realize there was an issue with naming restrictions when I opened the issue, but this seems like a good solution. I look forward to trying it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants