关键路径问题(课程设计)Java

合集下载

Java路径问题解决方案(Javapathproblemsolution)

Java路径问题解决方案(Javapathproblemsolution)

Java路径问题解决方案(Java path problem solution)Java path problem solutions are collected [rotate]1, TestURL (),.Class.getResource ("),.GetPath (), or TestURL (),.Class.getResource (") ".GetFile" (), the path obtained, cannot be directly applied by FileReader () and FileWriter ().The reason is that the URL of space, special characters (%, # [], etc.) and Chinese of encoding processing.For example, the space becomes%20.There is a solution (1). After using repaceAll ("%20", "\"), only the space problem can be resolved. But the path contains% and Chinese is no good.There is a solution to (2), URLDecoder.decode (STR, UTF-8) decoding, but only part of the solution, if the path contains +, is not going to solve, because URL is not complete with URLEncoder.encode (STR, UTF-8) encoding, + is decoded, turned into space.Method (3) can solve all problems with TestURL(),.Class.getResource ("),".ToURI "(),".GetPath "(), but need to deal with" URISyntaxException "exception, which is more troublesome.The space problem in the Java pathIf spaces are in the path, then1. uri.getpath (). The space in the returned path still appears as "space", such as /F:/MyEclipse Workspace/project/bin/...In addition, all the spaces in the path returned by URL appear in the form of "%20", and uri.toString () appears in the form of "%20".2. new File (String filePath); parameter accepts correct URI format and the "space" (20%) the correct relative / absolute string path, or even to the path is correct will appear in the file not found exception.The path separators returned by 3. URL/URI are all "/", and the path separators returned by File are "\"". The existing file path string returns the space in the "space", and there is no path from new file (getPath), return to the path of the space is still new File (String filePath) the original form of the parameters, i.e. filePath (getPath) is a space space is returned that is "%20" or "%20".4.new URL (); the arguments can be either the right URI or a string in the URI format; if the string is incomplete URI, the creation fails.5.File.toURI (file) will be the path name in the "space" into "%20", and then add protocol: "file:/" in the path, and (File.toURL) only in the file path before simply add protocol: "file:/" instead of "space" into "%20", regardless of the original is the "space" or "%20" will only be preserved!6.Woden in WSDLReader.readWSDL (String s) to achieve theparameter s into URL, so string parameter s must not have spaces, should be replaced by 20%. The parameter s is best a string in the standard URI format.Java path resolutionThe path problem of Java is relatively complicated. Recent work involves the creation and reading of files, and the problems encountered in actual use are summarized below:I. interpretation of relative paths1. relative paths, i.e., relative paths relative to the current user directory, can be obtained either by the general java project or the web projectString relativelyPath=System.getProperty ("user.dir");For the general java file in the project is relative to the root directory of the project, and for the web project file path, it may be a path to a server, at the same time, different web servers are different (Tomcat is relative to the Tomcat installation directory \bin). For this reason, personally, it is better not to use "relative paths" relative to the current user directory in the web project". By default, however, the class in the java.io package always analyzes the relative path name based on the current user directory. This directory is user. by the system propertyDir specifies the directory that is typically called by the Java virtual machine. That is to say, it is better not to use therelative path when using a class in the java.io package. Otherwise, although in the SE program may be normal, but in the EE program, do not good, it will bring a problem oh.2. relative path relative to classpathSuch as the relative path of the path relative tofile:/D:/mywork/javaprj/MyTest/bin. Among them, bin is the classpath of this project. All the Java source files, compiled.Class files, are copied into this directory.The two type loads the directory (i.e., when it runs a class, gets its load directory)1., whether it's a general java project or a web project, first locate the first level directory where you can see the package pathInputStream is=ReadWrite.class.getClassLoader().GetResourceAsStream ("DeviceNO");The path to the DeviceNO file is the project name \src\DeviceNO; the first directory of the package in class ReadWrite is located under the SRC directory.2. and 1 are similar, the difference is this method must havea leading '/'InputStream is=ReadWrite.class.getResourceAsStream ("DeviceNO");The path to the DeviceNO file is the project name \src\DeviceNO; the first directory of the package in class ReadWrite is located under the SRC directory.Three. Web project root directory1., you can create a servlet and write the following statement in its init methodServletContext, sc=this.getServletContext ();String temp=sc.getRealPath ("/");The output path obtained similar results:"D:\Apache\Tomcat6.0\webapps\windpower\" (windpower project name), if it is called s1.getRealPath ("") is the output of "D:\Apache\Tomcat6.0\webapps\windpower" (note that in the last one less "\")2. in httpServletRequest, you can pass the following statementString cp=request.getSession ().GetServletContext().GetRealPath ("/"); the resulting output path is similar: "D:\Apache\Tomcat6.0\webapps\windpower\""Four. Class path (classpath) access (in Eclipse/MyEclipse, the path to the SRC or classes directory)Method 1., Thread.currentThread (),.GetContextClassLoader (),.GetResource ('),.GetPath ()Such as:String, path=Thread.currentThread (),.GetContextClassLoader (),.GetResource ("),.GetPath ();System.out.println (path);Print: /D:/windpower/WebRoot/WEB-INF/classes/"Method 2., ParsingXML.class.getClassLoader (),.GetResource ("),".GetPath "() (ParsingXML is SRC, class in a package, same below)Such as:String, path=ParsingXML.class.getClassLoader (),.GetResource ("),.GetPath ();System.out.println ("ParsingXML.class.getClassLoader ()).GetResource--" +path ");Print: ParsingXML.class.getClassLoader().GetResource--/D:/windpower/WebRoot/WEB-INF/classes/"In addition, if you want to put a file in a package, you can get the directory where the file is located, that is, to locate the last directory of the package.ParsingXML.class.getResource ("").GetPath ();Such as:String path=ParsingXML.class.getResource ("").GetPath ();System.out.println ("ParsingXML.class.getResource---" +p2);Print:"ParsingXML.class.getResource---/D:/windpower/WebRoot/WEB-I NF/classes/parsing/" (ParsingXML is the class in the parsing package under the SRC directory)Five. Property file read:Method 1.Static {PS = new, Properties ();{tryInputStream in = ReadWrite.class.getResourceAsStream ("DeviceNO");Ps.load (in);In.close ();} catch (Exception, e) {E.printStackTrace ();Ps.getProperty ("key")Method 2.Locale locale = Locale.getDefault ();ResourceBundle localResource = ResourceBundle.getBundle ("windpower/DeviceNOProperties", locale);String value = localResource.getString ("1");System.out.println ("DeviceNO:" + value);In the project SRC directory, the file DeviceNOProperties.properties (name suffix must be properties) reads as follows: 1=3 output results as follows: "DeviceNO:3""Six. Code conversion problem:GetResource ClassLoader UTF-8 was used for the encoding of path information, when there is Chinese and spaces in the path, he will convert to these characters, this is often not the true path, we want to get this, call the URLDecoder decode method to decode, in order to get Chinese spaces and the original pathFor example: the result isfile:/C:/Documents%20and%20Settings/%e5%ba%84%e6%99%93%e6%a f%85/Local%20Settings/Temp/temp0.jar! /db/dmozdata.mdb!And we expect the C:/Documents path, P, source, and so on. Here, we just want to return the value decode before we get to the path. Use UTF-8 encoding. Java code:String, configPath = this.getClass (),.GetClassLoader (),.GetResource (` allowPath.xml '),.GetFile ();ConfigPath = .URLDecoder.decode (configPath, UTF-8);In addition Java URL encoding and decoding functions of .URLEncoder.encode (String s) and.URLDecoder.decode (String s); encoding and decoding function escape in JavaScript URL (String s) and unescape (String s);Seven. Summary:When using relative paths, we should use relative paths relative to the current classpath.ClassLoader class getResource (String, name), getResourceAsStream (String, name) and other methods, using the relative path of the classpath relative to the current project to find resources.The same is true of the getBundle (String path) of the ResourceBundle class that is commonly used to read property files.By looking at the source code of the ClassLoader class and its associated classes, it is actually using the absolute path of the URI form. By getting the absolute path of the current classpath's URI form, the absolute path of the URI form of the relative path is constructed.。

关键路径 例题

关键路径 例题

关键路径例题假设我们需要完成以下任务,每个任务的所需时间如下:任务A:3天任务B:2天任务C:6天任务D:4天任务E:5天任务F:2天任务之间的依赖关系如下:A -> BA -> CB -> DC -> DD -> ED -> FE -> F我们需要确定完成整个项目需要的最短时间,以及关键路径是哪些。

首先,我们需要确定每个任务的最早开始时间(ES)和最晚开始时间(LS)。

我们可以使用以下方法来计算:1. 首先,计算每个任务的最早开始时间(ES):- ES(A) = 0,因为任务A没有任何前置任务。

- ES(B) = ES(A) + 时间(A) = 0 + 3 = 3,任务B的前置任务是A。

- ES(C) = ES(A) + 时间(A) = 0 + 3 = 3,任务C的前置任务是A。

- ES(D) = max(ES(B), ES(C)) + 时间(B) = max(3, 3) + 2 = 5,任务D的前置任务是B和C。

- ES(E) = ES(D) + 时间(D) = 5 + 4 = 9,任务E的前置任务是D。

- ES(F) = ES(D) + 时间(D) = 5 + 4 = 9,任务F的前置任务是D。

2. 接下来,计算每个任务的最晚开始时间(LS):- LS(F) = ES(F) = 9,因为任务F没有后续任务。

- LS(E) = LS(F) - 时间(D) = 9 - 4 = 5,任务E的后续任务是F。

- LS(D) = min(LS(E), LS(F)) - 时间(D) = min(5, 9) - 4 = 5,任务D的后续任务是E和F。

- LS(B) = LS(D) - 时间(B) = 5 - 2 = 3,任务B的后续任务是D。

- LS(C) = LS(D) - 时间(C) = 5 - 6 = -1,这是不可能的,因为任务C必须在任务D开始之前完成。

关键路径代码课程设计

关键路径代码课程设计

关键路径代码课程设计一、教学目标本课程的教学目标是使学生掌握关键路径法的基本概念、计算方法和应用技巧。

通过本课程的学习,学生将能够:1.理解关键路径法的定义、原理和作用。

2.掌握关键路径法的计算步骤和技巧。

3.应用关键路径法分析项目的进度和风险。

4.能够运用关键路径法解决实际项目管理和工程问题。

二、教学内容本课程的教学内容主要包括以下几个部分:1.关键路径法的定义和原理:介绍关键路径法的概念、特点和应用范围。

2.关键路径法的计算:讲解关键路径法的计算步骤、技巧和注意事项。

3.关键路径法的应用:通过案例分析,使学生掌握关键路径法在项目管理和工程中的应用。

4.关键路径法的扩展:介绍关键路径法的改进和扩展方法,如PERT图、CPM分析等。

三、教学方法为了实现上述教学目标,我们将采用以下教学方法:1.讲授法:通过讲解、演示和案例分析,使学生掌握关键路径法的基本概念和计算方法。

2.讨论法:学生进行小组讨论,分享学习心得和实际应用经验。

3.实验法:安排实践环节,让学生动手操作,提高实际应用能力。

四、教学资源为了支持本课程的教学内容和教学方法,我们将准备以下教学资源:1.教材:选用权威、实用的教材,为学生提供系统的学习材料。

2.参考书:推荐相关参考书籍,丰富学生的知识体系。

3.多媒体资料:制作PPT、视频等多媒体资料,增强课堂趣味性和实用性。

4.实验设备:准备项目管理软件、计算器等实验设备,方便学生进行实践操作。

五、教学评估本课程的教学评估将采用多元化方式,全面、客观地评价学生的学习成果。

评估方式包括:1.平时表现:通过课堂参与、提问、讨论等环节,评估学生的学习态度和积极性。

2.作业:布置适量的作业,检查学生对知识的掌握和应用能力。

3.考试:设置期中考试和期末考试,全面测试学生的知识水平和运用能力。

4.项目实践:学生进行小组项目实践,评估学生在实际操作中的能力和团队协作精神。

六、教学安排本课程的教学安排将根据课程内容和学生的实际情况进行设计,确保教学进度合理、紧凑。

关键路径理解和实现(java)

关键路径理解和实现(java)

关键路径理解和实现(Java)一、什么是关键路径在项目管理中,关键路径指的是完成一个项目所需的最长时间,也就是说在没有任何延误的情况下,项目完成的最短时间。

关键路径法是一种用于确定项目完成时间的方法,它能够帮助项目管理者合理安排项目的工作,提高项目的执行效率。

在项目中,每一个任务都有其开始时间和完成时间,而不同的任务之间可能存在依赖关系,即某些任务的开始时间取决于其他任务的完成时间。

通过确定各个任务之间的依赖关系,可以建立项目的网络图,通过这个图可以找出最长的路径,即关键路径。

二、关键路径的重要性1. 有效管理时间关键路径法能够帮助项目管理者了解到项目所需的最长时间,可以在这个基础上对项目的进度进行合理安排,避免出现拖延等问题,从而保证项目能够按时完成。

2. 资源分配通过确定关键路径,项目管理者可以清楚地了解到哪些任务是关键的、哪些是可以并行进行的,可以有效地分配资源,提高资源利用率。

3. 风险控制关键路径法可以帮助项目管理者及时发现项目进度偏差,及时调整方案,降低项目风险。

三、关键路径的实现(Java)在实际项目管理中,我们通常会借助计算机软件来帮助我们确定项目的关键路径。

下面将介绍如何使用Java语言来实现关键路径的计算。

1. 定义任务节点和任务之间的依赖关系我们需要定义任务节点和任务之间的依赖关系。

我们可以使用图的数据结构来表示这些任务节点和它们之间的依赖关系。

我们可以定义一个Task类来表示任务节点,这个类包括任务的开始时间、完成时间等属性。

另外,我们还可以定义一个Graph类来表示整个项目的网络图,这个类包括任务节点之间的依赖关系等属性。

2. 计算最早开始时间和最晚开始时间在确定了任务节点和它们之间的依赖关系之后,我们可以利用拓扑排序算法来计算每个任务节点的最早开始时间和最晚开始时间。

计算最早开始时间时,我们可以从项目的起点开始,按照拓扑排序的顺序计算每个任务节点的最早开始时间,这个时间表示的是在没有任何延误的情况下,该任务节点可以开始的最早时间。

关键路径算法课程设计

关键路径算法课程设计
printf("%c",sv[i]);
if(sv[i]!=Graph[vexnumber-1].data)
printf("--->");
}
printf("\n");
printf("关键路径长度为:%d个单位时间\n",totaltime);
return 1;
}
void main( ) {
}
接着从终点出发,令事件最迟发生时间等于其最早发生时间,按你你逆拓扑排序求其余各顶点事件最迟发生时间vl[k];最后根据各顶点事件的ve和vl值,求所有活动最早开始时间ee和最迟开始时间el。如果某活动满足条件ee=el,则为关键活动。(代码如下)
if(el[i]==ee[i]) {
printf("此弧为关键活动");
if(el[i]==ee[i]) {
printf("此弧为关键活动");
sv[t]=Graph[j].data;t++;
}
printf("\n");
p=p->nextedge;
}
}
printf("关键路径节点为:");
sv[t]=Graph[vexnumber-1].data;
for(i=0;i<=t;i++){
}
同时,为计算各顶点事件的ve值是在拓扑排序的过程中进行的,因此需一个队列来记录拓扑排序,如果顶点的入度为0,则该顶点从队尾进入队列,拓扑排序时,从队头出队列。
if(Graph[k].ቤተ መጻሕፍቲ ባይዱd ==0)
topology_queue[++rear]=k;

