美文网首页
讲解:comp20005、Information Systems

讲解:comp20005、Information Systems

作者: kuijinzhong | 来源:发表于2020-01-12 11:43 被阅读0次

    School of Computing and Information Systemscomp20005 Engineering ComputationSemester 1, 2019Assignment 1Learning OutcomesIn this project you will demonstrate your understanding of loops, if statements, functions, and arrays,by writing a program that first reads a file of text data, and then performs a range of processing tasks onthe data. The sample solution that will be provided to you after the assignment has been completed willalso make use of structures (covered in Chapter 8), and you may do likewise if you wish. But there is norequirement for you to make use of struct types, and they will not have been covered in lectures beforethe due date.Sequential DataScientific and engineering datasets are often stored in text files using comma separated values (.csvformat) or tab separated values (.tsv format), usually with a header line describing the contents of thecolumns. A standard processing framework on such data is to first read the complete set of input rowsinto arrays, one array per column of data, and then pass those arrays (and a buddy variable) into functionsthat perform various computations based on the arrays.Your task in this project is to compute delivery sequences for Alistazon, a start-up company that isplanning to use drones to deliver parcels to customers. Each batch of deliveries is described by a filethat has one row of numbers for each package that has to be delivered. In the examples that follow wesuppose that the data file drones0.tsv contains these values in tab-separated format:x y kg150.6 -185.2 2.5113.9 500.9 4.15-31.6 51.9 4.31-58.2 190.3 5.7-27.8 312.6 1.95There will always be a single header line in all input files, and then rows of three values separated by“tab” characters (’\t’ in C). Once the first line has been bypassed (write a function that reads charactersand throws them away until it reads and throws away a newline character, ’\n’), each data line can beread using scanf(%lf%lf%lf,...). The three values in each row represent an (x, y) location ona east-west/north-south grid, in units of meters relative to an origin, and a package weight, in units ofkilograms. This example file and another one drones1.tsv can be copied from http://people.eng.unimelb.edu.au/ammoffat/teaching/20005/ass1/.Stage 1 – Control of Reading and Printing (marks up to 4/10)The first version of your program should read the entire input dataset into a collection of three parallelarrays (or, if you are adventurous, an array of struct), counting the data rows as they are read. Theheading line should be discarded and is not required for any of the subsequent processing steps. Oncethe entire dataset has been read, your program should print the total number of data lines that were read,the first and last of the input records, and the total of the package weights. The output from your programfor this stage for file drones0.tsv must be:mac: myass1 S1, total data lines: 51S1, first data line : x= 150.6, y=-185.2, kg=2.50S1, final data line : x= -27.8, y= 312.6, kg=1.95S1, total to deliver: 18.61 kgNote that the input is to be read from stdin in the usual manner, via “level; and that you must not make use of the file manipulation functions described in Chapter 11. Noprompts are to be written.You may (and should) assume that at most 999 data lines will occur in any input file, not countingthe header line. Note that to obtain full marks you need to exactly reproduce the required output lines.Full output examples can be found on the FAQ page linked from the LMS.Stage 2 – Sequential Processing (marks up to 7/10)The Alistazon drones are battery powered, and can carry up to 5.8 kilograms each in addition to the 3.8kilogram weight of the drone itself. (Future models may be able to carry more, but this is the currentlimit.) When the drone is carrying a payload of w kilograms, a fully-charged battery pack allows thedrone to safely fly a total of 6300/(3.8 + w) meters. That is, an unladen drone can safely travel a total of6300/3.8 = 1657.9 meters, whereas a fully laden drone can only safely fly 6300/(3.8 + 5.8) = 656.3meters. The drones fly at a constant speed of 4.2 meters/second, regardless of what load they are carrying,and always fly in a straight line from one specified location to another.As an example, suppose that a fully-charged drone starts at location (0, 0) and is to carry out the firstdelivery in the list in drones0.txt. The distance to be flown can be computed asq(150.6 0.0)2 + (185.2 0.0)2) = 238.7 meters.On the outward trip, before the delivery takes place made, the drone plus package has a weight of3.8 + 2.5 = 6.3 kg, and hence the drone range is given by 6300/6.3 = 1000.0 meters. That is, theoutward trip to the delivery point will consume 238.7/1000.0 = 23.9% of the available battery power.On the return trip back to the origin, after the delivery has been made, the drone is lighter, and consumesanother 238.7/1657.9 = 14.4% of the battery capacity. The round trip to complete the first delivery willhave a flight time of 2×238.7/4.2 = 113.7 seconds, and will consume a total of 23.9 + 14.4% = 38.3%of a full battery charge.Add further functionality to your program to carry out these calculations for each package, and totell the operators when the battery pack needs to be changed. You should assume that each deliverycommences at and returns to the origin (0, 0), and that the packages are delivered in the same order theyare listed in the data file. For drones0.tsv, your output from this stage should be:S2, package= 0, distance= 238.7m, battery out=23.9%, battery ret=14.4%S2, change the batteryS2, package= 1, distance= 513.7m, battery out=64.8%, battery ret=31.0%S2, change the batteryS2, package= 2, distance= 60.8m, battery out= 7.8%, battery ret= 3.7%S2, package= 3, distance= 199.0m, battery out=30.0%, battery ret=12.0%S2, change the batteryS2, package= 4, distance= 313.8m, battery out=28.6%, battery ret=18.9%S2, total batteries required: 4S2, total flight distance=2652.0 meters, total flight time= 631 secondsNote how the large demand associated with package 1 forces a battery change straight after package 0,even though less than half the battery capacity was used. In contrast, packages 2 and 3 are able to bedelivered on a single battery.Before implementing this step, you should read the rest of the specification, to understand what elsewill be required as your program develops. Code should be shared between the stages through the use of2functions wherever it is possible to do so. In particular, there shouldn’t be long (or even short) stretchesof repeated or similar code appearing in different places in your program. Functions should also be usedto break up long runs of code, to make them more understandable, even if those functions are only calledonce. As a general rule of thumb, functions shouldn’t be longer tha代做comp20005作业、代写Information Systems作业、C++编程语言作业调试、代做C++课程作业 n a single screen in the editor. If theyare, break that code up further into smaller functions. It is also completely ok to have functions that arejust one or two lines long.Your program should print an error message and exit if any of the packages would require more than100% of a fully charged battery to be delivered, or if any package weighs more than 5.8 kilograms.Stage 3 – Non-Sequential Processing (marks up to 9/10)Ok, so now let’s try and make better use of each battery. Add further functionality to your program sothat after each delivery has been completed, all of the remaining undelivered packages are considered inturn, and if any of them can be delivered using the current battery, that delivery is carried out next.That is, for each fully charged battery, you should consider the entire list of packages in order, startingat the beginning, and each package that can be delivered using the power still available in that batteryshould be delivered. The battery is changed to a fresh one only when there are no remaining packagesthat can be delivered using the old battery.The required output for drones0.tsv is (hint, hint) similar in format to the Stage 2 output:S3, package= 0, distance= 238.7m, battery out=23.9%, battery ret=14.4%S3, package= 2, distance= 60.8m, battery out= 7.8%, battery ret= 3.7%S3, package= 3, distance= 199.0m, battery out=30.0%, battery ret=12.0%S3, change the batteryS3, package= 1, distance= 513.7m, battery out=64.8%, battery ret=31.0%S3, change the batteryS3, package= 4, distance= 313.8m, battery out=28.6%, battery ret=18.9%S3, total batteries required: 3S3, total flight distance=2652.0 meters, total flight time= 631 secondsStage 4 – A Further Generalization (marks up to 10/10)Stages 2 and 3 assumed that all deliveries were to start from the origin point at (0, 0), maybe because thatis where the Alistazon warehouse is located. But a smart employee (that had taken comp20005 whilestudying at University) has pointed out that maybe it could be better to put a batch of deliveries into avan, drive to some more useful location, and then do the deliveries from that point. They suggest that anappropriate starting point could be found by computingas a kind of “centroid” location of the n delivery locations (xi, yi). The same package delivery approachas was used for Stage 3 would then be followed. The required output for this stage for drones0.tsv is:S4, centroid location x= 29.4m, y= 174.1mS4, package= 0, distance= 379.2m, battery out=37.9%, battery ret=22.9%S4, package= 2, distance= 136.6m, battery out=17.6%, battery ret= 8.2%S4, change the batteryS4, package= 1, distance= 337.6m, battery out=42.6%, battery ret=20.4%S4, package= 3, distance= 89.1m, battery out=13.4%, battery ret= 5.4%S4, change the batteryS4, package= 4, distance= 149.8m, battery out=13.7%, battery ret= 9.0%S4, total batteries required: 3S4, total flight distance=2184.5 meters, total flight time= 520 seconds3The FAQ page contains links to full output examples that show how the output from the stages is toappear overall. Note the final output line at the end of each execution it is also required.Modifications 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/ass1/ 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 10% of your final mark. A rubric explaining the marking expectations is linkedfrom the FAQ page, and you should read it carefully.You need to submit your program for assessment; detailed instructions on how to do that are linkedfrom the FAQ page. Submission will not be done via the LMS; instead you need to log in to a Unixserver and make use of a system known as submit. You can (and should) use submit both early andoften – to get used to the way it works, and also to check that your program compiles correctly on the testserver, which has some different characteristics to the lab machines. Failure to follow this simple adviceis likely to result in tears. Only the last submission that 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. Students whose programs are identified as containing significant overlaps will beevaluated for mark penalties of for referral to the Student Center for possible disciplinary action withoutfurther warning. This message is the warning. See https://academicintegrity.unimelb.edu.aufor more information. Note also that solicitation of solutions via posts to online forums, whether or notthere is payment involved, is also taken very seriously. In the past students have had their enrolmentterminated for such behavior.Very Important: The FAQ page contains a link to a program skeleton that you must start with,including an Authorship Declaration that you must “sign” and include at the top of your submittedprogram. Marks will be deducted if you do not include the declaration, or do not sign it, or do notcomply with its expectations.Deadline: Programs not submitted by 10:00am on Monday 6 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 ammoffat@unimelb.edu.au as soon as possible after those circumstancesarise. 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 StudentPortal), 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 will be available on the LMS by Monday 20 May.And remember, programming is fun!c The University of Melbourne, 2019. Prepared by Alistair Moffat, ammoffat@unimelb.edu.au.4转自:http://www.7daixie.com/2019050657138611.html

    相关文章

      网友评论

          本文标题:讲解:comp20005、Information Systems

          本文链接:https://www.haomeiwen.com/subject/lgmiactx.html