




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、主讲人: 雒兴刚东北大学系统工程研究所Email: Tel: 83682292优化软件与应用优化软件与应用第七章 OPL 界面IDE 介绍IDE 是什么:是什么:integrated development environment (IDE) for mathematical programming and combinatorial optimization applications. It is the graphical user interface (GUI) for the OPL modeling language and the ILOG Script for OPL scrip
2、ting language. 第七章 OPL 界面IDE 介绍IDE能做什么:能做什么:Create and modify model, data, and project files using the editing capabilities Execute a project Generate a compiled model Generate external data files or calculated data files to various formats Visualize OPL results in text or tabular form Visualize the
3、 state of variables at some point during the search for a solution Set GUI options and mathematical programming options Connect to a database or to a spreadsheet to read and write data Work with ILOG Script for OPL, the scripting language Profile the execution of a model Search for relaxations of va
4、riables and constraints, and for conflicts between constraints Debug scripts using the debug facilities 第七章 OPL 界面IDE 介绍IDE 环境处理三种文件:环境处理三种文件:model files, data files, and project filesModels:保持:保持OPL语句及语句及ILOG脚本,后缀是脚本,后缀是.mod。也可以生成编译后的。也可以生成编译后的模型格式,后缀是模型格式,后缀是.opl。Data: 对于较大规模问题,可以分离数据之数据文件对于较大规模问题
5、,可以分离数据之数据文件(.dat),数据文件中也,数据文件中也可以说明外部数据源,如可以说明外部数据源,如Excel文件或文件或ODBC数据库源等。数据库源等。Projects:文本格式,:文本格式,XML表示。说明表示。说明project关联的模型和数据文件。类关联的模型和数据文件。类似似VC的工程文件。的工程文件。第七章 OPL 界面IDE 介绍创建新文件:创建新文件:第七章 OPL 界面IDE 介绍运行项目:运行项目:如何检查语法:如何检查语法:运行项目后,出错的语运行项目后,出错的语法会以红色标识。修改法会以红色标识。修改错误后,继续运行项目。错误后,继续运行项目。第七章 OPL 界
6、面IDE 介绍查看运行结果:查看运行结果:Solution TAB显示运行的结果。显示运行的结果。CPLEX statistics显示算法的具显示算法的具体运行参数。当然,可以通过体运行参数。当然,可以通过Options设置显示的项。设置显示的项。第七章 OPL 界面IDE 介绍产生一个编译的产生一个编译的opl文件:文件:File-Generate Compiled Model File第七章 OPL 界面IDE 介绍IDE文本编辑的特色:文本编辑的特色:MDI approach; Syntax coloring; Multiple levels of Undo and Redo;Autom
7、atic indentation Blocks: as delimited by curly brackets ;Bracket (or brace) matching; When typing , or ), highlighted;Margin symbols the yellow arrow that indicates the current line the red box that indicates an error the red circle that indicates a breakpoint Reload prompt:If you modify a file with
8、 an external editor, you are prompted to reload Customization:options to customize the editor第七章 OPL 界面IDE 介绍数据库支持:数据库支持:OPL通过通过ILOG DBLink 5.0 支持支持RDBMS ;支持的数据库类型:支持的数据库类型:OPL数据库支持通过函数数据库支持通过函数DBconnection 来实现,该函数主要有两个参数:来实现,该函数主要有两个参数:the database client you want to use : e.g. oracle81the connecti
9、on string: e.g. scott/tigerilog “后面我们有一个详细的数据库连接的例子。后面我们有一个详细的数据库连接的例子。第七章 OPL 界面IDE 介绍为什么使用为什么使用ILOG 脚本?脚本?Add preprocessing to prepare data for the model Control the flow while solving the model Set CPLEX parameters Add postprocessing to aggregate, transform, and format data (including results dat
10、a) for display or for sending to another application, for example, a spreadsheet Solve repeated instances of the same model Feedback:Create algorithmic solutions where the output of one model instance is used as the input of a second model instance第七章 OPL 界面IDE 介绍ILOG 脚本的入口点脚本的入口点The main statement
11、for a flow control script The execute statement for preprocessing and postprocessing scripts 没有独立的脚本文件;脚本文件总是和模型文件结合使用没有独立的脚本文件;脚本文件总是和模型文件结合使用第七章 OPL 界面例:IDE Project1、在、在IDE界面中,界面中,FileNewProject. 红色的星号表示是必选项。选择红色的星号表示是必选项。选择Location为为C:Temp,在项目,在项目Name中键中键入入MyProject;可以看到系统自动命名可以看到系统自动命名mod文件和文件和d
12、at文件为文件为MyProject。用户也可以对其名。用户也可以对其名称进行修改,或者点选其右面的图标,称进行修改,或者点选其右面的图标,选择一个现有的文件添加到本项目中;选择一个现有的文件添加到本项目中;注意一个项目中注意一个项目中mod文件只有文件只有1个,个,dat文件可以有多个;文件可以有多个;点击点击“Create Project”,可以看到系统,可以看到系统在在C:Temp下创建了两个文件,下创建了两个文件,Project窗口如右图。窗口如右图。第七章 OPL 界面例:IDE Project2、拷贝下面的代码到、拷贝下面的代码到mod文件中,保存文件中,保存. string Pro
13、ducts = .;string Resources = .;tuple ProductData float demand; float insideCost; float outsideCost; float consumptionResources;ProductData productProducts = .;float capacityResources = .;dvar float+ insideProducts;dvar float+ outsideProducts;execute CPX_PARAM cplex.preind = 0; cplex.simdisplay = 2;
14、minimize sum(p in Products) (productp.insideCost*insidep + productp.outsideCost*outsidep);subject to forall(r in Resources) sum(p in Products) productp.consumptionr * insidep = productp.demand;第七章 OPL 界面例:IDE Project3、如图,选择、如图,选择“Add new data file”,选择和,选择和project文件相同的文件夹,输文件相同的文件夹,输入文件名称入文件名称MyProje
15、ct.dat,保存,保存. 第七章 OPL 界面例:IDE Project4、双击、双击MyProject.dat,将下面的代码拷贝到右侧的编辑区,保存。,将下面的代码拷贝到右侧的编辑区,保存。 运行文件,结果如图运行文件,结果如图. Products = kluski, capellini, fettucine ;Resources = flour, eggs ;product = # kluski : , capellini : , fettucine : #;capacity = 20, 40 ;注意:项目可以有多个注意:项目可以有多个dat文件。一个文件。一个dat中的变量定义可能参考
16、另一个中的变量定义可能参考另一个dat文件,文件,IDE调取调取dat文件的顺序是从上到下。因此,可以通过点选文件的顺序是从上到下。因此,可以通过点选dat文件右文件右键菜单的键菜单的move up来调整顺序。来调整顺序。 另外,从项目中移除一个文件也可以通过右键菜单来实现。另外,从项目中移除一个文件也可以通过右键菜单来实现。第七章 OPL 界面例:IDE Project另外,另外,IDE也支持同时打开多个项目。例如,图中打开了也支持同时打开多个项目。例如,图中打开了4个项目,红色的、个项目,红色的、单选框选中的是当前项目。单选框选中的是当前项目。当前项目可以通过右键菜单中的当前项目可以通过右
17、键菜单中的“set as active project”来设定。来设定。第七章 OPL 界面例:IDE Project5、在、在execute处设置一个断点,然后运行项目。处设置一个断点,然后运行项目。和高级语言的和高级语言的Debug按钮类似:按钮类似:停止运行停止运行暂停(当程序暂停(当程序长时间运行时)长时间运行时)继续运行继续运行Step intoStep outStep overRun to cursor第七章 OPL 界面例:IDE Project6、取消断点,继续运行项目。、取消断点,继续运行项目。下面以这个例子的结果为例,介绍下面以这个例子的结果为例,介绍IDE的界面元素。的界
18、面元素。首先是首先是Output窗口中的窗口中的Console标签页:标签页:如果编译出错,则显示语法错误;如果求解成功显示最优解状态如果编译出错,则显示语法错误;如果求解成功显示最优解状态第七章 OPL 界面例:IDE ProjectOutput窗口中的窗口中的Solution标签页:标签页:显示局优解显示局优解partial solutions (如果有如果有)和最优解。下面是另一个例子的结果。和最优解。下面是另一个例子的结果。第七章 OPL 界面例:IDE ProjectOutput窗口中的窗口中的Infeasibility标签页:标签页:因为本例有解,所以标签页为空白。下面是另一个例子
19、的结果。因为本例有解,所以标签页为空白。下面是另一个例子的结果。第七章 OPL 界面例:IDE ProjectOutput窗口中的窗口中的CPLEX Log标签页:标签页:显示显示CPLEX求解过程中的日志信息,包括每个迭代过程的换基过程求解过程中的日志信息,包括每个迭代过程的换基过程第七章 OPL 界面例:IDE ProjectOutput窗口中的窗口中的CPLEX Statistics标签页:标签页:显示显示CPLEX求解的各种统计信息,包括变量个数、约束个数、算法求解的各种统计信息,包括变量个数、约束个数、算法类型、迭代次数等等。类型、迭代次数等等。第七章 OPL 界面例:IDE Pro
20、jectOutput窗口中的窗口中的Profiler标签页:标签页:右面是执行步骤,左面是计算时间和使用内存。通过分析这些信息,右面是执行步骤,左面是计算时间和使用内存。通过分析这些信息,可以改进模型(缩短时间和减少内存)可以改进模型(缩短时间和减少内存)第七章 OPL 界面例:IDE ProjectProfiler标签页中,执行步骤主要分为以下两类:标签页中,执行步骤主要分为以下两类:左面的计算时间和使用内存的含义见下表:左面的计算时间和使用内存的含义见下表:第七章 OPL 界面例:IDE ProjectOutput窗口中的窗口中的Log标签页:标签页:显示运行日志信息。显示运行日志信息。第
21、七章 OPL 界面例:IDE Project模型窗口显示如图。模型窗口显示如图。下面介绍下面介绍IDE的模型窗口。的模型窗口。7、关闭当前项目。、关闭当前项目。第七章 OPL 界面例:IDE Project可以显示模型的类型、常量、变量、可以显示模型的类型、常量、变量、变量的初始化数据。变量的初始化数据。8、重新调入刚才的项目,运行项目。、重新调入刚才的项目,运行项目。用鼠标点选用鼠标点选Data或者或者Variables中的中的变量或常量变量或常量,下面的,下面的Property和和Value会显示相应的值;同时,右会显示相应的值;同时,右面的编辑区也会定位的模型的相关面的编辑区也会定位的模
22、型的相关代码处。代码处。第七章 OPL 界面例:IDE Project9、修改模型代码如下,然后重新运行项目。、修改模型代码如下,然后重新运行项目。 constraint ct1; constraint ct2; subject to ct1= forall(r in Resources) sum(p in Products) productp.consumptionr * insidep = productp.demand;注意到前面的模型窗口中,注意到前面的模型窗口中,Contraints没有详细的信息。这是因为没有详细的信息。这是因为mod文件中没有给约束命名。文件中没有给约束命名。第七
23、章 OPL 界面例:IDE Project现在可以看到详细的约束信息(打开小加号):现在可以看到详细的约束信息(打开小加号): 另外,在模型窗口中,也可以双击元素,可以弹出窗口,显示详细信息。另外,在模型窗口中,也可以双击元素,可以弹出窗口,显示详细信息。第七章 OPL 界面例:IDE Project下面再介绍一点下面再介绍一点IDE的选项设置。的选项设置。10、如图方式选择;或者从菜单选择、如图方式选择;或者从菜单选择OptionsProject Options 第七章 OPL 界面例:IDE Project选择选择 OPL Language下的下的General,右面的,右面的Displa
24、y Solution不选。不选。重新运行项目,将只显示最优目标。重新运行项目,将只显示最优目标。第七章 OPL 界面IDE 界面详解IDE主环境主环境脚本对象浏览器脚本对象浏览器菜单菜单主工具栏主工具栏执行工具栏执行工具栏项目项目 浏览器浏览器模型模型 浏览器浏览器输出输出 窗口窗口编辑区域编辑区域状态显示状态显示当前行和列当前行和列状态显示状态显示第七章 OPL 界面IDE 界面详解菜单命令详解菜单命令详解File菜单菜单NewCreatesanewfile.Displaysasubmenutospecifyamodel,project,ordatafile.OpenOpensafile.D
25、isplaysasubmenutospecifyamodel,project,ordatafile.Ineachcase,theIDEdisplaysanOpenFiledialogboxrequestingthefilenameyouwanttoopen.RecentFilesYoucanopenafilethatyouhaveusedrecentlybyselectingitsnamefromthesubmenu.SaveSavesthecurrentfileintheEditingareawithitscurrentnameandatthecurrentlocation.SaveAsSa
26、vesthecurrenteditedfilewithanewname.SaveAllSavesallthefilesintheEditingareawiththeircurrentnamesandatthecurrentlocation.第七章 OPL 界面IDE 界面详解File菜单菜单CloseCurrentEditorClosestheactivefileintheEditingarea.Ifitisamodelfile,anerrormessagewarnsyouthatcannotclosethemodelofthecurrentproject.Ifitisadatafile,it
27、swindowdisappearsfromtheEditingAreabutitsnameremainsdisplayedintheProjectstree.CloseActiveProjectClosestheactiveprojectfile(.prj)andpromptsyoutosaveitifoneofitsassociatedfilescontainsunsavedmodifications.Ifoneofitsassociatedfilesisnotwrite-accessible,anerrormessagewarnsyouthatyoucannotsaveit.Generat
28、eCompiledModelFileGeneratesacompiledmodelfile(.opl)whichyoucanlaterpassasanargumentwhenusingtheOPLAPItointegrateyourmodelinanapplication.第七章 OPL 界面IDE 界面详解File菜单菜单GenerateExternalDataFileOpensaSaveAsdialogboxwhichenablesyoutoexportthedatatoafilethatcanlaterbeusedasinput.GenerateCalculatedDataFileOpe
29、nsaSaveAsdialogboxwhichenablesyoutoexportthecalculateddatatoafilethatcanlaterbeusedasinput.QuitExitstheIDEandpromptsyoutosaveanyunsavedproject.第七章 OPL 界面IDE 界面详解Edit菜单菜单UndoUndoesthelastactioninthecurrenteditor(unlimited).RedoRedoesthepreviouslyundoneactioninthecurrenteditor(unlimited).CutRemovesthe
30、selectedtextandcopiesittotheclipboard,fromwhereyoucanpasteitelsewhere.CopyCopiestheselectedtext,fromtheEditingareaorOutputwindow,totheclipboard,fromwhereyoucanpasteitelsewhere.PastePastesfromtheclipboardtothecurrenteditor.KillLineDeletesalinefromthecursorpositiononwardandcopiesittotheclipboard,repla
31、cingtheexistingclipboardcontent.SelectAllSelectstheentirecontentofthecurrenteditor.第七章 OPL 界面IDE 界面详解Edit菜单菜单FindDisplaystheFinddialogboxforspecifyingsearchcriteria.FindNextFindsthenextoccurrenceofthetextdisplayedintheFindbox.FindPreviousFindsthepreviousoccurrenceofthetextdisplayedintheFindbox.Repla
32、ceDisplaystheReplacedialogboxforspecifyingsearchcriteriaandreplacingspecifiedstrings.GoToDisplaystheGoTodialogboxforspecifyingalinewherethecursorshouldbeplacedintheEditingarea.RecenterPlacesthecurrentlineinthemiddleofthewindow,ifpossible.IndentLinesAddsatabulationatthebeginningofselectedlines.(Youmu
33、sthighlighttheline,notjustclickinit.)按Tab键是相同的结果第七章 OPL 界面IDE 界面详解Edit菜单菜单OutdentLinesRemovesthetabulationfromthebeginningofselectedlines.按Shift+Tab键是相同的结果CommentTransformsselectedlinestocomments,usingthe/delimiter.Youcanalsoaddcommentsmanuallyusing/*and*/asopeningandclosingdelimiters.However,inthis
34、case,theUncommentcommandisineffective.UncommentRemovesthe/commentdelimitersfromtheselectedlines.Ifyouusedthe/*and*/charactersascommentdelimiters,theUncommentcommanddoesnotwork,CompleteWordSearchesupwardforastringinthesamefileandcompleteswiththefirststringthatmatchesthesamebeginningletters.Thesearchb
35、eginsupwardattheleftofthecurrentcursorposition.第七章 OPL 界面IDE 界面详解View菜单菜单Show/HideProjectsHidesorredisplaystheProjectswindowcontainingtheprojecttree.Show/HideModelBrowserHidesorredisplaystheModelBrowserwindowcontaininginformationaboutthedatastructuresdefinedintheactivemodelinalphabeticalorderofname.
36、Show/HideOutputHidesorredisplaystheOutputwindow.Show/HideILOGScriptObjectsAlternatelydisplaysorhidesthepartoftheOutputWindowthatcontainsthedebuginformationonobjectsinscripts.第七章 OPL 界面IDE 界面详解Project菜单:其内容根据当前选定的对象而改变菜单:其内容根据当前选定的对象而改变SetasActiveProjectSetasActiveModelThiscommandisavailableonlywheny
37、ouselectaprojectorstand-alonemodelthatisnotalreadyactive,toenableyoutomakeittheactiveprojectormodel.ProjectDescriptionDisplaysadialogboxwhereyoucantypeafewwordstodescribethepurposeorcontentoftheproject.YourdescriptionthenappearsinthelistofRecentfilesintheStartwindow.AddNewModelFileAddsanew,emptymode
38、lfiletotheproject.Ifyouselectanexistingmodelfilebymistakeinthefilechooser,amessagewarnsyouthatitwillbeoverwrittenbythenewemptymodelfile.AddNewDataFileAddsanew,emptydatafiletotheproject.第七章 OPL 界面IDE 界面详解Project菜单菜单InsertExistingModelFileAddsanexistingmodelfiletotheproject.Aprojectcanhaveonlyonemodel
39、file.InsertExistingDataFileAddsanexistingdatafiletotheproject.SavetheProjectSavestheprojectsoptionsanditscomponents.SavetheProjectAsChangesthenameand/orlocationofanexistingproject.CloseProjectClosestheprojectanditsassociatedfiles.BrowseModelBuildsorrebuildsthemodeltreeofthedatastructuresdefinedinthe
40、activemodelorproject.第七章 OPL 界面IDE 界面详解Execution菜单菜单BrowseActiveModelBuildsorrebuildsthemodeltreeofthedatastructuresdefinedintheactivemodelorproject.RunSubmitstheactivemodelorprojectforexecution.Thebuttonturnsgreyduringexecution.AfteryouclickRun,thePauseExecutionbuttonbecomesavailable,aswellasotherb
41、uttonsoftheExecutiontoolbarincertaincases.AbortAppearswhenyouclicktheRunbutton,toenableyoutostopexecutionofamodel,projectorscript.AfteryouclicktheAbortbutton,theIDEreturnstoanormaleditingsessionbutkeepsthesolutioninformationintheOutputwindow.第七章 OPL 界面IDE 界面详解Execution菜单菜单PauseSuspendsexecutionofamo
42、delorprojecttemporarily.YoucanresumewiththeContinuebutton.ContinueRequeststheIDEtocontinueexecutionafterapause.StepIntoStepsintoaloopinascript.StepOutStepsintoafunctioninascript,tothefirststatement,orstepstotheinstructionafterthecurrentoneifthereisnofunctioncalled.StepOverSkipsaninstructioninaloop:e
43、itherafunctioncall,thengoingtothestatementafterthefunctioncall,oraninstruction,thengoingtotheinstructionafterit.RunToCursorMakesthescriptruntothecursorpositiononceyouhavesetafirstbreakpoint.Usefulwhenyoudebugscripts.第七章 OPL 界面IDE 界面详解Debug菜单菜单Add/RemoveBreakPointAlternatelysetsandremovesbreakpointsi
44、nthesearchprocedureofanOPLmodelorscript.Options菜单菜单GeneralSettingsDisplaystheGeneralSettingsdialogboxthatallowsyoutochangeGUIoptionsforallprojects.Youcannotchangeanygeneralsettingsforstandalonemodels.Youmustfirstincludetheminaproject.ProjectOptionsDisplaystheProjectOptionsdialogboxthatallowsyoutochange
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 污泥管线施工方案
- 石膏射灯施工方案
- 青苔铺面施工方案
- 2025-2030年中国粉底液行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国竹炭纤维行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国离岸充气船行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国硬密封蝶阀行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国真空杯行业市场深度调研及发展趋势与投资战略研究报告
- 架空布线施工方案
- 2025-2030年中国男式化纤上衣行业市场现状供需分析及投资评估规划分析研究报告
- 第十单元 常见的酸、碱、盐 检测题(含答案)-2024-2025学年九年级化学人教版下册
- 业务合规培训
- 2025年高考语文一轮复习知识清单专题13:图文转换(学生版)
- 工厂实验室规划和建设
- 2025年国家保密基本知识考试题库及答案
- 空调售后客服培训课件
- 《《定制式医疗器械医工交互全过程监控及判定指标与接受条件》》
- 《三只松鼠公司基于哈佛探析框架的财务探究(9900字论文)》
- DB32T 3293-2017 企业专职消防队建设和管理规范
- 2024年江苏南京林业大学招聘专职辅导员15人(第二批)管理单位遴选500模拟题附带答案详解
- GB/T 44828-2024葡萄糖氧化酶活性检测方法
评论
0/150
提交评论