程序代写代做代考 python algorithm MATH6005 COURSEWORK 1

MATH6005 COURSEWORK 1

MATH6005 Introduction to Python

Coursework ·· – Technical Document

Notation

Denote the starting coordinates of the support ship by (xso, Yso) and its speed by so

Consider ship i in the task force, where 1 –<; i -<; n. Denote its starting coordinates by (x,o, Yw). Its velocity is split into x- and y-components, Vix and Viy , respectively. Therefore the position of ship i at time t > 0 is given by

(xit, Yit) = (xio + tv,x, Yio + tv,y)­

N ote that the speed of ship i is given by

1 Calculating intercept times

To calculate intercept times, it is simplest to reset the timescale so that (xso, Yso) represents
the current coordinates of the support ship and (xw, Yw) represents the current coo;dinates of
ship i for 1 –<; i -<; n. Then the time, T , taken for the support ship to intercept ship i is found by finding the smallest positive root of the quadratic equation aT2 +bT+c, where a= vf x + V[ y - s5 , b = 2(v,x(x,o - Xso) + Viy(Yw - Yso)) and c = (x,o - x,o) 2 + (y,o -Yso)2• 2 User inputs The workbook should contain a user-interface (UI) implemented using a single UserForm. The UI should • Ask the user to specify the filename. • Display the size of the dataset. • Ask the user to run the heuristics - this should only happen if there is a valid data set in memory. • Display the result of the most recent run of the greedy heuristic (i.e. the time the last ship was intercepted). • Write the solution to a CSV file. Note that this should only be done when a valid dataset is in memory and the algorithm has been run successfully on it. MATH6005 C 2 3 Input Data The input data for each problem instance will be presented in a comma separated value ( CSV) file. A correctly-formatted input file consists of N rows of data, where N ;,. 2. Row 1 corre­ sponds to the support ship and consists of three pieces of information in the following order: 1. Start x-coordinate (real numeric data type). 2. Start y-coordinate (real numeric data type). 3. Ship speed (real numeric data type). Rows 2, ... , N correspond to ships 1, ... , N - 1 , each containing five pieces of information in the following order: 1. Ship name/description (string data type). 2. Start x-coordinate (real numeric data type). 3. Start y-coordinate (real numeric data type). 4. Velocity x-component (real numeric data type). 5. Velocity y-component (real numeric data type). Note that it is assumed that the data conforms to U.S. and U.K. regional settings in which the decimal separator is represented by a full stop (.) symbol. 4 Data validation When validating an input file, you must check that: • There is at least one ship in the task force. • Each row conforms to the specified_ format, including data types. • There are a suitable number of rows. • The support ship is faster than all ships 1n the task force. 3 MATH6005 6 Output results to a CSV file. You should write data to a CSV file only after user input. • Output results: The ships in the task force should be sorted in the sequence of interception, specifying the time and location of each interception.