sasoptpy:python的sas优化接口

sasoptp的Python项目详细描述


Python的SAS优化接口

sasoptpy是一个python包,为SAS Viya和sas/或优化求解器提供建模接口。 它为用户提供了一种快速部署优化模型并使用cas操作解决它们的方法。

sasoptpy可以处理线性、混合整数线性和非线性优化问题。 用户可以从本机python结构(如字典、元组和列表)中获益,以定义优化问题。 sasoptpy广泛使用Pandas结构。

在引擎盖下,sasoptpy使用 swat package通信 sas viya和uses saspy package与SAS 9.4通信 装置。

sasoptpy是SAS优化求解器的接口。支票 SAS/ORPROC OPTMODEL 有关SAS提供的优化工具和 SAS中的模型优化问题。

要求

要使用sasoptpy,您需要有:

安装

sasoptpy可以从project releases页安装。 下载发行版并使用pip

pip install vX.X.X.tar.gz

其中vX.X.X是要安装的版本。

或者,使用:

   pip install https://github.com/sassoftware/sasoptpy/archive/vX.X.X.tar.gz

开始

示例

sasoptpy demo gif

fromswatimportCASimportsasoptpyasso# Create a CAS Sessions=CAS(hostname='host',port=12345)# Create an empty optimization modelm=so.Model('demo',session=s)# Add variablesx=m.add_variable(vartype=so.CONT,name='x')y=m.add_variable(vartype=so.INT,name='y')# Set objective functionm.set_objective(2*x+y,sense=so.MAX,name='obj')# Add constraintsm.add_constraint(x+2*y<=4.5,name='c1')m.add_constraint(3*x+y<=5.5,name='c2')# Solve the optimization problemresult=m.solve()# Print and list variable valuesprint(so.get_solution_table(x,y))print('Optimal objective value:',m.get_objective_value())

输出

NOTE: Initialized model demo.
NOTE: Added action set'optimization'.
NOTE: Converting model demo to OPTMODEL.
NOTE: Submitting OPTMODEL codes to CAS server.
NOTE: Problem generation will use 32 threads.
NOTE: The problem has 2 variables (2 free, 0 fixed).
NOTE: The problem has 0 binary and 1 integer variables.
NOTE: The problem has 2 linear constraints (2 LE, 0 EQ, 0 GE, 0 range).
NOTE: The problem has 4 linear constraint coefficients.
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).
NOTE: The OPTMODEL presolver is disabled for linear problems.
NOTE: The initial MILP heuristics are applied.
NOTE: The MILP presolver value AUTOMATIC is applied.
NOTE: The MILP presolver removed 0 variables and 1 constraints.
NOTE: The MILP presolver removed 2 constraint coefficients.
NOTE: The MILP presolver modified 0 constraint coefficients.
NOTE: The presolved problem has 2 variables, 1 constraints, and 2 constraint coefficients.
NOTE: The MILP solver is called.
NOTE: The parallel Branch and Cut algorithm is used.
NOTE: The Branch and Cut algorithm is using up to 32 threads.
             Node   Active   Sols    BestInteger      BestBound      Gap    Time
                0123.3333333      4.2000000   20.63%       00134.0000000      4.0000000    0.00%       00034.0000000      4.0000000    0.00%       0
NOTE: Optimal.
NOTE: Objective=4.
NOTE: The CAS table 'solutionSummary' in caslib 'CASUSERHDFS(casuser)' has 18 rows and 4 columns.
NOTE: The CAS table 'problemSummary' in caslib 'CASUSERHDFS(casuser)' has 20 rows and 4 columns.
NOTE: The CAS table 'primal' in caslib 'CASUSERHDFS(casuser)' has 2 rows and 6 columns.
NOTE: The CAS table 'dual' in caslib 'CASUSERHDFS(casuser)' has 2 rows and 4 columns.
     x    y
11.5  1.0
Optimal objective value: 4.0

资源

SAS协会版权所有

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

推荐PyPI第三方库


热门话题
java Intellij通过方法中的包查找用法   java中VS代码和打包命名的问题   将java CMS功能集成到具有高度动态内容的网站(Lucene/Mysql/Nosql)的策略   oracle的java类强制转换异常。jdbc。驾驶员OracleConnection   字节码向JVM添加上指令   如何在抽象类中执行java方法?   java是否可以在apache访问日志中排除指定的GET参数?(作者:W7开发环境)   java如何获取已安装音频播放器的列表?   尝试向HS学生展示如何使用Java访问MS数据库   使用正则表达式java对给定行中的特定字符串进行计数   java JOOQ Select查询中的Select计数   方法Java,如何从二维双精度数组中找到特定值?   获取图像URL的java正则表达式   java在切换到新的窗口驱动程序后找不到元素