Skip to main content
 首页 » 编程设计

python之glpk.LPX 向后兼容

2025年05月04日10zhujiabin

较新版本的 glpk 没有 LPX api,而旧版软件包需要它。 我如何将旧包(如 COBRA )与新版本的 glpk 一起使用?

请注意,COBRA 可用于 MATLAB 和 Python。两者都需要 glpk 和 LPX api,我想同时使用两者。

请您参考如下方法:

理想情况下,您应该切换到使用新 API 的版本。它已经存在多年了。如果那不是一个选项,那么 V4.53 的更改日志中的以下条目指向正确的方向

    * examples/oldapi/lpx.h, examples/oldapi/lpx.c 
    A set of routines that simulate the old GLPK API (as defined 
    in 4.48) were added. Thanks to Jan Engelhardt <jengelh@inai.de> 
    for suggestion. 

在源版本的目录 examples/oldapi 中,您可以找到所需的一切。自述文件摘录:

The program module in this subdirectory contains an implementation of 
the old GLPK API as it was defined in GLPK 4.48. 
 
To compile an existing project using the old GLPK API you need to add 
to the project two files lpx.h and lpx.c.