Add function for querying attributes of solver model #247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new function
get_solver_attribute()
introduces a mechanism for querying properties of a solver model through the attribute interface. This extends the functionality of Linopy interface by allowing users to retrieve properties from mathematical model, variable attributes and attributes associated with solution quality -> and map this information to dimensions of a linopy problem.For now the functionality works with Gurobi interface. The list of attributes can be found here. NB some attributes are available at all times (e.g., the number of variables in the model), some are only populated at certain times (e.g., those related to the problems of a specific type).
The functionality can be extended to interfaces of other solvers if Linopy & PyPSA communities finds this useful.
The original idea driving this PR is to create convenient mechanism to retrieve & map to dimensions of an original linopy problem sensitivity information related to variables (SAObjLow, SAObjUp, RC) that is promising to be useful for both debugging and analysis for PyPSA applications.
Toy example: