Presentation Title By Author 2014 The MathWorks, Inc. 1
MATLAB 在 IT 系统中的大规模应用发布 魏奋,MathWorks 中国 应用工程师团队经理 2
什么是应用发布 (Application Deployment)? 和没有 MATLAB 的人分享 MATLAB 程序 免版税的发布 MATLAB apps 可直接提供给其他 MATLAB 的用户 3
MATLAB Compiler 的功能 把 MATLAB 程序打包作为独立应用程序或共享库 打造专业的软件与定制安装, 图标和启动画面 知识产权加密 A deployed application created with MATLAB Compiler 4
独立应用程序的典型流程 Application author 1.) 开发算法 2.) 定义图形化界面 3.) 用 MATLAB Compiler 打包应用程序 4.) 把程序安装包交付用户 用户安装程序 并且在桌面运行 5
应用程序的定制化 启动画面 图标 Metadata 从 Windows 开始菜单安装, 访问和添加 / 删除应用程序 安装画面 6
最终客户看到一个专业的应用软件 安装界面 开始菜单中的应用程序 开始画面 图标 7
MATLAB Builder 产品 生成外接程序, 组件和库与 Microsoft Excel,.NET, and Java 集成 支持网络技术, 如 ASP.NET, SOAP, XML, JavaScript, and HTML 通过 Java RMI and.net remoting 可扩展 MATLAB Compiler MATLAB Builder EX MATLAB Builder JA MATLAB Builder NE.exe.dll Excel Java Web COM.NET 8
集成应用的典型流程 Application author Integrator External Development Environment (C, C++,.NET, Java) 1.) 开发 MATLAB 算法 2.) 用 MATLAB Compiler 打包组件库 3.) 使用外部的开发环境来开发集成的应用程序, 包括用户界面 4.) 最终产品交付用户 9
MATLAB Compiler 与 MCR Toolboxes 3 1 MATLAB Desktop End-User Machine 2 MATLAB Compiler.exe 10
部署到一系列的应用平台 功能扩展, 以支持桌面,Web 或企业应用程序 MATLAB Production Server TM 提供了扩展到高安全要求的企业级应用程序的最佳途径 11
MATLAB Production Server 直接将 MATLAB 程序部署到生产环境 集中管理多个 MATLAB 程序和运行时库 ( 即 MCR) 版本 无需重新启动服务器自动部署更新 可扩展和可靠性 服务大量并发请求 增加容量或冗余服务器 MATLAB Production Server(s) 与网络, 数据库和应用服务器共同使用 轻量级的客户端库分离 MATLAB 处理 使用原生数据类型访问 MATLAB 程序 Web Server(s) HTML XML Java Script 12
与 IT 系统集成 MATLAB Compiler Web Applications Web Server MATLAB Production Server Portfolio Optimization Excel Desktop Applications Application Server Pricing Risk Analytics Database Server 13
MATLAB Production Server 的定义 在企业级架构上运行打包的 MATLAB 程序 MATLAB Production Server.NET Request Broker & Program Manager 服务器软件 管理打包的 MATLAB 程序和 worker pool 运行时库 MATLAB Compiler Runtime (MCR) 轻量级的客户端库 (.NET and Java) 请求的 MATLAB 程序 ( 函数 ) 14
大规模发布的工作流程 Development MATLAB Developer Algorithm MATLAB Compiler Enterprise Application Developer Web Application CTF MATLAB Production Server Client Library Function Call Production. Web Application Client Library MATLAB Production Server 15
Client Library( 客户端库 ) 要求运行 MATLAB 生产服务器的 MATLAB 程序 MATLAB Production Server.NET Request Broker & Program Manager 目前有两个库.NET Java MathWorks.MATLAB.ProductionServer.Client.dll mps_client.jar 基于 HTTP 或 HTTPS 通信协议.NET 和 Java 数据类型与 MATLAB 数据类型的自动转换 动态调用 API 18
函数调用 Enterprise Application MATLAB Production Server MWHttpClient object HTTP(S) Request Broker & Program Manager Calculation Process Calculation Process Worker Pool 19
集成用例 (Java) Reference client library Define function signature/interface Define server and CTF url Call function to be run MATLAB Function function price = pricecalc(maturity_value, coupon_yield, interest_rate, num_payments) end C = coupon_yield; N = num_payments; i = interest_rate; M = maturity_value; price = C * ( (1 - (1 + i)^-n) / i ) + M * (1 + i)^-n; Enterprise Application import com.mathworks.mps.client.mwclient; import com.mathworks.mps.client.mwhttpclient; import com.mathworks.mps.client.matlabexception; interface BondTools { double pricecalc(double maturityvalue, double couponyield, double interestrate, double numpayments) throws IOException, MATLABException; } MWClient client = new MWHttpClient() double maturityvalue; double couponyield; double interestrate; double numpayments BondTools bondtool = client.createproxy<bondtools>(new URL("http://toolserve.mathworks.com:9910/BondToolsPkg"), BondTools.class); double price = bondtool.pricecalc(maturityvalue, couponyield, interestrate, numpayments); client.close(); 22
动态调用 API (Java) Define signatures and function at run-time No need to define interface Define url using MWInvokable and createcomponentproxy method Call invoke method and pass function name and parameters Interoperate with static API and CTFs Enterprise Application import com.mathworks.mps.client.mwclient; import com.mathworks.mps.client.mwhttpclient; import com.mathworks.mps.client.matlabexception; interface BondTools { double pricecalc(double maturityvalue, double couponyield, double interestrate, double numpayments) throws IOException, MATLABException; } MWClient client = new MWHttpClient() double maturityvalue; double couponyield; double interestrate; double numpayments BondTools MWInvokable bondtool = client.createproxy<bondtools>(new = client.createcomponentproxy(new URL("http://toolserve.mathworks.com:9910/BondToolsPkg"), URL("http://toolserve.mathworks.com:9910/BondToolsPkg")); BondTools.class); double price = bondtool.invoke( pricecalc, bondtool.pricecalc(maturityvalue, maturityvalue, couponyield, couponyield, interestrate, interestrate, numpayments); numpayments); client.close(); 23
桌面应用 从 Microsoft Excel 里调用 MATLAB 生产服务器的应用程序 MATLAB Builder EX 产生 CTF 和插件 支持 32 和 64 位 Excel 环境, 使用同样的 CTF 和插件 无需管理员权限即可部署 Add-in MATLAB Builder EX CTF MATLAB Production Server Solar Analysis coeffs 24
与数据库的集成 优化数据库中的数值处理 直接从数据库服务器请求基于 MATLAB 的分析 基于数据库事件触发请求 动态调用 API 提供更新的分析 ( 无需管理员权限 ) Enterprise Application Database Server Stored Procedure Client Library MATLAB Production Server Solar Analysis coeffs 25
同一程序, 不同的集成方法 Deploy to Desktop Deploy to a Web app Native code in MATLAB 26
MATLAB 应用发布总结 与没有 MATLAB 的人分享 MATLAB 程序 发放无需版税 创建独立的应用程序和共享库 部署到桌面,Web 和企业应用程序 28