何为优秀的essay？
有一个精彩的开头。虽然无论essay开头如何，导师都会读下去，但一个精彩的、引人入胜的开头，无疑能在很大程度上增加导师的阅读兴趣，为文章增色不少。而导师带着兴趣阅读下去，主动寻找文章的逻辑和主线，还能够更加容易理解文章内容。这种方法特别适合英语表达能力还有待提升的学生。
重点突出。能够让人一眼就看出文章的观点是什么、重点是什么，且文章内容都是围绕中心店展开的。一般情况下，essay都是议论文，建议采取的结构是总分总。在开头亮出观点，然后详细论证观点，最后再总结。这种结构写作简单且容易理解，非常实用。
逻辑清晰。逻辑是文章的重点，如果逻辑不清，文章就会显得混乱。在essay写作中，常见的逻辑方式有时间顺序、距离顺序、大小顺序、因果等。其中叙事上最常用时间顺序，即文章的写作是按照时间发展顺序展开的。而在论述上，则必须遵循因果原则，论据应该为论点服务，两者一定要求因果关系。
句式灵活多变。在essay中，虽然对句式的要求不太严格，但若想出彩，必须要做到句式多变。而且西方国家都喜欢简洁、准确的表述，因此在句式选择上，尽量简短的，切勿使用过程的从句。此外，还要注意句式的丰富性，进行选用新颖的，写作中也要避免重复。毕竟无论是中文还是英文，重复都会让人感觉无趣，甚至产生审美疲劳。
有新颖的思想。思想是essay的灵魂，一篇优秀的essay，必然蕴含作者新颖的、有创造性的思想，这也是导师最看重的内容。如果其中的思想能吸引到导师，即使essay中会有一些其他的瑕疵，也会获得很高的评价。
如何提高essay优秀度– Essay写作技巧
看完上文内容，相信大家已经对essay写作要点有了一定的了解。但如何写好essay呢？
一定要认真审题。
只有深入了解题目，才能选择正确的写作方向。很多导师在布置essay的时候都会给出提示，这些提示很重要，一定要仔细看完后再下笔写作。如果盲目写作，即使写的再好，文不对题肯定也是不合格。
尽量提前写essay。
在拿到老师布置的题目以后，要第一时间开始准备写作。导师布置的essay基本都会和近期的课程相关，写的越早，难度就越小。而且这样还可以保持时间充裕，能够更好地搜集资料，最后还有时间修改。如果到邻近交稿时间才开始写，仓促的时间下准备肯定不充分，再加上紧张的心情，严重影响论文质量。
多阅读essay范文。
写作之前可以多找一些相关的范文进行阅读，学习别人的写作方法，同时也会更了解essay的要求。
]]>
报名请填写以下相关信息：
[contact-form]
或扫描以下微信二维码报名：
]]>
Executive Summary (½ page)
Introduction (1 page)
Final Design and Implementation (5-6 pages)
Analysis of Final Testing Results (2-3 pages)
Conclusions & Recommendations (1 page)
Suggested Delegation:
Louisa: Executive Summary, introduction, conclusion, recommendations (2.5 pages)
Harvey: Final Design/Implementation: how each part was constructed/put together; accurate diagrams/listing of materials (2 pages)
Wilson: Final Design/Implementation: circuit diagrams + programming; problems that were overcome (2 pages)
Hermes: Final Design/Implementation: Explain decisions made, total cost, ease/cost of manufacture (2 pages)
Leo: Analysis of final testing results: statement of results, how each aspect of design contributed, reasons for the team’s result (1.5-2 pages)
Tina: Analysis of final results: comparison of original with final design, what was learned during testing, limitations that were not originally obvious (1.5-2 pages)
Recommendations/References/Formatting appendices
References (1 page) – need some references!! We get marked down if there aren’t enough references (dw I got this ~Harvey)
Assuming max number of pages written, there are 4 pages for appendices (20 page limit)
These questions must be completed under self-administered exam-like conditions.
You must time the test yourself and ensure you comply with the conditions below.
You may access this language documentation while attempting this test:
Any violation of the test conditions will results in a mark of zero for the entire weekly test component.
Download count_even_list.c, the starting code for this exercise or use this cp command:
cp -n /web/cs1511/18s1/activities/count_even_list/count_even_list.c .
Note count_even_list.c uses the following familiar data type:
struct node { struct node *next; int data; };
Your task is to add code to this function:
int count_even(struct node *head) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
count_even is given one argument, head, which is the pointer to the first node in a linked list.Add code to count_even so that its returns the number of even values in the linked list.
For example if the linked list contains these 8 elements:
16, 7, 8, 12, 13, 19, 21, 12
count_even should return 4, because these 4 elements are even:
16, 8, 12, 12
count_even_list.c also contains a main function which allows you to test your count_even function.This main function:
Do not change this main function. If you want to change it, you have misread the question.
Your count_even function will be called directly in marking. The main function is only to let you test your count_even function
Here is how you use main function allows you to test count_even:
cp -n /web/cs1511/18s1/activities/count_even_list/count_even_list.c . dcc count_even_list.c -o count_even_list ./count_even_list 16 7 8 12 13 19 21 12 4 ./count_even_list 2 4 6 2 4 6 6 ./count_even_list 3 5 7 11 13 15 17 19 23 29 0 ./count_even_list 2 4 8 16 32 64 128 256 8 ./count_even_list 0
An even number is divisible by 2.count_even should return a single integer.
count_even should not change the linked list it is given. Your function should not change the next or data fields of list nodes.
count_even should not use arrays.
count_even should not call malloc.
count_even should not call scanf (or getchar or fgets).
You can assume the linked list only contains positive integers.
count_even should not print anything. It should not call printf.
Do not change the supplied main function. It will not be tested or marked.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest count_even_list
98% of 366 students who have autotested count_even_list.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test11_count_even_list count_even_list.c
Download list_intersection_size.c, the starting code for this exercise or use this cp command:
cp -n /web/cs1511/18s1/activities/list_intersection_size/list_intersection_size.c .
Note list_intersection_size.c uses the following familiar data type:
struct node { struct node *next; int data; };
Your task is to add code to this function:
int intersection_size(struct node *head1, struct node *head2) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
intersection_size is given two arguments, head1 and head2, which are pointers to the first node of linked lists.Add code to intersection_size so that its returns the number of values that occur in both linked list.
Assume no value occurs more than once in either linked list.
For example, if the two lists contain these values:
3, 1, 4 2, 7, 1, 8, 3
intersection_size should return 2, because these 2 elements occur in both lists:
1, 3
list_intersection_size.c also contains a main function which allows you to test your intersection_size function.This main function:
Do not change this main function. If you want to change it, you have misread the question.
Your intersection_size function will be called directly in marking. The main function is only to let you test your intersection_size function
Here is how the main function allows you to test intersection_size:
cp -n /web/cs1511/18s1/activities/list_intersection_size/list_intersection_size.c . dcc list_intersection_size.c -o list_intersection_size ./list_intersection_size 3 1 4 - 2 7 1 8 3 2 ./list_intersection_size 16 7 8 12 - 13 19 21 12 1 ./list_intersection_size 2 4 6 - 2 4 6 3 ./list_intersection_size 3 5 7 11 13 - 15 17 19 23 29 0 ./list_intersection_size 1 2 3 4 - 3 2 1 3 ./list_intersection_size - 1 2 3 4 0 ./list_intersection_size 4 3 2 1 - 0 ./list_intersection_size - 0
intersection_size should return a single integer.No value will occur more than once in either linked list.
intersection_size should not change the linked lists it is given. Your function should not change the next or data fields of list nodes.
intersection_size should not use arrays.
intersection_size should not call malloc.
intersection_size should not call scanf (or getchar or fgets).
intersection_size should not print anything. It should not call printf.
Do not change the supplied main function. It will not be tested or marked.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest list_intersection_size
96% of 348 students who have autotested list_intersection_size.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test11_list_intersection_size list_intersection_size.c
Download most_frequent_list.c, the starting code for this exercise or use this cp command:
cp -n /web/cs1511/18s1/activities/most_frequent_list/most_frequent_list.c .
Note most_frequent_list.c uses the following familiar data type:
struct node { struct node *next; int data; };
Your task is to add code to this function:
int most_frequent(struct node *head) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
most_frequent is given one argument, head, which is the pointer to the first node in a linked list.Add code to most_frequent so that its returns the most frequently occuring value in the linked list.
For example if the linked list contains these 8 elements:
655 10 204 8192 76 38 204 43912 204
most_frequent should return 204, because it is the most frequently occurring integer — it appears 3 times.
For example if the linked list contains these 8 elements:
7 8 12 3 12 3 8
most_frequent should return 8.
There is a tie for most frequently occurring integer – 3, 8 and 12 all occur twice.
8 occurred first in the list so it should be returned.
You are not permitted to use arrays or malloc in your function.
most_frequent_list.c also contains a main function which allows you to test your most_frequent function.This main function:
Do not change this main function. If you want to change it, you have misread the question.
Your most_frequent function will be called directly in marking. The main function is only to let you test your most_frequent function
Here is how you the main function allows you to test most_frequent:
cp -n /web/cs1511/18s1/activities/most_frequent_list/most_frequent_list.c . dcc most_frequent_list.c -o most_frequent_list ./most_frequent_list 655 10 204 8192 76 38 204 43912 204 204 ./most_frequent_list 5 4 6 5 4 6 5 ./most_frequent_list 3 5 7 11 13 15 3 17 19 23 29 13 3 3
most_frequent should return a single integer.most_frequent should not change the linked list it is given. Your function should not change the next or data fields of list nodes.
most_frequent should not use arrays.
most_frequent should not call malloc.
most_frequent should not call scanf (or getchar or fgets).
You can assume the linked list contains at least one integer.
most_frequent should not print anything. It should not call printf.
Do not change the supplied main function. It will not be tested or marked.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest most_frequent_list
95% of 300 students who have autotested most_frequent_list.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test11_most_frequent_list most_frequent_list.c
When you are finished each exercise make sure you submit your work by running give.You can run give multiple times. Only your last submission will be marked.
Don’t submit any exercises you haven’t attempted.
If you are working at home, you may find it more convenient to upload your work via give’s web interface.
Remember you have until Friday 25 May 23:59:59 to complete this test.
Automarking will be run several days after the submission deadline for the test. When complete you can view automarking here and you can view the the resulting mark via give’s web interface
]]>
These questions must be completed under self-administered exam-like conditions.
You must time the test yourself and ensure you comply with the conditions below.
You may access this language documentation while attempting this test:
Any violation of the test conditions will results in a mark of zero for the entire weekly test component.
cp -n /web/cs1511/18s1/activities/count_even_list/count_even_list.c .
Note count_even_list.c uses the following familiar data type:
struct node { struct node *next; int data; };
Your task is to add code to this function:
int count_even(struct node *head) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
count_even is given one argument, head, which is the pointer to the first node in a linked list.Add code to count_even so that its returns the number of even values in the linked list.
For example if the linked list contains these 8 elements:
16, 7, 8, 12, 13, 19, 21, 12
count_even should return 4, because these 4 elements are even:
16, 8, 12, 12
count_even_list.c also contains a main function which allows you to test your count_even function.This main function:
Do not change this main function. If you want to change it, you have misread the question.
Your count_even function will be called directly in marking. The main function is only to let you test your count_even function
Here is how you use main function allows you to test count_even:
cp -n /web/cs1511/18s1/activities/count_even_list/count_even_list.c . dcc count_even_list.c -o count_even_list ./count_even_list 16 7 8 12 13 19 21 12 4 ./count_even_list 2 4 6 2 4 6 6 ./count_even_list 3 5 7 11 13 15 17 19 23 29 0 ./count_even_list 2 4 8 16 32 64 128 256 8 ./count_even_list 0
An even number is divisible by 2.count_even should return a single integer.
count_even should not change the linked list it is given. Your function should not change the next or data fields of list nodes.
count_even should not use arrays.
count_even should not call malloc.
count_even should not call scanf (or getchar or fgets).
You can assume the linked list only contains positive integers.
count_even should not print anything. It should not call printf.
Do not change the supplied main function. It will not be tested or marked.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest count_even_list
98% of 366 students who have autotested count_even_list.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test11_count_even_list count_even_list.c
cp -n /web/cs1511/18s1/activities/list_intersection_size/list_intersection_size.c .
Note list_intersection_size.c uses the following familiar data type:
struct node { struct node *next; int data; };
Your task is to add code to this function:
int intersection_size(struct node *head1, struct node *head2) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
intersection_size is given two arguments, head1 and head2, which are pointers to the first node of linked lists.Add code to intersection_size so that its returns the number of values that occur in both linked list.
Assume no value occurs more than once in either linked list.
For example, if the two lists contain these values:
3, 1, 4 2, 7, 1, 8, 3
intersection_size should return 2, because these 2 elements occur in both lists:
1, 3
list_intersection_size.c also contains a main function which allows you to test your intersection_size function.This main function:
Do not change this main function. If you want to change it, you have misread the question.
Your intersection_size function will be called directly in marking. The main function is only to let you test your intersection_size function
Here is how the main function allows you to test intersection_size:
cp -n /web/cs1511/18s1/activities/list_intersection_size/list_intersection_size.c . dcc list_intersection_size.c -o list_intersection_size ./list_intersection_size 3 1 4 - 2 7 1 8 3 2 ./list_intersection_size 16 7 8 12 - 13 19 21 12 1 ./list_intersection_size 2 4 6 - 2 4 6 3 ./list_intersection_size 3 5 7 11 13 - 15 17 19 23 29 0 ./list_intersection_size 1 2 3 4 - 3 2 1 3 ./list_intersection_size - 1 2 3 4 0 ./list_intersection_size 4 3 2 1 - 0 ./list_intersection_size - 0
intersection_size should return a single integer.No value will occur more than once in either linked list.
intersection_size should not change the linked lists it is given. Your function should not change the next or data fields of list nodes.
intersection_size should not use arrays.
intersection_size should not call malloc.
intersection_size should not call scanf (or getchar or fgets).
intersection_size should not print anything. It should not call printf.
Do not change the supplied main function. It will not be tested or marked.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest list_intersection_size
96% of 348 students who have autotested list_intersection_size.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test11_list_intersection_size list_intersection_size.c
cp -n /web/cs1511/18s1/activities/most_frequent_list/most_frequent_list.c .
Note most_frequent_list.c uses the following familiar data type:
struct node { struct node *next; int data; };
Your task is to add code to this function:
int most_frequent(struct node *head) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
most_frequent is given one argument, head, which is the pointer to the first node in a linked list.Add code to most_frequent so that its returns the most frequently occuring value in the linked list.
For example if the linked list contains these 8 elements:
655 10 204 8192 76 38 204 43912 204
most_frequent should return 204, because it is the most frequently occurring integer — it appears 3 times.
For example if the linked list contains these 8 elements:
7 8 12 3 12 3 8
most_frequent should return 8.
There is a tie for most frequently occurring integer – 3, 8 and 12 all occur twice.
8 occurred first in the list so it should be returned.
You are not permitted to use arrays or malloc in your function.
most_frequent_list.c also contains a main function which allows you to test your most_frequent function.This main function:
Do not change this main function. If you want to change it, you have misread the question.
Your most_frequent function will be called directly in marking. The main function is only to let you test your most_frequent function
Here is how you the main function allows you to test most_frequent:
cp -n /web/cs1511/18s1/activities/most_frequent_list/most_frequent_list.c . dcc most_frequent_list.c -o most_frequent_list ./most_frequent_list 655 10 204 8192 76 38 204 43912 204 204 ./most_frequent_list 5 4 6 5 4 6 5 ./most_frequent_list 3 5 7 11 13 15 3 17 19 23 29 13 3 3
most_frequent should return a single integer.most_frequent should not change the linked list it is given. Your function should not change the next or data fields of list nodes.
most_frequent should not use arrays.
most_frequent should not call malloc.
most_frequent should not call scanf (or getchar or fgets).
You can assume the linked list contains at least one integer.
most_frequent should not print anything. It should not call printf.
Do not change the supplied main function. It will not be tested or marked.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest most_frequent_list
95% of 300 students who have autotested most_frequent_list.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test11_most_frequent_list most_frequent_list.c
Don’t submit any exercises you haven’t attempted.
If you are working at home, you may find it more convenient to upload your work via give’s web interface.
Remember you have until Friday 25 May 23:59:59 to complete this test.
Automarking will be run several days after the submission deadline for the test. When complete you can view automarking here and you can view the the resulting mark via give’s web interface
You must time the test yourself and ensure you comply with the conditions below.
You may access this language documentation while attempting this test:
Any violation of the test conditions will results in a mark of zero for the entire weekly test component.
Write a C program line_char.c
which reads a line from its input then reads an integer n from its input.It should write the character in position n from the line in the format given in the examples below.
Your program should then exit – it should not read more lines.
For example:
dcc -o line_char line_char.c ./line_char abcdefghijklmnopqrstuvwxyz 0 The character in position 0 is 'a' ./line_char abcdefghijklmnopqrstuvwxyz 13 The character in position 13 is 'n' ./line_char abcdefghijklmnopqrstuvwxyz 25 The character in position 25 is 'z' ./line_char Andrew Rocks! 6 The character in position 6 is ' ' ./line_char Andrew Rocks! 7 The character in position 7 is 'R' ./line_char Andrew Rocks! 12 The character in position 12 is '!'
No error checking is necessary.You can assume a line can be read.
You can assume the line will contain at mnost 256 characters.
You can assume a positive integer n can be read.
You can assume the line read has at least n characters.
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest line_char
98% of 761 students who have autotested line_char.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test10_line_char line_char.c
Write a C program reverse_lines.c
which reads lines and writes them out with the characters of each line in reverse order. It should stop when it reaches the end of input.For example:
dcc -o reverse_lines reverse_lines.c ./reverse_lines Two roads diverged in a yellow wood, ,doow wolley a ni degrevid sdaor owT And sorry I could not travel both htob levart ton dluoc I yrros dnA And be one traveler, long I stood doots I gnol ,relevart eno eb dnA To where it bent in the undergrowth; ;htworgrednu eht ni tneb ti erehw oT You don't make friends with salad. .dalas htiw sdneirf ekam t'nod uoY
You can assume lines will contain at most 256 characters.You can assume lines are terminated with a newline (‘\n’) character,
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest reverse_lines
86% of 735 students who have autotested reverse_lines.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test10_reverse_lines reverse_lines.c
Write a C program remove_repeated_lines.c
which reads lines and prints them unless it has seen exactly the same line previously.In other words it doesn’t print repeated lines. It prints our only the first occurance of any line.
It should stop when it reaches the end of input.
For example:
dcc -o remove_repeated_lines remove_repeated_lines.c ./remove_repeated_lines one one hello world hello world two two one hello world two hello hello ./remove_repeated_lines Na, na, na, na, na Na, na, na, na, na Na, na, na Na, na, na Na, na, na, na, na Na, na, na Do, do, do, do, do, Do, do, do, do, do, Do, do, do Do, do, do Do, do, do, do, do, Do, do, do
You can assume lines will contain at most 256 characters.You assume at most 256 lines will be read before end-of-input.
You can assume lines are terminated with a newline (‘\n’) character,
When you think your program is working you can autotest
to run some simple automated tests:
1511 autotest remove_repeated_lines
86% of 503 students who have autotested remove_repeated_lines.c so far, passed all autotest tests.
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test10_remove_repeated_lines remove_repeated_lines.c
When you are finished each exercise make sure you submit your work by running give.You can run give multiple times. Only your last submission will be marked.
Don’t submit any exercises you haven’t attempted.
If you are working at home, you may find it more convenient to upload your work via give’s web interface.
Remember you have until Thursday 17 May 23:59:59 to complete this test.
Automarking will be run several days after the submission deadline for the test. When complete you can view automarking here and you can view the the resulting mark via give’s web interface
]]>
al statement
Assessment
This lab has three parts: Parts A to C. You need to show your tutors all three parts.
There is also an online multiple choice question which is worth 1 mark. We suggest that you attempt this question after completing Parts A-C.
Excel in CSE lab environment and workbook
In order to use Excel in the CSE lab environment, you need to do the following.
• First login as usual
• After logging in, click on the Windows 10 icon. This will transfer you to a Microsoft Windows environment.
• Click on the Firefox icon to start the browser. Near the top-left hand corner, you will see a bookmark tab labelled ENGG1811. Click on that to take you to the ENGG1811 website. Navigate to Lab 12.
• You will need to download and complete your work in this workbook. When you click on the link, a dialogue box will pop up, choose the option “Save File” to save the file on the desktop. If you double click on the file icon, Excel will start.
IMPORTANT NOTE: The CSE Microsoft Windows environment does NOT preserve your Excel workbook after logging out. This means if you log out from the Windows environment and log back in again the next time, the Excel file on the desktop will NOT be there anymore. We recommend that after you have completed your lab, you save your Excel notebook on a portable drive or online storage so that you can keep a copy.
Note: You cannot use the CSE vlab system to access the Windows environment. The above instructions only work for a computer located inside a physical CSE lab.
Part A: Freefall
In Week 3’s lecture, you used a formula to determine the speed of a falling object over time using Python. In this exercise, you will do the same using Excel.
The parameters of the problems are:
• Mass of the object m
• Acceleration due to gravity g
• Drag coefficient of air cair
The above three parameter values are given (shown) in the picture below.
The speed v(t) of the falling object at time t is given by the formula:
You are asked to complete your work in the worksheet Freefall. The steps are:
Step 1: There are four yellow cells where the user can specify physical parameters (m and cair), simulation parameter (Δt) and constant (g), see the sample output below. Name each yellow cell so that your formula becomes meaningful. You can do this by first selecting the cell and type a short name in the name box, which is next to the formula bar. Step 2: The simulation parameter Δt is the time increment between successive time points. Your task is to fill in the cells A10 to A51 with the values 0, 0.5, 1, 1.5, .., 20, which are multiples of the time increment. These are the time values which you will use later on to compute the freefall speed. You should not manually type these 41 values in. You should use the fill operation to help you.
Hint: The hint is to fill in the first value A10 with 0. Each cell after the first should be the sum of the previous cell using relative addressing plus the time increment. Note that you had chosen a name for the time increment which is the name for Cell C6 in Step 1, you should use that. Step 3: Determine the frefall speed using the formula and fill in the values in Column B. Don’t forget to use the names that you have used in Step 1. Step 4: Now create a scatter chart to show the speed profile over time. You should add titles to the axes. To do that, click on the chart and a tab on “Chart Design” will appear. The leftmost choice on the tab is “Add Chart Elements” and choose “Axis Title”. Step 5: Try modifying the mass and see how it changes the speed profile. You will see that the chart will be updated automatically.
Part B: Using Excel’s Pivot table
An engineering project management firm has collected a data set containing information on the last 500 completed projects that the firm has supervised. The information includes the
• Project manager
• Estimated Time (weeks)
• Actual Time (weeks)
• Estimated Cost
• Actual Cost
• Category (Commercial Construction, Residential Construction, etc)
• OnTime? – a calculated field that reports “Delayed” if the actual time is more than 5% over the estimated time
• OnBudget? – a calculated field that reports “Over Budget” if the actual cost is more than 2% over the estimated cost
• Prj – a column in the worksheet that simply contains a 1 for each project listed. This column could be used to count the number of projects that meet certain criteria. (Note that, this is not necessary; there are other ways to count projects.)
The worksheet Pivot contains 500 rows of data, one per completed project.
Complete the following 4 tasks. Please put the pivot table for each task in a new worksheet. You can name the worksheets as PT-Task1, PT-Task2 etc.
• Task 1 Which project managers had the most “On Time” Transportation projects?
• Task 2 Which project manager has handled the most Municipal Construction projects?
• Task 3 Which project manager has had the most “As Budgeted” Municipal Construction projects?
• Task 4 Which category has the fewest “Delayed” projects?
If you have difficulty doing this project, you should consult Examples 1 and 2 that we discussed in the lecture. You can check your answers here.
(The above example, the data set and some of the questions are from the chapter titled “Excel Pivot Tables” in the book “Engineering with Excel” by Larsen.)
Part C: Counting heart beats
The worksheet Heart_Beat contains 2 columns of data obtained from a pulse oximeter sensor. Column A contains the times (in seconds) at which the measurements were taken. Column B is the voltage (in Volts) measured at the corresponding time in Column A. For example, at Row number 16, the data were collected at time 1.4s (Cell A16) with a measured voltage of 2.52V (Cell B16).
In the lecture, we counted the number of beats by counting the number of peaks whose value exceeds a threshold. In this exercise, you will use a different method to determine the number of heart beats. We will describe the alternative method in Task 3. First, we do some preliminary processing in Tasks 1 and 2.
Task 1 The first step of data analysis is very often to plot the data. Plot the voltage (y-axis) versus time (x-axis). Choose a line type so that you can see the oscillatory pattern of the heart beats. After plotting the graph, you can see that number of heart beats is fairly large. You can manually count them (if you really want to) but it is easy to make a mistake. What you really want to is to get the computer to count them for you.
Task 2 We will be using a threshold voltage of 3V. We have specified this value in Cell H1. In this task, you should define a named constant called “threshold” for Cell H1. In Task 3, you should use the named constant “threshold” instead of the value of 3. This will make the context clearer.
Task 3
In this exercise, you will use:
• Number of heart beats = number of times the voltage crosses the 3V threshold and is decreasing
For example, the following plot shows the voltage from 5s to 10s. The red squares in the plot indicates the time instances that the voltage crosses the 3V threshold and is decreasing. These are downward crossing of a threshold.
The first job that you need to do is to translate the condition “the voltage crosses the 3V threshold and is decreasing” into a logical condition that the spreadsheet can use to determine where these crossings have occurred. You may recall that we did something similar in Part C in Lab05 but you were using upward crossing there instead.
After you have derived the logical condition, implement it in the worksheet. Note that you may need to put some intermediate calculations in some columns. It is always a good practice to check what you have derived is correct. Please do so.
After you have satisfied that your logical condition is correct, determine the number of heart beats and place the answer in cell H3.
The answer is 75. If your answer is less than 75, then you might have missed the last beat in counting downward crossings; or you might have counted upward crossings or peaks instead of downward crossings.
At the End of the Lab
You should be able to show your tutor the exercises. You should get some familiarity with using Excel.
Finally, do not forget to complete your online multiple choice question if you have not done it yet and also save your Excel file on a portable drive or some on-line storage.
If you have completed everything, please do not forget to logout. You will need to log out TWICE: Once from the Windows environment and then from your CSE account. To log out from the Windows environment, click on the Windows logo at the bottom left corner, and choose Log Off. After that, double click on the “Log Out” icon.
]]>
Matlab documentation
In case you have problems doing the work, you can look up the Matlab documentation. There are plenty of examples in the documentation. There are two ways to use the documentation. Go to the top-right corner of the Matlab window, click on the question mark ? to browse or enter some texts to search:
Note that some of the questions will ask you to look up the documentation. This is to give you some practice to learn something new on your own, which is a situation that you will face all your life.
Part A: Arrays
This is an exercise for you to create a script and perform some simple operations on arrays. You are asked not to add a semicolon at the end of the Matlab statement so that we can see
the results on the screen. Example: typing the Matlab command id = [1, 0; 0, 1]
is one way of creating the identity matrix of order 2 and displaying the result.
1. Create a 2×3 array m whose first row contains the values 1, 2 and 4 and whose second row contains 3, -7 and 16.
2. Confirm how big m is with the size and length functions.
3. Many Matlab built-in functions can work with arrays as well as scalars. An example is the mod() function which computes the remainder. For example, the command mod(10,3) returns the remainder when 10 is divided by 3, which equals to 1. Enter the command p = mod(m,2) and explain what it does.
4. You want to create a 2×3 array m_prime which has the same elements as m except that the odd numbers are changed to zero, i.e. m_prime is expected to be the array shown below. You are asked to obtain m_prime from the arrays m and p, where p is the array that you have computed in Step 3. Hint: You need to use .* (elementwise multiplication) and – (subtraction). 0 2 4 0 0 16
Part B: Functions
An object of mass m (in kg) is suspended from the end of a rigid horizontal beam of length b (in metres) that is attached to a wall by a pivot. The beam is supported by a cable of the same length as the beam attached to the beam at a distance d (in metres) from the wall. The tension T (in Newtons) on this cable is given by the equation
where g is the acceleration due to gravity and you can assume its value is 9.81.
Your task is to write a function that calculates the tension given the mass m, and lengths b and d as parameters. A requirement is that you need to make sure your function should work even when the inputs are vectors.
Your program should pass all the following three tests:
1. In this test, the parameters m, b and d are scalars. Their values are respectively 100kg, 2m and 1.2m. The answer should be about 2044N.
2. In this test, the input d is a vector, and m and b are scalars. Specifically,
o Generate a vector d which is an arithmetic progression starting at 0.4 and ending at 1.95, and the increment between two consecutive values is 0.01. If you’re unsure how to make incremental vectors in Matlab, remember you can use the colon : operator.
o The values of m and b are the same as Test 1.
Use your function to generate a vector T of the corresponding tension values. It should require nothing more than passing the vector as the last argument.
If you get a message like Error using __*__ and you don’t understand why, click here.
Your function should return a vector with 156 elements. The elements at indices 1, 50, 100 and 156, are approximately, 5006, 2462, 1963 and 4528, respectively.
3. In this test, all the three inputs m, b an d are vectors. You want to use the function to compute the tension of the cable for the following three cases. The restriction is that you are only allowed to call the function only once. Hint: You need to define three vectors of m, b and d values.
i. m = 100, b = 2, d = 1
ii. m = 200, b = 3, d = 2
iii. m = 300, b = 4, d = 3
The expected answer is a vector with 3 elements whose approximate values are [2266, 3948, 5933].
Part C: A Data Processing Exercise
You might have heard of the recommendation that we should walk at least 10,000 steps per day to stay healthy. Some people use Fitbit, pedometers or smartphone apps to keep track of the number of steps they walk per day. Have you ever wondered how these devices and applications work? In order to count the number of steps, you need both hardware and software. In Fitbit, pedometers and smartphones, there is a common piece of hardware called the accelerometer, which as its name suggests, measures acceleration.
The picture below plots the acceleration data collected by an ENGG1811 lecturer using his smartphone during his commute to work. The horizontal axis shows time measured in
minutes. The vertical axis shows the acceleration in the x-, y- and z-directions measured in m/s^2.
Note that these acceleration data were collected in a trip consisting of walking, train and bus rides. The aim of this lab exercise is to determine which part of the data corresponds to walking.
Fitbit and smartphone apps use fairly sophisticated algorithms for data processing. In this lab, you will use a basic algorithm to decide whether a person is walking in a certain time interval or not. The basic idea is to look at the acceleration over a short time interval. The figures below show the acceleration when the person was walking and not walking over a time interval of about 6 seconds. Note that the y-axes of the two sub-plots have the same scale to make the comparison easier. If the person was not walking (the plot on the right), the acceleration varied around the value of 10. However, when the person was walking, the acceleration varied between 4 and 20. Hence, a way to distinguish between walking and non-walking is to say: walking corresponds to larger variation in acceleration and non-walking corresponds to smaller variation of acceleration. There are many ways to measure variation. In this lab, we will use variance. If we calculate of the variance of the walking and non-walking data in the plots below, we get 20.85 and 0.04 respectively. So, one key point that you need to use later on is this: large variation in acceleration means walking and vice versa.
You are provided with a matlab mat file named acc_data.mat. The file contains a variable mat_data which is a matrix with 49910 rows and 4 columns.
Let us inspect the contents of the first 8 rows of the matrix mat_data >> mat_data(1:8,:) ans = 0 0.7219 3.6775 12.2583 0.0990 1.1169 2.7922 9.5751 0.1990 0.1090 3.3778 7.3958 0.2960 0.1090 3.2144 6.9736 0.3990 -3.9499 3.5277 10.0382 0.5090 -9.6160 3.1463 6.7829 0.6090 -10.1472 0.2724 5.1349 0.7090 -8.8124 0.8853 3.9090
The first column is time (in seconds); the second, third and fourth columns are respectively the accelerations (in m/s^2) in the x-, y- and z-directions.
The first row of data is 0 0.7219 3.6775 12.2583
which means that at time 0, the accelerations in the x-, y- and z-directions were 0.7219, 3.6775 and 12.2583. The third row of data is
0.1990 0.1090 3.3778 7.3958
which means that at time 0.1990, the accelerations in the x-, y- and z-directions were 0.1090, 3.3778 and 7.3958.
You can see that the numbers in the first column are 0, 0.0990, 0.1990, 0.2960 and so on, this means that the accelerometer was trying to measure the accelerations in the three directions roughly every 0.1 seconds, or about 10 samples per seconds.
You are asked to do your work in a script so that you can show your tutor later on. We have divided the work into Exercises 1, 2, 3 and 4.
Exercise 1: Preliminary processing
The first part of your script is shown below. A couple of steps have been done for you and the comments are there to help you to understand what the steps are. The places that say “Your task” contain the work that you have to do. Some further explanation is below the yellow box. % ENGG1811 Lab 11 % Processing acceleration data % Constants THRESHOLD = 0.5; % Threshold to separate walking from non-walking % Load the data file which contains one variable called mat_data load acc_data % The file contains one variable called mat_data % The matrix mat_data has 49910 rows and 4 columns. % You should check the size of the matrix to confirm % % Column 1: The time at which the acceleration is measured % Column 2: Acceleration in x-axis % Column 3: Acceleration in y-axis % Column 4: Acceleration in z-axis %% YOUR TASK: Create a vector vec_time which contains the first column of the % the matrix mat_data % Note that you will only be using the vector vec_time for plotting, % you won’t be using this vector for calculations % Hint: See examples in indexing2_ex.m that was discussed in the lecture vec_time = % You to complete
%% YOUR TASK: Create a matrix called mat_acc_3axes which contains columns 2-4 of % the matrix mat_data % Hint: See examples in indexing2_ex.m that was discussed in the lecture mat_acc_3axes = % You to complete %% YOUR TASK: Use the following Matlab commands to % plot the accelerations in the three axes against time figure(1) plot(vec_time,mat_acc_3axes) xlabel(‘time’) ylabel(‘Acceleration’) legend(‘x’,’y’,’z’) %% YOUR TASK: Calculate the total acceleration (See explanation below) % You can store the result in a vector called vec_acc_total % Note: You shouldn’t use any loops. %% YOUR TASK: Plot the total acceleration vec_acc_total against time % using the following commands figure(2) plot(vec_time,vec_acc_total) xlabel(‘time’) ylabel(‘Acceleration’) legend(‘total acceleration’)
Here we explain the meaning of total acceleration. We assume you have the matrix mat_acc_3axes which is a matrix with 3 columns. The three elements at each row of the matrix is the acceleration in the x-, y- and z-directions at a particular time instance. The matrix mat_acc_3axes has the form
then the total acceleration is the following vector
You should use array operations and vectorisation to calculate the total acceleration. No loops should be used.
Hint: One method is to use the elementwise exponentiation (.^), sum() (making sure to specify the correct dimensions – remember in Matlab columns = 1 and rows = 2) and sqrt().
If you want to check your answers, some of them are here.
Exercise 2: Determining which segments contain walking data using a (for or while) loop
Let us assume that you store the total acceleration in a vector called vec_acc_total. This vector has 49910 rows. (You may wish to check the size of the vector to confirm.) We will partition the elements in this vector into segments where each segment contains 60 elements. With this partition, we have:
• Segment 1 contains elements 1 to 60
• Segment 2 contains elements 61 to 120
• Segment 3 contains elements 121 to 180, and so on
Given that the vector vec_acc_total has 49910 elements and each segment has 60 elements, it means that there is going to be an incomplete segment at the end. We will simply discard that incomplete segment. We will use num_segments to denote the number of complete segments.
Since each segment contains 60 elements (or data points), and acceleration data were collected once per 0.1 seconds, each segment contains roughly 6 seconds of acceleration data. For each segment, you should compute the variance of the total acceleration in the segment. If the variance is greater than or equal to a threshold (i.e. if the variance is big) then the person was walking during this time segment; otherwise, the person was not walking. The threshold you should use is 0.5 and it is specified in the beginning of the script shown in Exercise 1.
You should output your answer in a vector with num_segments elements. The k-th element of this vector is 1 if Segment k corresponds to walking; otherwise the k-th element should be 0.
We will use a small example to illustrate the calculations. Let us assume that the transpose of vec_acc_total is a vector with 14 elements shown below and each segment contains 3 elements. (Note you will use 60 elements per segment for you calculation, but for illustration, we need to use a much smaller number.)
The total accelerations in Segment 1 are 2, 20 and 2. The variance of 2, 20 and 2 is 108, which is at or above the threshold of 0.5, so this is walking. Similarly:
• Segment 2: Variance of 10, 10 and 10 is 0. Below threshold 0.5. Not walking.
• Segment 3: Variance of 10, 9 and 10 is 0.333. Below threshold 0.5. Not walking.
• Segment 4: Variance of 3, 18 and 3 is 75. At or above threshold 0.5. Walking.
The output should be in a vector with 4 elements because there are 4 complete segments. The output in this case should be the vector [1; 0; 0; 1]
because Segments 1 and 4 correspond to walking. Note that the last elements (i.e. the values of 6 and 7) are not used because they do not form a complete segment.
For Exercise 2, you task is to use an implementation that uses loops.
You will find that, out of a total of 831 complete intervals, 265 of them are walking intervals. More answers are here.
Hint: The following code will help you get started: % Use segments of 60 samples and determine whether the person is walking % Basic parameters num_samples_per_segment = 60; % number of samples per segment num_samples = length(vec_acc_total); % total number of samples in the data num_segments = floor(num_samples/num_samples_per_segment); % number of complete segments % Create a vector whose length is the number of complete segments walking_segments_loops = zeros(1,num_segments); % if Segment k is walking, then we will set walking_segments_loops(k) to 1 % Loop over each segment, if the variance is bigger than threshold, set % the index of that segment in walking_segments_loops to 1 for k = 1:num_segments % Extract the sub-array for this segment. % Need to work out the first index of the segment and the index for the segment % After that, use colon notation to select the appropriate elements. % % Determine the variance and compare it to the threshold end
Exercise 3: Determining which segments contain walking data WITHOUT using any loops
For this part, you should do the calculations stated in Exercise 2 but your implementation should NOT use any loops.
You will need to use the var function in Matlab to calculate variance. You can look at the documentation on how to use this function.
Hint: Consider the small example in Exercise 2. Let us start from ex_0 = [2; 20; 2; 10; 10; 10; 10; 9; 10; 3; 18; 3; 6; 7]
You need to extract all the complete segments: ex_1 = [2; 20; 2; 10; 10; 10; 10; 9; 10; 3; 18; 3]
and then think about using the Matlab reshape() function (Please read the note below on the Matlab reshape() function) obtain the matrix: 2 10 10 3 20 10 9 18 2 10 10 3
Once you get this matrix, you see that each segment is in a column. You can then use var() to calculate the variance of the segments. After that you compare against the threshold.
Note that the Matlab reshape() function stacks columns, you can look up the examples in the online documentation. The numpy reshape function by default is row-wise, but allows the option of column-wise stacking.
If you got 264 total walking segments instead of 265, check out this link for more information.
Exercise 4: Comparing the outputs from Exercises 2 and 3
The results from Parts B2 and B3 should be identical, and your task is to verify this. The vectors from Parts B2 and B3 are quite long, so visual comparison is tedious. However, in Matlab, you can do this verification with one line of code. We impose the following requirements in how you verify whether the two vectors are identical.
• Your method can use only one line of code
• You cannot use any if-statements
• You cannot use any for- or while-loops
• The line of code should return 1 if the vectors are identical, otherwise it should return 0
You can use any methods you like as long as they meet the above requirements. For this part, you need to come out with two different methods.
Some functions or operators that you may find useful: any, all, sum, ~, ==, ~=, -.
Remark 1: Now that you have determined which segments of data correspond to walking, you can count the number of steps in those segments if you want. The process of counting the number of steps is fairly similar to that of counting the number heart beats, which you have done a few times in the course. So, we won’t ask you to do it.
Remark 2: This exercise asks you to compare two vectors consisting of integers (0 and 1). In this case, the comparison is straightforward. You may recall that we discussed in an earlier lecture on the topic of finite precision on the problem of comparing floating point numbers in Python. The same issue will also appear when you try to compare floating point numbers in Matlab due to inherent errors in representing floating points numbers. This isn’t an issue with this exercise, but you may need to compare floating point numbers in the future. See this link for one way of approaching the problem similar to what you have already done in Python.
At the End of the Lab
You should be able to show your tutor the exercises. You should be comfortable with the following aspects of Matlab: creating an array, elementwise operations, writing functions, array indexing and data operations.
Finally, do not forget to complete your online multiple choice question if you have not done it yet.
If you have completed everything, please do not forget to logout. Simply double click on the “Log Out” icon
Ask for Help
or
Scan the Wechat
]]>
请加微信：HYPdear
或扫描二维码即可免费咨询：
We often think bacteria are bad. The truth is that there are many different types of bacteria in this world. Some bacteria are harmful to humans but some bacteria in our bodies help us to live. Have you ever considered the possibility that bacteria can also be “factory workers”? Engineers and scientists are working on using bacteria to produce certain chemicals and materials. An example is to use bacteria to produce fuel for us. In engineering, we often want to optimise the process, so we may want to make the bacteria to produce as much fuel as possible in a given time. However, there are often constraints in nature. The truth is that fuel is toxic to bacteria, so we need to find a way for the bacteria to make a lot of fuel but at the same time keep them alive! This biofuel production process is the theme of this assignment.
The aim of this assignment is to give you an opportunity to work on a small-scale engineering design problem in python. The engineering system that you will be working on is biofuel production. Your goal is to determine the design parameters so that the bacteria can produce as much fuel as possible while respecting a couple of constraints. You will use simulation as part of the design process.
For this assignment, you need to work in a group of two with the restriction that your group partner must come from the same lab class (i.e. same lab time slot and lab room). If you want to work on your own, please check with your tutor.
This assignment is designed to give you practice in
This assignment is design to imitate engineering design. You will see the following elements:
Download files: There are a number of python files that you need to do this assignment. These files are in assign2.zip. We will first talk about the tasks involved, and later introduce these supplied files, see Supplied Files for more.
We will first give an introduction to biofuel production. This introduction is meant to give you some intuition on the design problem. After that we will tell you what you need to do for the assignment.
We will give you a basic mental picture that you can use to visualise biofuel production. A pictorial representation of a bacterium is in Figure 1. A bacterium is a single-cell organism. It has a cell membrane, which you can think about as the “skin” of a bacterium. By using bioengineering, we can get the bacteria to produce fuel for us. This production will take place within the bacteria, i.e. inside the cell membrane of the bacteria.
Figure 1. A pictorial depiction of the main elements of a bacterium for biofuel production.
Now that you know that fuel is produced inside the membrane of bacteria, the next thing you need to know is that having the fuel staying inside the bacteria is neither good for us nor the bacteria. It is not good for us because we cannot collect the fuel. It is not good for the bacteria because it is toxic to them. This means we need a way to get the fuel from the inside of the membrane to the outside. A good news is that bacteria can make efflux pumps on the membrane to push the fuel from the inside of the membrane to the outside.
With these efflux pumps, we can reduce the amount of fuel in the bacteria (i.e. toxicity level) and collect the fuel, solving the problem that we talked about in the last paragraph, but there is one catch. Efflux pumps, though useful, can be a burden to the bacteria. This means that a bacterium should not have too many efflux pumps. A clever way is to get the bacteria to make efflux pumps on demand. If a bacterium senses that there is a lot of fuel inside its membrane, it should make more efflux pumps to expel the fuel; and vice versa. With the help of bioengineering, it is possible to have biosensors in bacteria to sense the amount of fuel in the bacteria.
The above mental picture should give you the intuition you need for the biofuel production process. In order to do engineering design, we need a mathematical model which we will discuss next.
From the biofuel production description that we have discussed above, you know that we are interested in a few quantities: the amount of biofuel inside the bacteria because this is related to the toxicity level; and, the amount of biofuel outside the bacteria because this is the amount that we can collect. We would like to have a mathematical model which tells us how these two quantities vary over time. The mathematical model can tell us how the following five quantities vary over time:
You will use simulation to determine these five quantities.
There are two design parameters which we will vary, they are:
We have placed the mathematical model for the biofuel on a separate page. We believe it is best for you to understand what you need to do for this assignment first before dwelling into the mathematical model. You should be able to understand what you need to do for the assignment without going into the mathematical model at this stage. (The model is here and you can read it later.) The mathematical model for biofuel production is based on Reference [1].
We have divided the work into a number of tasks.
The aim of this task is to write a python function sim_biofuel (which should be in a file with name sim_biofuel.py) to simulate the biofuel production process. You can find a template for this function in sim_biofuel_template.py (in assign2.zip). You should rename it as sim_biofuel.py before you start. The declaration of the function sim_biofuel is:
def sim_biofuel(data_set_to_use, time_array, init_bacteria_amount, alpha_b, alpha_p) :
The above function returns five arrays. All these five arrays should have the same length as the input array arrayTime. These five arrays contain the following simulation outputs:
The inputs are:
The implementation of sim_biofuel requires the mathematical model for the biofuel production process. (The model is here and the suggestion is that you read the model later.)
Hint: You can use the python simulation program para_ODE_ext_lib.py and para_speed_height_by_ODE.py (code from Week 7’s lecture) or the material from “Lab 08: Simulation and its applications” as a starting point to develop the function sim_biofuel.
The only non-zero initial condition is the amount of bacteria. This is defined by the constant INITIAL_BACTERIA_AMOUNT, which is specified in the simulation data set. The python files provided for testing load this constant in for you, so you can assume this constant is available and use it. You can assume the initial conditions for R, p, b_{i} and b_{e} are zero.
The array time_array is a uniformly spaced array of time instances. The start and end times, as well as time increments, are specified in the simulation data set. The python files provided for testing your function load these constants in for you, as well as define the array time_array. So, you can assume the time array is available and use it.
When you call the function sim_biofuel, the only inputs that you need to adjust are the values of alpha_b and alpha_p. For example, if you want to do simulation with α_{b} = 0.1 and α_{p} = 0.6, you should use:
def sim_biofuel(data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, 0.1, 0.6) :
Note that you can leave the first three inputs (shown in red) as they are shown in the above line. You may want to read through the file test_1A_1B.py to give you an example on how to call the function.
You can use the python program test_1A_1B.py (in assign2.zip) to test your sim_biofuel. The program test_1A_1B.py first reads in the constants and parameters for the selected data set. It then creates an equally spaced array time_array. The program then calls the function sim_biofuel to compute the five outputs of the simulation, and compares them to the reference values. If you see the error is small, i.e. less than 10^{-6}, then your sim_biofuel should be working correctly.
Note that we have provided two different sets of system and simulation parameters. You can choose between them by assigning the variable data_set_to_use to either 1 or 2. You can find this variable near the beginning of the file. For each system parameter set, you can use three different pairs of design parameters in test_1A_1B to test your data_set_to_use. The selection is done by setting the variable test_indexto 1, 2 or 3.
We have mentioned earlier that biofuel is toxic to the bacteria. It would be desirable if we can choose our design parameters α_{b} and α_{p} to limit the maximum amount of biofuel inside the bacteria. This is one design constraint that we want to impose.
There is another design constraint that we would like to impose. Let us first illustrate it. Depending on the choice of the value of α_{b} and α_{p}, the amount of biofuel in the bacteria can vary differently over time during the biofuel production process. Figure 2 shows how the amount of internal biofuel varies over time for α_{b} = 0.0162 and α_{p}= 0.07, with Parameter Set 1. We can see that the amount of biofuel increases steadily from zero.
Figure 2: Amount of internal biofuel against time for α_{b} = 0.0162 and α_{p}= 0.07.
Figures 3 shows what happens if we use α_{b} = 1 and α_{p}= 0.05 instead. We see that the amount of biofuel in the bacteria oscillates for these design parameters. This may not be good for the bacteria because they have to make efflux pumps which they later do not need. This is undesirable.
Figure 3: Amount of internal biofuel against time for α_{b} = 1 and α_{p}= 0.05.
For our design, we would like to find design parameters which limit (1) The maximum amount of internal biofuel; and, (2) The amount of oscillation in the level of internal biofuel. We want to do this quantitatively. Let us assume that you have done the simulation and have the amount of internal fuel stored in the array biofuel_int_array. The maximum amount of internal biofuel is then the maximum value in the arraytor biofuel_int_array. To determine oscillation, we use the following algorithm:
Figure 4: Illustration on the amount of oscillation.
In this task, your job is to write a python function find_max_and_oscillation with declaration
def find_max_and_oscillation(input_array) :
The aim of the function is to determine (1) The maximum value in input_array and output it in max_value; and (2) The amount of oscillation in input_array and output it in oscillationSize. The function returns these two values (i.e. return max_value, oscillationSize).
A requirement for Task 1B is that you cannot use any loops in this function. You can only get full marks if you do not use any loops. If you use loops, you will receive a reduced mark.
You can test this function by using the script test_1A_1B. The lines for testing this function is commented out initially. You need to remove the # sign in order to get the testing going. If you adjust the value of the variable test_index, you can choose between 3 different set of design parameters.
You have seen that different values of α_{b} and α_{p} can lead to different behaviour of internal biofuel level. In the same way, different values α_{b} and α_{p} can lead to different amount of fuel that we can collect. Our design objective is to collect as much fuel as possible at the end of the production process. We can measure this design objective quantitatively by using the value of the last element of the array biofuel_ext_array, which represents the amount of external biofuel at the end time of the simulation.
In this task, you will use many different pairs of (alpha_b, alpha_p) for simulation. For each pair of (alpha_b, alpha_p), you will simulate the biofuel production and use the output of the simulation to determine: (1) The amount of biofuel you can collect; (2) The maximum amount of internal biofuel; and, (3) The amount of oscillation of the internal biofuel.
The steps for this task are:
For example,
In this part you need to implement the following function:
def generate(data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, alpha_b_array, ALPHA_P_LOWER, ALPHA_P_UPPER, ALPHA_P_STEP) :
Input:
Output:
You can use the file test_2A.py to check whether you have calculated the three matrices max_internal_biofuel, oscillation_internal_biofuel and final_external_biofuel correctly.
The engineering design problem is to choose good design parameters to meet our design requirements. In our case, a design has two design parameters alpha_b and alpha_p. In Task 2A, you have associated each design, or each pair of (alpha_b, alpha_p), with three quantitative measures:
We want to choose the best pair of (alpha_b, alpha_p) base on these three quantitative measures. We know that large amount of internal biofuel and large amount of oscillation are undesirable. What we want to do is to impose an upper limit on each of these two quantitative measures. We introduce two thresholds:
These two constants are specified in a parameter set that the program test_2B.py reads in. We say that a design is acceptable if
Out of all the designs that are acceptable, we will choose the design that allows us to collect the largest amount of biofuel. We will call this design the best design.
For comparison purpose, we will also determine a poor design which we define as the design that maximises the amount of biofuel that can be collected, without considering any constraints.
Once you have obtained the best design and the poor design, you need to return these four values from the following function you need to implement for his part.
A requirement for Task 2B is that you should complete this task without using any loops. You can only get full marks if your solution does not use loops. If your solution requires loops, then you can only get a reduced mark.
In this part, you need to implement the following function:
def design( THRESHOLD_MAX_INTERNAL_FUEL, THRESHOLD_MAX_OSCILLATION_INTERNAL_FUEL,
alpha_b, alpha_p,
max_internal_biofuel, oscillation_internal_biofuel, final_external_biofuel) :
Output (return values):
You should be able to determine whether your answers are correct by manually checking on the elements of the matrices. You can do that. The matrices are big so you may want to come out with some smaller matrices yourselves to test your work. We strongly encourage you to do that because it is always good to try to check your own work. When you go out to work, you will need to check your own work. We have also placed the answers here but we encourage you to check your own work before looking at them.
Remark: We have used exhaustive search here to determine the design parameters. This is certainly not the most efficient algorithm but you will learn better optimization methods in later years.
You should make sure that all your files are properly documented with appropriate comments. Variables that you use should have well chosen names and their meaning explained. Appropriate style should be used.
The supplied files are (in assign2.zip):
We have two sets of parameters. You can choose between the two sets of parameters by using the variables data_set_to_use. Each set of parameters is made up of constants in two files:
The following table shows the maximum possible marks for the tasks. Note that, for Tasks 1B and 2B, you can only get full marks if your solution does not use any loops; otherwise, a reduced mark will apply.
Marks | Feature/Assessable Item |
6 | Task 1A (Function sim_biofuel) |
6 | Task 1B (Function find_max_and_oscillation. Reduced maximum: 1.5 |
6 | Task 2A (Correct max_internal_biofuel, oscillation_internal_biofuel and final_external_biofuel) |
6 | Task 2B (Correct values of alpha_b and alpha_p for the two designs). Reduced maximum: 1.5 |
3 | Style, complexity, etc. (Comments; Variable definitions; Style; Complexity) |
27 | Total mark (rescaled to 10% of overall assessment) |
This assignment is to be completed in a group of two with the restriction that your group partner must come from the same lab class (i.e. same lab time slot and lab room). If you want to work on your own, please check with your tutor.
You must register the pair with your tutor no later than the Week 11 lab class.
A complete submission should contain the following four files (as described above):
The submission system will accept the above four filenames.
Submission system will be available in week-12.
Only one member of a pair should submit, as the submission is stored against the group rather than the individual, and each member will receive the mark awarded to the group.
As with all material submitted for assessment, this must be substantially your own registered group’s work. It’s OK to discuss approaches to solutions with other students, and to get help from tutors and consultants, but you must write the Basic code yourself. Sophisticated software is used to identify submissions that are unreasonably similar, and marks will be reduced or removed in such cases.
Use the forum to ask general questions about the assignment, and keep an eye on it for updates and responses.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811 Assignment 2 Purpose: You can use this program to testthe following function from task 2A: (1) generate """ import numpy as np import pickle import biofuel_simulation_design_parameter_sets as bsdps import generate as gn # Use the variable dataSetToUse to choose which parameter set you # want to use data_set_to_use = 1 # Either 1 or 2 # # PLEASE DO NOT CHANGE THIS SECTION # BEGIN - DO NOT CHANGE # The following line reads in the simulation parameters for data_set_to_use, # For example: time increment and other parameters you need for simulation simulation_design_para = bsdps.biofuel_simulation_design_parameter_sets(data_set_to_use) # Initial (normalised) amount of bateria INITIAL_BACTERIA_AMOUNT = simulation_design_para['INITIAL_BACTERIA_AMOUNT' ] # Simulation start and end times, simulation time interval TIME_START = simulation_design_para['TIME_START' ] # Start time TIME_END = simulation_design_para['TIME_END' ] # End time TIME_DELTA = simulation_design_para['TIME_DELTA' ] # Delta t # alpha_b: Lower and upper limits, number of points ALPHA_B_EXP_LOWER = simulation_design_para['ALPHA_B_EXP_LOWER'] ALPHA_B_EXP_UPPER = simulation_design_para['ALPHA_B_EXP_UPPER'] ALPHA_B_NUMBER_POINTS = simulation_design_para['ALPHA_B_NUMBER_POINTS'] # alpha_p: Lower and upper limits, step size ALPHA_P_LOWER = simulation_design_para['ALPHA_P_LOWER'] ALPHA_P_UPPER = simulation_design_para['ALPHA_P_UPPER'] ALPHA_P_STEP = simulation_design_para['ALPHA_P_STEP'] # ## Load the data for checking, Read from file data_cheking_file = open('set'+ str(data_set_to_use) + '_check.pickle', 'rb') data_checking = pickle.load(data_cheking_file) data_cheking_file.close() # END - DO NOT CHANGE ## Task 2A: Caclulating the design objective and constraints for many pairs # of (alphaB,alphaP) # Time vector # Create a list of regularly spaced time instants # [0,0.25,0.5,0.75,...,20] # time_array = np.arange(TIME_START, TIME_END+TIME_DELTA/2, TIME_DELTA) num_time_points = len(time_array) # Parameter vectors for design # The vector vecAlphaB has been defined for you alpha_b_array = np.logspace(ALPHA_B_EXP_LOWER, ALPHA_B_EXP_UPPER, num=ALPHA_B_NUMBER_POINTS) # alpha_b_array, alpha_p_array, max_internal_biofuel, oscillation_internal_biofuel, final_external_biofuel = \ gn.generate(data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, alpha_b_array, ALPHA_P_LOWER, ALPHA_P_UPPER, ALPHA_P_STEP) # # Code to check your answers below .. # diffmax_max_internal_biofuel = np.amax(abs(np.subtract(max_internal_biofuel, data_checking['max_internal_biofuel_check']) )) diffmax_max_oscillation_internal_biofuel = np.amax(abs(np.subtract(oscillation_internal_biofuel , data_checking['oscillation_internal_biofuel_check']) )) diffmax_max_final_external_biofuel = np.amax(abs(np.subtract(final_external_biofuel , data_checking['final_external_biofuel_check'])) ) print('Difference in the maximum amount of internal biofuel = ' + str(diffmax_max_internal_biofuel) ) print('Difference in the maximum amount of oscillation_internal_biofuel = ' + str(diffmax_max_oscillation_internal_biofuel) ) print('Difference in the maximum amount of final_external_biofuel = ' + str(diffmax_max_final_external_biofuel) )
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811 Assignment 2 Purpose: You can use this program to testthe following function from task 2A: (1) generate """ import numpy as np import pickle import biofuel_simulation_design_parameter_sets as bsdps import design.py as dn import generate as gn # Use the variable dataSetToUse to choose which parameter set you # want to use data_set_to_use = 1 # Either 1 or 2 # # PLEASE DO NOT CHANGE THIS SECTION # BEGIN - DO NOT CHANGE # The following line reads in the simulation parameters for data_set_to_use, # For example: time increment and other parameters you need for simulation simulation_design_para = bsdps.biofuel_simulation_design_parameter_sets(data_set_to_use) # Initial (normalised) amount of bateria INITIAL_BACTERIA_AMOUNT = simulation_design_para['INITIAL_BACTERIA_AMOUNT' ] # Simulation start and end times, simulation time interval TIME_START = simulation_design_para['TIME_START' ] # Start time TIME_END = simulation_design_para['TIME_END' ] # End time TIME_DELTA = simulation_design_para['TIME_DELTA' ] # Delta t # alpha_b: Lower and upper limits, number of points ALPHA_B_EXP_LOWER = simulation_design_para['ALPHA_B_EXP_LOWER'] ALPHA_B_EXP_UPPER = simulation_design_para['ALPHA_B_EXP_UPPER'] ALPHA_B_NUMBER_POINTS = simulation_design_para['ALPHA_B_NUMBER_POINTS'] # alpha_p: Lower and upper limits, step size ALPHA_P_LOWER = simulation_design_para['ALPHA_P_LOWER'] ALPHA_P_UPPER = simulation_design_para['ALPHA_P_UPPER'] ALPHA_P_STEP = simulation_design_para['ALPHA_P_STEP'] # # Design parameters for biofuel system # Upper limit on the amount of internal fuel THRESHOLD_MAX_INTERNAL_FUEL = simulation_design_para['THRESHOLD_MAX_INTERNAL_FUEL'] # Upper limit on the amount of oscillation THRESHOLD_MAX_OSCILLATION_INTERNAL_FUEL = simulation_design_para['THRESHOLD_MAX_OSCILLATION_INTERNAL_FUEL'] # ## Load the data for checking, Read from file data_cheking_file = open('set'+ str(data_set_to_use) + '_check.pickle', 'rb') data_checking = pickle.load(data_cheking_file) data_cheking_file.close() # END - DO NOT CHANGE time_array = np.arange(TIME_START, TIME_END+TIME_DELTA/2, TIME_DELTA) num_time_points = len(time_array) # Parameter vectors for design # The vector vecAlphaB has been defined for you alpha_b_array = np.logspace(ALPHA_B_EXP_LOWER, ALPHA_B_EXP_UPPER, num=ALPHA_B_NUMBER_POINTS) ## Task 2B: Caclulating the design objective and constraints for many pairs # # alpha_b, alpha_p, max_internal_biofuel, oscillation_internal_biofuel, final_external_biofuel = \ gn.generate(data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, alpha_b_array, ALPHA_P_LOWER, ALPHA_P_UPPER, ALPHA_P_STEP) best_alpha_b, best_alpha_p, poor_alpha_b, poor_alpha_p = \ dn.design( THRESHOLD_MAX_INTERNAL_FUEL, THRESHOLD_MAX_OSCILLATION_INTERNAL_FUEL, alpha_b, alpha_p, max_internal_biofuel, oscillation_internal_biofuel, final_external_biofuel) # # Print your answers, and manually check them against the expected answers, # available from the link provided in the specs (see below). # Answers for this part are at, https://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/answers.html # You need to manually compare/check these answers.
答疑一：
提问者：
老师您好，请问可以帮我看看这个问题吗？
答主：
你好，可以的，请说。
答疑二：
提问者：老师，可以帮我下吗？
答主：你好，请说。
提问者：
我没看懂这个最后一行的意思。为什么最后一行是 -1？
答主：
-1 是取array的最后一个数
提问者：
那一行代码可以解释下吗？
答主：
稍等，，，
这句话意思也就是取最后时间的值。
提问者：我看看，这里明白了，
另外一个问题，这一步怎么写的呀，好像没懂。
答主：
就是这句。
答疑三：
提问者：
你好，有时间给我看一下这个问题吗？我不知道哪里出错了，，，，
答主：
可以的，你发来看看。
答疑四：
提问者：
在吗？、可以帮下忙吗？
答主：
选第四个
答疑四：
提问者：
您好老师，可以帮我看看吗？急
答主：
选第四个
答疑五
提问者：
答主：
选第二个
答疑六：
提问者：
为什么可以用一个参数接受返回五个参数的函数
答主：
函数返回五个参数，其实是返回一个五个参数的list,可以像如图的方式进行获取，避免了多余参数的定义
答疑七：
提问者：
关于np.where函数三个参数模式下怎么用？
答主：
如图所示，可以用作类似 a = 0 if condition else 1这样的三元批量替换，可以节省很多代码，且可以替换掉很多循环操作
答疑八：
]]>
问答一：
提问者：老师在吗？
答主：在的，咋呢？
提问者：有个问题关于matlab的，可以帮我看看吗？
答主：这个程序本来有问题，
答主：定义函数的m文件里面不能直接调用函数。
提问者：我试试，
可以拉。谢谢老师。
]]>