数据结构课程设计报告——关键路径

数据结构课程设计报告——关键路径

《数据结构》课程设计报告课程题目:关键路径学院:班级:学号:XX:指导教师:完成日期:目录一、需求分析3二、概要设计4三、详细设计5四、调试分析11五、用户使用说明12六、测试结果13七、附录13一、需求分析1、问题描述AOE网(即边表示活动的网络),在某些工程估算方面非常有用。

它可以使人们了解:(1)研究某个工程至少需要多少时间?(2)哪些活动是影响工程进度的关键? 在AOE网络中,从源点到汇点的有向路径可能不止一条,但只有各条路径上所有活动都完成了,这个工程才算完成。

因此,完成整个工程所需的时间取决于从源点到汇点的最长路径长度,即在这条路径上所有活动的持续时间之和,这条路径就叫做关键路径(critical path)。

2、设计步骤(1)、以某一工程为蓝本,采用图的结构表示实际的工程计划时间。

(2)、调查并分析和预测这个工程计划每个阶段的时间。

(3)、用调查的结果建立AOE网,并用图的形式表示。

(4 )、用CreateGraphic ()函数建立图的邻接表存储结构,能够输入图的顶点和边的信息,并存储到相应存储结构中。

(5)、用SearchMaxPath()函数求出最大路径,并打印出关键路径。

