Skip to content

Commit 1649a0b

Browse files
lkstrpolivierjuanpre-commit-ci[bot]
authored
Export variable and constraint names in LP files (#413)
* Export variable and constraints names in LP files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update io.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update io.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Export variable and constraints names in LP files and add new lp-debug io_api * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove the lp-debug io_api and replace it with parameter. Extend it to polars export too * added variable names with direct solver and mps. CBC and GLPK are incompatible with variables names. MindOpt untested since my license is not functioning * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix ruff errors * rename argument * add release notes * fix merge * fix merge * fix merge * fix types and some structure --------- Co-authored-by: Olivier JUAN <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Olivier JUAN <[email protected]>
1 parent 58a28b5 commit 1649a0b

File tree

7 files changed

+663
-174
lines changed

7 files changed

+663
-174
lines changed

doc/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Version 0.4.4
1515
* Solution files that following a different naming scheme of variables and constraints using more than on initial letter in the prefix (e.g. `col123`, `row456`) are now supported.
1616
* GLPK solver is always called with the `--freemps` option instead of the `--mps` when using the Solver API to solve an external MPS file. `--mps` is for the older fixed-column MPS format that is rarely used nowadays. Almost all fixed MPS files can be parsed by the free MPS format.
1717

18+
* Added extra argument in io methods `explicit_coordinate_names` to allow for export of
19+
variables and constraints with explicit coordinate names.
20+
1821
Version 0.4.3
1922
--------------
2023

linopy/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ def set_int_index(series: pd.Series) -> pd.Series:
4343
"""
4444
Convert string index to int index.
4545
"""
46+
4647
if not series.empty and not pd.api.types.is_integer_dtype(series.index):
4748
cutoff = count_initial_letters(str(series.index[0]))
48-
series.index = series.index.str[cutoff:].astype(int)
49+
try:
50+
series.index = series.index.str[cutoff:].astype(int)
51+
except ValueError:
52+
series.index = series.index.str.replace(".*#", "", regex=True).astype(int)
4953
return series
5054

5155

0 commit comments

Comments
 (0)