GLPKMEX is a MATLAB MEX Interface for the GLPK Library developed by Andrew Makhorin.
GLPKMEX is developed by Nicolo' Giorgetti (Email: giorgetti at ieee.org).
GLPK is currently being maintained by Niels Klitgord (Email: niels at bu.edu).
This version of GLPK MEX Generator is maintained by Royi Avital.
It is based on glpkmex
by Benoit Legat.
It was updated to support the 4.65
and 5.0
versions of GLPK (Latest as of March 2022).
This MEX Generator builds a Stand Alone MEX File by linking to the static library of GLPK.
This means the MEX file can be transferred to other computers and should work there.
In order to use this generator download the repository and extract it any place.
Then open a MATLAB session and navigate MATLAB to the folder the repository was extracted to and follow the instructions.
- A working MATLAB installation with
MEX
compiler set. - A Compiler:
- Windows: MSVC 2017, MSVC 2019, MSVC 2022.
- Linux: GCC 6.3 and above.
- Open the
MakeMexWindows.m
file. - Go to the
User Settings
section and edit themsvcVersion
according to the predefined constants. - Update
mexCompFlags
for MEX Compilation flags. It won't have any significant performance gain as most of work is done in the GLPK Library. In case of being unsure, just setuseCompFlags = OFF;
(Default). - Set the MEX API by
mexApi
. - Run the script. At the end it should verify the generated
MEX
file is working.
- Open the
MakeMexLinux.m
file. - Go to the
User Settings
section and edit thecCompFlags
. For most cases the best choice is-march=native
.
I'd also recommend using-O2
. I haven't checked-fast-math
. In case of being unsure, just setuseCompFlags = OFF;
(Default). - Update
mexCompFlags
for MEX Compilation flags. It won't have any significant performance gain as most of work is done in the GLPK Library. In case of being unsure, just setuseCompFlags = OFF;
(Default). - Set the MEX API by
mexApi
. - Run the script. At the end it should verify the generated
MEX
file is working.
The MEX API, set by mexApi
has importance related to the size of problems solved.
The user should set it to either {MEX_API_R2018A, MEX_API_R2017B, MEX_API_LARGE_ARRAY}
.
In case of old MATLAB Installation, or compiling for others who might have older MATLAB one could try MEX_API_COMPATIBLE_ARRAY
.
Yet using MEX_API_COMPATIBLE_ARRAY
will limit the problems to have roughly 2^31
elements. Check MATLAB documentation for more information.
TBD
- The procedure was tested on:
- Windows 10 64 Bit with MSVC 2017 Professional with MATLAB R2020a.
- Windows 10 64 Bit with MSVC 2019 Professional with MATLAB R2020a.
- Windows 10 64 Bit with MSVC 2019 Community with MATLAB R2020a.
- Windows 10 64 Bit with MSVC 2022 Professional with MATLAB R2022a.
- Linux Mint 19.3 (Based on Ubuntu 18.04 LTS) with GCC 7.5.0 with MATLAB R2020a.
- Users with different Operating System (Specifically macOS), Please assist with issues.