PyPSA / linopy

Linear optimization with N-D labeled arrays in Python
https://linopy.readthedocs.io
MIT License
162 stars 44 forks source link

avoid using highs_bindings, they are not needed and are removed in 1.7.1.dev #264

Closed apfelix closed 6 months ago

apfelix commented 6 months ago

Mini change to get ObjSense.kMaximize directly from highspy instead of highspy.highs_bindings.

This will make linopy compatible with the dev version 1.7.1.dev1 of highspy, while keeping it compatible with the current stable version 1.5.3.

However, when running the tests, I noticed that all .mps tests fail for test/test_optimization.py::test_model_maximization, as the .mps file generated with 1.7.1.dev1 no longer flips the objective coefficients, but instead uses OBJSENSE MAX.

1.5.3 file:

NAME        
ROWS
 N  Obj     
 L  c0      
 L  c1      
COLUMNS
    x0        Obj       -1
    x0        c0        2
    x0        c1        4
    x1        Obj       -2
    x1        c0        6
    x1        c1        2
RHS
    RHS_V     c0        10
    RHS_V     c1        3
BOUNDS
 FR BOUND     x0      
 FR BOUND     x1      
ENDATA

1.7.1.dev1 file:

NAME        
OBJSENSE
  MAX
ROWS
 N  Obj     
 L  c0      
 L  c1      
COLUMNS
    x0        Obj       1
    x0        c0        2
    x0        c1        4
    x1        Obj       2
    x1        c0        6
    x1        c1        2
RHS
    RHS_V     c0        10
    RHS_V     c1        3
BOUNDS
 FR BOUND     x0      
 FR BOUND     x1      
ENDATA

As 1.7.1.dev1 is no stable version, I didn't adjust the code for this change.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.78%. Comparing base (ecbc962) to head (b5f40dc).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #264 +/- ## ========================================== - Coverage 88.94% 85.78% -3.16% ========================================== Files 15 15 Lines 3645 3645 Branches 856 856 ========================================== - Hits 3242 3127 -115 - Misses 279 403 +124 + Partials 124 115 -9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

FabianHofmann commented 6 months ago

@apfelix great that you look into this. Let's merge it and fix the other issue as soon as the stable version is out.