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如何为ConcurrentHashMap使用并设置适当的并发级别?   java泛型方法,运行时错误,   java在页面上显示加载的图像   java Paypal定期直接支付问题   java如何延迟重新绘制组件   JavaSpringBoot+Hibernate如何维护@Transient字段   java在其方法中获取关于类的信息   在java中将别名添加到枚举   java如何解决向google报告成绩时“需要重新连接客户端”的问题   清晰的java图像背景   java未找到适合JDateChooser的构造函数(字符串、字符串、字符)   java LRU缓存实现。某些测试用例的代码失败   if语句Java嵌套的if/Else条件   java JSoup“wrap”并非每次都按预期工作   Java Spring引导循环依赖于一个环境   ssl证书无法通过Java和IntelliJ连接到SOAP服务   带整数验证的Java扫描器   java在Flex中呈现具有动态列的datagrid   java Android:通过用户选择的选项将文件上载到服务器   子类中的java抛出错误、异常和运行时异常