-
Notifications
You must be signed in to change notification settings - Fork 29
Remove GLPK Dependency #52
Description
Problem statement
I have only started with this repo, so this could be a very naive view, but I'm not sure why we need to have both GLPK and CBC solvers in our system.
There's a lot of messy boilerplate code for switching between GLPK and CBC in the repo. Also, the need for GLPK seems to be the fundamental root cause of our cross-platform issues, because installing GLPK on Windows requires Windows-specific Python packages to be installed. Everything else is just python.
Proposed solution
Migration to CBC only (using PuLP package)
I propose that we use the PuLP python package for all of the underlying linear programming computations. The package uses the CBC solver by default. The best part is that pip install pulp installs the CBC solver on all platforms (Windows, macOS, and Linux).
The only reason we need to install the GLPK solver is here. We use it for generating the LP file that is then fed to the CBC solver. We could get rid of this step by generating the LP constraints using the Python PuLP API to read our data files. In fact, there is an official implementation that does this already - https://github.com/OSeMOSYS/OSeMOSYS_PuLP/blob/master/OSeMOSYS_PuLP.py.
By using the PuLP package, we completely abstract away the need to install and hunt down binaries in our code base.
Regression Testing
As a parallel line of work for this solution, we'd develop a set of numerical regression tests. Honestly, this is simpler than it sounds. It would just be a set of python scripts that compare two sets of results files and confirms that the values are all equal (within some numerical tolerance bounds).
We'd then run the following three implementations with the same sample input data (CLEWs.Demo.zip):
- GLPK only
- GLPK (to generate LP file) + CBC Solver
- CBC only (using PuLP package)
And then compare each pair with the numerical regression test scripts. Once the validity of the CBC only solver is confirmed, we merge the changes into main and have a much cleaner code base with a CBC only solver.
Acceptance criteria
- Searching for 'GLPK' and 'binary' within the code base should return nothing (because we'd be doing everything with CBC, and the binary resolution would all be taken care of by the PuLP python package).
The regression tests prove that the results of CBC only workflow are numerically equivalent to existing solver solutions.
Dependencies and constraints
- Requires the development of numerical regression testing scripts