(6)、编写代码并调试、测试通过。

3、测试数据○v2○v5○v1○v4○v6○v36v1 v2 v3 v4 v5 v68v1 v2 a1 3v1 v3 a2 2v2 v4 a3 2v2 v5 a43v3 v4 a5 4v3 v6 a6 3v4 v6 a7 2v5 v6 a8 1二、概要设计为了实现上述函数功能:1、抽象数据类型图的定义如下:ADT Graph {数据对象V:V是具有相同特性的数据元素的集合,称为顶点集。

数据关系R:R={VR};VR={<v,w>|v,w∈V,且P(v,w),<v,w>表示从v到w的弧,谓词P(v,w)定义了弧<v,w>的意义和信息}基本操作:InitGraph(G);初始条件:图G存在。

《JAVA程序设计》课程设计指导书.doc

《JAVA程序设计》课程设计指导书.doc

《JAVA程序设计》课程设计指导书一、目的和意义《JAVA语言课程设计》是学完《程序设计语言一JAVA》课程Z后,让学生综合运用所学到的JAVA编稈基础以及应用,进行较大规模的、具有一定综合性、复杂性的软件开发,对理解JAVA稈序设计语言以及应用的精龍,具有重要实践意义。

能够通过实践来巩固、加深对JAVA的理解和运用,同时通过理论联系实际,能够培养学生的动手设计和实践能力,能够提高学生的学习兴趣,并且能够培养和增强学生通过自己独立解决实际问题所带来的“成就感”。

此外,通过木课程设计学生能够掌握软件开发的过程,在软件开发的备个过程有切身体会。

二、选题要求选题要符合木课程的教学要求,通常应包含面向对象程序设计思想(类设计、继承、多态性的应用)、异常处理、图形用户界面设计,并注重数据结构类的自觉使用,此外,多线程技术、网络编稈技术(Socket编程、基于WEB的JSP开发、Applet开发)可以兼顾。

注意选题内容的先进性、综合性、实践性,应适合实践教学和启发创新,选题内容不应太简单, 难度要适屮;最好结合软件开发实际情况进行选题,反映JAVA的语言特性和应用特点,并且有一定的实用价值;软件成果具有相对完整功能,并易于使用,易于理解,具有良好的可维护性。

三、任务及要求1.任务%1能够掌握JAVA的基木编程技术,如循环、递推、递归;%1理解面向对彖的思想,熟悉类、对象、继承及多态性概念;%1熟悉异常处理的特点和用法;%1掌握图形界面的设计;%1熟悉数据结构类的应用;%1对于多线程技术、网络编程技术(Socket编稈、基于Web的JSP开发、Applet开发)知识根据课程设计课题的需要进行选择。

2.要求%1选定设计课题,下达设计任务;选题可由指导教师选定,或由指导教师提供几个选题供学生选择;也可由学生自己选题, 但学生选题需通过指导教师批准。

课题应在设计周之前提前公布,并尽量早些,以便学生有充分的设计准备时间。

JAVA路径问题及命令行编译运行基础(linux下)

JAVA路径问题及命令行编译运行基础(linux下)

JA V A路径问题及命令行编译运行基础(linux下)(初学者的一些总结~高手们勿喷哈~)原因:以前一直用Eclispe编程环境运行java。

非常舒服,就像用傻瓜相机照相一般。

有看见许多高手都是直接用vim编辑文件,命令行编译运行,觉得那样不是反而更繁琐?转折点是在前几天本科毕设题目选定之后。

毕设题是一个基于java 字节码的类关系动态分析。

需要对.class文件中字节码进行更改(具体的说是在许多指令后加入做标记的新指令,以实现动态跟踪的目的)。

我发现,eclipse根本无法如此灵活,他无法直接装载运行一个我修改过的.class文件。

它是照顾大多数的一般情况。

它为我们做了很多事情:自动将.java源文件编译成.class字节文件,帮我们加载类、运行。

但却无法满足我个性化的需求。

命令行虽然麻烦,却是更加本质。

至少从这一点上看,java的命令行编译运行还是非常重要的。

我查阅了不少网上资料,发现资料虽多,却并不齐全,也不是太清晰。

于是整理如下,希望对初涉java命令行编译运行的筒子有些帮助吧!许多初学者编译运行时候的Exception的发生,下面的方法都能解决了~如果你遇到什么问题,仔细看看下面先~说不定有所帮助噢。

java的运行机制的基本概念:源文件也就是我们熟知的.java文件。

类文件.class文件是编译器由.java文件编译而成。

众所周知,Java的跨平台性在于Java虚拟机(JVM)这一层对硬件的隔离,而.class文件可以理解为JVM中的执行文件(自己的理解,可能不太准确)。

里面存储的是java字节码,java bytecode 是基于栈的(stack based)(关于字节码和JVM更详细的官方解释可以参照The Java Virtual Machine Specification ,如果嫌那本书太厚,另外再推荐一本Programming for the Java Virtual Machine)。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
3.4测试数据……………………………………………………………………………………………7
第四章调试分析及测试…………………………………………………………………………………10
4.1程序操作与运行……………………………………………………………………………………10
4.2容错处理……………………………………………………………………………………………11
在概要设计的基础上,又给出了详细的算法设计,实现概要设计中定义的所有函数,对每个函数写出核心算法,并画出了流程图。然后对编码进行了测试与分析(并在最后附上java语言编写的程序代码)。最后对整个设计过程进行了总结。
关键词:关键路径;抽象数据类型;程序模块;核心算法;流程图;java。
CRITICALPATHPROBLEM
Key words:critical path; abstract data type; program module; the core algorithm flow chart; Java.
第一章绪论…………………………………………………………………………………1
1.1题目内容与研究意义………………………………………………………………………………1
(7) 编写代码并测试。
2.2 系统模块图
图1系统模块图
第三章详细设计
3.1 遇到的问题及解决方法
计算各顶点的ve值是在拓扑排序的过程中进行的,需对拓扑排序的算法做一些修改,求关键路径算法中没有标明明显的关于工程能否顺利进行的提示语。
3.2关键算法分析
1.有向图的输入
class CriticalPath1
First of all, the demand analysis, to explain what is the critical path, and points out its important role in estimating engineering. Then given for the critical path of the outline design, including all of the procedures used in the definition of abstract data types, the main program flow and the program module between the layers ( call) relationship.
4.3再举一例……………………………………………………………………………………………13
第四章总结………………………………………………………………………………………………15
参考文献………………………………………………………………………………………………16
附录
第一章绪论
1.1题目内容与研究意义
1.概述
ABSTRACT
The critical path is we estimate some works very useful, is a very important to estimate a project the minimum time required. This article on how to seek a project critical path is described in detail, including needs analysis, outline design, detailed design, testing and analysis, summary, source list.
2.研究意义
关键路径可以很方便的让我们估算出某个工程最短的时间开销,以及这个工程中哪些活动,即哪些项目是主要的,是影响工程进度的关键,从而让我们对工程的实施做出更好的时间安排,并且可以分清主次,抓住核心工程,做到有的放矢。
总的来说,正因为关键路径可以帮助我们对工程进行非常有必要的估算,让我们得以看清全局,做出更为优化的安排,所以可见关键路径的求出对一项工程而言是非常必要的。这亦是本次对关键路径求法的研究意义所在。
(1)研究某个工程至少需要多少时间?
(2)哪些活动是影响工程进度的关键?
由于AOE-网中的有些活动可以并行进行,从开始点到各个顶点,以致从开始点到完成点的有向路径可能不止一条,这些路径的长度也可能不同。完成不同路径的活动所需的时间虽然不同,但只有各条路径上所有活动都完成了,这个工程才算完成。因此,完成工程所需的最短时间是从开始点到完成点的最长路径的长度,即在这条路径上的所有活动的持续时间之和.这条路径长度就叫做关键路径(Critical Path)。
void calculate()
{
int[] ve=new int[graph.length]; //事件的最发生时间
Stack stack1=new Stack();
Stack stack2=new Stack();
int i,j,v;
for(int t : ve) t=0;
stack1.push(0);
关键路径问题
摘要
关键路径是我们估算某些工程非常有用,是一种非常重要的估算一项工程所需的最短时间的依据。本文对如何求一个工程的关键路径做了详细的说明,包括需求分析、概要设计、详细设计、测试与分析、总结、源程序清单。
首先,做了需求分析,解释了什么是关键路径,并指出它在估算工程中的重要作用。然后给出求关键路径的概要设计,包括程序中用到的所有抽象数据类型的定义,主程序的流程以及各程序模块之间的层次(调用)关系。
v=(Integer)stack2.pop();
for(i=1; i<graph[v].length; i=i+2){
j=graph[v][i];
if(vl[j]-graph[v][i+1]<vl[v]){
vl[v]=vl[j]-graph[v][i+1];
}
}
}
4.求关键路径的所有边
for(v=0; v<graph.length-1; v++){ //求关键路径的所有边
//System.out.println("边:" + path[i][0]+ "-" + path[i][1] +" 权:"+ path[i][2]);
s+="边:" + path[i][0]+ "-" + path[i][1] +" 权:"+ path[i][2]+"\n";
}
}
求事件的最早发生时间
该题实质要求用数据结构中的图形知识编写一个求无循环有向帯权图中从起点到终点所有路径,经分析、比较求出长度最大路径,从而求出关键路径。
通常我们用有向图表示一个工程。在这种有向图中,用顶点表示活动,用有向边<Vi,Vj>表示活动Vi必须先于活动Vj进行。如果在这种图中用有向边表示一个工程中的各项活动(ACTIVITY),用有向边上的权值表示活动的持续时间(DURATION),用顶点表示事件(EVENT),则这种的有向图叫做用边表示活动的网络,简称AOE网络。在AOE网络中,从源点到各个顶点,可能不止一条。这些路径的长度也可能不同。不同路径所需的时间虽然不同,但只有各条路径上所有活动都完成了,这个工程才算完成。因此,完成整个工程所需的时间取决于从源点到汇点的最长路径长度,即在这条路径上所有活动的持续时间之和。这条路径长度就叫做关键路径(Critical Path)。程序所要达到的功能:输入并建立AOE网;输出关键活动并求出这个工程的关键路径;求出完成这个关键路径的最少时间并输出,该程序结束。
我们通常把计划、施工过程、生产流程、程序流程等都当成一个工程。工程通常分为若干个称为“活动”的子工程。完成了这些“活动”,这个工程就可以完成了。
我们通常用AOE-网来表示工程。AOE-网是一个带权的有向无环图,其中,顶点表示事件(EVENT),弧表示活动,权表示活动持续的时间。
AOE-网可以用来估算工程的完成时间。他可以使人们了解:
ve[j]=ve[v]+graph[v][i+1];
}
}
stack2.push(v);
}
3.求事件的最迟生时间
for(i=0; i<graph.length; i++) vl[i]=1000;
vl[graph.length-1]=ve[graph.length-1];
while(stack2.empty()!=true){
1.2题目理解与功能分析………………………………………………………………………………1
第二章概要设计…………………………………………………………………………………………3
2.1 设计思路……………………………………………………………………………………………3
2.2 系统模块图…………………………………………………………………………………………3
In the summary of the design basis, and gives a detailed algorithm design, design outline to achieve the definition of all functions, each function to write the core algorithms, and draw the flow chart. Then the coding are tested and analyzed ( and in the final with a java language program code ). The final design of the whole process are summarized.
相关文档
最新文档