comp20005 Engineering ComputationSemester 1, 2018Assignment 2Learning OutcomesIn this project you will demonstrate your understanding of structures and arrays of structures, and willdevelop a computational solution for a non-trivial problem. You are also expected to make extensiveuse of functions; and to demonstrate that you have adopted a clear and elegant programming style. Youwill find it difficult to create a working solution unless you plan your program carefully in advance, anddevelop it incrementally.Spatial DataMuch of the data that is used in computing (including engineering) applications is spatiotemporal, anddescribes the layout of objects in space and/or time. In this project we are going to pretend to haveexpert knowledge in the area of forest and tree management, and simulate the possible consequences ofdiffering amounts of rainfall on the ability of a grove of trees to survive. To keep things manageable, andto allow straightforward output formats to be employed, many of the aspects of the required simulationare greatly simplified. Nevertheless the underlying programming principles – use of two dimensionalarrays and graphical output visualizations – are important ones to master.Input file test1.tsv describes five trees in a tab-separated input format with one header line:label xloc yloc liters rootradA 14.8 23.8 18500 8.0G 18.8 28.1 20800 7.0F 24.1 22.2 31000 6.2C 35.3 19.9 28000 7.3E 16.5 10.5 15000 4.2For example, the third tree has the label F, has its trunk at location 24:1 meters east of the origin (positivex direction) and 22:2 meters north of the origin (positive y direction), requires 31;00 liters of water peryear to survive, and sends its roots out in all directions to a radius of 6:2 meters from the location of itstrunk. Each input file will contain at most 52 trees, with labels restricted to the letters ’a’ to ’z’ and’A’ to ’Z’. The trees are in no particular order in the file.Stage 1 – Reading the data (marks up to 6/20)In this stage you should read all of the data into internal structures suitable for use in the later stages.The required output of this stage is:mac: myass2 S1: total data lines = 5 treesS1: total water needed = 0.113 megaliters per yearHint: you should be able to get this stage going quite quickly starting from either your solution to thefirst project, or the sample solution to the first project. In either case you should acknowledge the sourceof any code that you have reused, even if it is your own.1Stage 2 – Multiway processing (marks up to 12/20)Define the catchment zone of a tree to be a circle centered on its trunk, of radius given by its rootradvalue. This is the area from which the tree is able to draw water. Two trees are in conflict if theircatchment zones overlap. In this case their roots may be interlinked and they are competing for rainwater.In this stage you are to check each tree in turn, and for each of them list all of the other trees in theinput with which they are in conflict. The required additional output for test1.tsv is:S2: tree A is in conflict with G FS2: tree G is in conflict with A FS2: tree F is in conflict with A G CS2: tree C is in conflict with FS2: tree E is in conflict withDistances between points should be calculated using the standard Euclidean formula: d(x1;y1;x2;y2) =p(x1 x2)2 +(y1 y2)2. You will need to include math.h, and use the -lm flag when compiling ondimefox: gcc -Wall -lm -o myass2 myass2.cStage 3 – Make a map (marks up to 16/20)Now let’s have some real fun. In order to help the arborists look after the trees, they would like a sketchmap of where the trees are located and where the conflict regions are. Suppose that the region currentlyof interest to the arborists is 70 meters wide (in the east-west direction) and 60 meters tall (north-southdirection), with the (0;0) origin at the south-west corner. To generate the plot, form. a grid that is 70cells/characters wide, and 30 characters tall (because printed characters are approximately twice as tallas they are wide). For example, the bottom-left cell in the grid is to represent the 1 meter wide (thatis, in the east-west direction) by 2 meter tall cell (that is, in the north-south direction) of land from[0 xBy considering the center point of every cell in the grid in turn, and asking (a) which of the trees thatcenter point is closest to, and (b) whether that center point is within the catchment zone of that tree, acharacter plot can be built up showing which tree “claims” that cell as part of its catchment. Note thatwhere there is conflict at the center point of a cell, the nearest tree claims the whole of that cell. Whenall cells have been considered and assigned (or not) to a tree, a plot can be output. For test1.tsv thetop third of the plot is all blanks, and (only) the bottom two thirds of the required output is as shown inFigure 1. Full examples are linked from the Assignment FAQ page.Note carefully the layout of the axes. The numbers that are printed indicate the x and y coordinatesof the lower-left (south-west) corner of the cells. There will thus never be any cell labels plotted in thetop row indicated by the 60 +, and in the right-hand column, above the 70. The character plotted in eachcell is the label of the tree that is closest to the midpoint of that cell, or blank if the midpoint of the cell isnot within the catchment zone of any of the trees. In all cases, it is assumed that if a cell is matched witha tree label, then all of any rainfall into that cell (totaling 2 square meters) is drawn to the correspondingtree by its roots.You should also assume that all of the trees that are specified in any input file will lie fully (includingtheir complete catchment zone) within the designated plot zone of [0 x note that the numbers 60 and 70 should be #define’d, and your program should operate correctly ifthey were altered to other values such as 50 and 60, provided that the input trees all fall in that smallerrectangle.Stage 4 – Let it rain! (marks up to 20/20)If rainfall of one millimeter occurs on one square meter of land, a total of one liter of water is available. Inthis stage, your program should access a total annual rainfall value in millimeters from the commandline2S3: 40 +S3: |S3: |S3: | GGS3: | GGGGGGGGGGS3: 30 + AGGGGGGGGGGGGGS3: | AAAAAGGGGGGGGGGGGS3: | AAAAAAAAAGGGGGGGGFFFF CCCS3: | AAAAAAAAAAAGGGFFFFFFFFFCCCCCCCCCCCS3: | AAAAAAAAAAAAFFFFFFFFFFFCCCCCCCCCCCCS3: 20 + AAAAAAAAAAAAFFFFFFFFFFFCCCCCCCCCCCCCS3: | AAAAAAAAAAAFFFFFFFFFFCCCCCCCCCCCCCCS3: | AAAAAAAA FFFFFF CCCCCCCCCCCCCS3: | CCCCCCCCCCCS3: | EEEEEEE CCCCCS3: 10 + EEEEEEEEES3: | EEEEEEES3: | EEEEES3: |S3: |S3: 0 +S3: +---------+代写asp编程、asp课程设计代写留学生、代做留学生comp20005 Engineering Computation---------+---------+---------+---------+---------+---------+S3: 0 10 20 30 40 50 60 70Figure 1: Partial output for Stage 3 for test1.tsv. See the LMS for full examples.used to run the program, and then check to see (using the reduced catchment zones calculated in Stage 3,including handling the conflicts via the cell-at-a-time approximation process) whether each tree will beable to survive based on that much rainfall. For example, referring again to test1.tsv and Figure 1,tree E has a total of 28 cells associated with it, or 56 square meters. Because tree E has no conflicts, itscomputed catchment zone is a reasonable approximation of the circular area r2 = 55:42 square meters.For the other trees in this example the catchment zones are reduced because of conflicts – for example,tree G has a catchment of 48 cells, or 96 square meters, much less than the circle defined by its root radius(which would be 153:9 square meters). Returning to tree E: it needs 15;000 liters per year, which means(following the calculations you are to perform) it can survive provided the annual rainfall is greater than15;000=56 = 267:9 millimeters. (As indicative reference points, Melbourne’s annual rainfall is about650 millimeters, and Sydney’s is 1200.)Define the stress factor of a tree to be the ratio between the required-for-survival rainfall and therainfall amount provided on the commandline. Trees with a stress factor greater than 1:0 will die; and inour simulation, they are to die in decreasing stress order. That means the death of one tree might reducethe stress on nearby trees once the conflicts are removed, allowing those other trees to shift to a lowerstress factor, and to live.To complete this stage, compute the stress factor for each tree for the rainfall amount given on thecommandline, and if all trees have a stress factor of less than or equal to 1:0, then no trees will die andthe process can finish. But if any trees have stress factors greater than 1:0, your program should identifythe tree with the highest stress factor, and note it as having “died”. You must then recalculate all of thecatchment zones, assuming that dead trees draw no water, and once that is done, all of the stress factors.The process should then be repeated, at each iteration “killing” the tree with the highest stress factorgreater than 1:0, and stopping once either all of the trees are dead, or when every surviving tree has acatchment that allows it to survive on the amount of rainfall that was specified on the commandline.The output of this stage should report the sequence of trees that have died, and then draw anotherplot to illustrate the final tree arrangement. See the examples linked from the FAQ page for full detailsof what is required.3Modifications to the SpecificationThere are bound to be areas where this specification needs clarification or correction. Refer to theFAQ page at http://people.eng.unimelb.edu.au/ammoffat/teaching/20005/ass2/ regularlyfor updates to these instructions. There is already a range of information provided there that you need tobe aware of, with more to follow.The Boring Stuff...This project is worth 20% of your final mark. A rubric explaining the marking expectations will beprovided on the FAQ page.You need to submit your program for assessment; detailed instructions on how to do that will beposted on the LMS once submissions are opened. Submission will not be done via the LMS; instead youwill need to log in to a Unix server and submit your files to a software system known as submit. You can(and should) use submit both early and often – to get used to the way it works, and also to check thatyour program compiles correctly on our test system, which has some different characteristics to the labmachines. Failure to follow this simple advice is highly likely to result in tears. Only the last submissionthat you make before the deadline will be marked.You may discuss your work during your workshop, and with others in the class, but what gets typedinto your program must be individual work, not copied from anyone else. So, do not give hard copyor soft copy of your work to anyone else; do not “lend” your “Uni backup” memory stick to othersfor any reason at all; and do not ask others to give you their programs “just so that I can take a lookand get some ideas, I won’t copy, honest”. The best way to help your friends in this regard is to say avery firm “no” when they ask for a copy of, or to see, your program, pointing out that your “no”, andtheir acceptance of that decision, is the only thing that will preserve your friendship. A sophisticatedprogram that undertakes deep structural analysis of C code identifying regions of similarity will be runover all submissions in “compare every pair” mode. Students whose programs are so identified will bereferred to the Student Center for possible disciplinary action without further warning. This message isthe warning. See https://academicintegrity.unimelb.edu.au for more information. Note alsothat solicitation of solutions via posts to online forums, whether or not there is payment involved, is alsotaken very seriously. In the past students have had their enrolment terminated for such behavior.Deadline: Programs not submitted by 10:00am on Monday 21 May will lose penalty marks at therate of two marks per day or part day late. Students seeking extensions for medical or other “outsidemy control” reasons should email as soon as possible after those circum-stances arise. If you attend a GP or other health care professional as a result of illness, be sure to takea Health Professional Report form. with you (get it from the Special Consideration section of the Stu-dent Portal), you will need this form. to be filled out if your illness develops in to something that laterrequires a Special Consideration application to be lodged. You should scan the HPR form. and send it inconnection with any non-Special Consideration assignment extension requests.Marks and a sample solution should be available on the LMS by Monday 4 June.Disclaimer: None of the “facts” about trees and their water requirements given here are reliable, and itis all just a story I made up to motivate the project. In particular, when it rains, the water runs downhill,making land contours an important additional factor, and different soils and undergrowth have differentabsorption rates. As well, trees need varying amounts of water according to the temperature, and theirsize, and their age, and the growing season, and etc, dozens of different factors; and trees can alsosometimes withstand one or more drought years before becoming eventually threatened. They alsosometimes get too much water and drown to death. Indeed, this project description is misleading inso many different ways that a horticulture student would laugh themselves silly if they read it. Hopefullyyou don’t know any horticulture students, and will just have fun writing the program转自:http://ass.3daixie.com/2018052758777214.html
讲解:asp、asp、comp20005 Engineering Computation
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...