opl的python接口。

doopl的Python项目详细描述


欢迎使用ibm®opl connector for python。 在apache许可证v2.0下授权。

有了这个库,您可以快速轻松地将优化的能力添加到 您的python应用程序。您可以使用opl语言和ide对问题建模,并通过python/pandas/sql炼金术输入/输出将其集成到python中。

使用cplex解决问题需要在您的计算机上安装ibm®ilog cplex optimization studio v12.8.0。

安装库

pip install doopl

获取示例

获取IBM®ILOG CPLEX Optimization Studio版本

许可证

此库在2004年1月的ApacheLicense2.0版本下提供(请参阅license.txt)。

起点

这个api非常简洁。 必须在路径/ld_library_path中包含opl二进制文件,或者 dyld_library_path,取决于您的平台。它们位于 <cplex_studio_dir>/opl/bin/<platform>其中:

  • ^{tt2}$ is the installation directory of CPLEX 12.8
  • ^{tt3}$ is your plaform (OPL nomenclature, that is ^{tt4}$, ^{tt5}$ or ^{tt6}$)

以下是这些功能的小结:

  • Inputs can be tuple lists, panda’s dataframe, sql alchemy fetch statements.
  • Generate, solve and get output tuplesets as panda’s dataframe
  • Get the CPLEX problem statistics and quality metrics for the solution
  • Convert all integer variables to floating point variables and vice-versa.
  • Run the conflict/relaxation mechanism.
  • Call the ‘RunSeed’ diagnosis for CPLEX/CPO based problems.

这些特性中的每一个都用简单的例子来演示。

下面是一个开始使用api的小示例:

from doopl.factory import *

# Create an OPL model from a .mod file
with create_opl_model(model="file.mod") as opl:
    # tuple can be a list of tuples, a pandas dataframe...
    opl.set_input("TupleSet1", tuples)

    # Generate the problem and solve it.
    opl.run()

    # Get the names of post processing tables
    print("Table names are: "+ str(opl.output_table_names))

    # Get all the post processing tables as dataframes.
    for name, table in iteritems(opl.report):
        print("Table : " + name)
        for t in table.itertuples(index=False):
            print(t)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android解析JSON数据显示重复结果   Java图像写入   java将JSON对象作为对象而不是字符串写入文件   java获取servlet中的选定下拉列表值   java PowerMockito 1.6.0验证Mockito扩展API中的私有最终重载方法   java将地图图像更改为节点和边   java如何更改IntelliJ IDEA方案和窗格主题?   如何在java中解析文本文件?   当我使用Selenium IDE时,java WebDriver无法找到WebElement,而同样的css在哪里工作良好   java Android无线遥控摄像机   Go、Java和C#中数组的最大长度是多少?   java Guava的@Subscribe事件总线可见性   java如何将带有服务调用的循环重构为流?   java如何处理自定义Hamcrest匹配器中的异常?   java在Android中保存GUI状态   基于时间戳的java检索卡夫卡主题中的偏移量   图像构造函数中的java差异   java RxAndroidBle如何从多个服务读取通知?