联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2018-05-29 01:55

2018/5/28 ENGG1811 Assignment 2


ENGG1811 Assignment 2: Simulation and Design of Biofuel

Production

Due date: 5pm, Friday of Week-13 .

Late Penalty: Late submissions will be penalised at the rate of 10% per day

(including weekends). The penalty applies to the maximum available mark. For

example, if you submit 2 days late, maximum available marks is 80% of the

assignment marks. Submissions will not be accepted after 5pm Tuesday of Week14.

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). You

must register the pair with your tutor no later than the Week 11 lab class. If you want

to work on your own, please check with your tutor.

Change log :

05:35am Mon 21 May: Please download the following updated files:

set1_check.pickle (diff should be now zero or very low, say less than 10^-4)

set2_check.pickle (diff should be now zero or very low, say less than 10^-4)

test_2B.py (in "import", design.py changed to design)

10:35am Wed 16 May: Test files for 2A and 2B are now available: test_2A.py and

test_2B.py

09:20am Tue 15 May (changes marked with light-cyan background)

Due date is 5pm Friday of Week-13.

In part 2A and 2B, 'alpha_b' and 'alpha_a' should be replaced by 'alpha_b_array' and

'alpha_p_array' respectively.

The following updated files are now available:

'test_1A_1B.py'

'test_2A.py'

'test_2B.py'

Introduction

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.

Learning objectives

This assignment is designed to give you practice in

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 2/9

Applying programming to solve a simple engineering design problem

Writing a python program to simulate an engineering system

Applying a number of python features, which include arraytorisation, built-in functions and others

Applying good software engineering practices, which includes proper documentation, program style

Working with a partner (if applicable)

Assignment overview

This assignment is design to imitate engineering design. You will see the following elements:

1. (Simulation) Simulation of a biofuel production system with different design parameters.

2. (Design) Evaluate the performance of the systems that you have simulated.

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.

Biofuel production process

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.

A mathematical model for the biofuel production process

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

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 3/9

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:

The amount of bacteria in the colony denoted by the mathematical symbol n. Note that we scale the

amount by the maximum possible of bacteria so n is a number in the interval [0,1].

The biosensor output denoted by R which is a non-negative real number.

The amount of efflux pumps, denoted by p, which is a non-negative real number.

The amount of biofuel in the interior of the bacteria, denoted by bi

, which is a non-negative real number.

We also call this internal biofuel.

The amount of biofuel in the exterior of the bacteria, denoted by be

, which is a non-negative real number.

We also call this external biofuel.

You will use simulation to determine these five quantities.

There are two design parameters which we will vary, they are:

The biofuel production rate αb

. (python variable name alpha_b)

The efflux pump production rate αp

. (python variable name alpha_p)

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].

Overview of tasks

We have divided the work into a number of tasks.

Task 1: Task1A is on simulation and Task 1B evaluates the system constraints

Task 2: is on engineering design (which also has Parts A and B)

Task 1A: A python function to simulate the biofuel production system

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:

bacteria_amount_array for the amount of bacteria n

sensor_array for the biosensor output denoted by R

pump_array for the amount of efflux pumps p

biofuel_int_array for the amount of biofuel in the interior of the bacteria bi

,

biofuel_ext_array for the amount of biofuel in the exterior of the bacteria be

,

The inputs are:

data_set_to_use is an integer indicating data set to use containing constants you need for simulation.

time_array is a array of time instances that you need for simulation.

init_bacteria_amount is a scalar for the initial amount of bacteria in the colony.

alpha_b is a scalar for the design parameter for biofuel production rate αb

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 4/9

alpha_p is a scalar for the design parameter efflux pump production rate αp

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, bi and be 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_index to 1, 2 or 3.

Task 1B: A function to calculate the maximum and the amount of oscillation

in the level of internal biofuel

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.

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 5/9

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:

Determine the maximum value in biofuel_int_array and we will call the maximum value

max_biofuel_int

If max_biofuel_int is the last element of biofuel_int_array, then the amount of oscillation is zero. This is

the situation of Figure 2.

If max_biofuel_int is not the last element of biofuel_int_array and let us say it is the k-th element of the

array. We determine the minimum value of biofuel_int_array from the (k+1)-th element till the end of the

array and let us call this value min_biofuel_int. The amount of oscillation is max_biofuel_int minus

min_biofuel_int. This is the situation in Figure 3. An illustration of the meaning of max_biofuel_int and

min_biofuel_int is in Figure 4.

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.

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 6/9

Task 2A: Calculating the design objective and constraints for many pairs of

(alpha_b, alpha_p)

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:

1. Create an array of alpha_p_array of equally spaced αp values. The first value is ALPHA_P_LOWER and the

last value is ALPHA_P_UPPER with an increment of ALPHA_P_STEP. These three constants are specified in a

parameter set that the program test_2A.py reads in. You can use them directly. Note that the program

also has a line which creates an array alpha_b_array of αb values. You can use that.

2. Create three zero matrices whose number of rows is the number of elements in alpha_b_array and the

number of columns is the number of elements in alpha_p_array. You should call these three matrices

max_internal_biofuel, oscillation_internal_biofuel and final_external_biofuel.

3. Perform simulations for all possible pairs of (alpha_b, alpha_p) where alpha_b comes from the elements

in alpha_b_array and alpha_p comes from the elements of alpha_p_array. For each pair of (alpha_b,

alpha_p), we need to do the following:

The (i,j) element of the matrix max_internal_biofuel, i.e. max_internal_biofuel(i,j), should be

assigned the maximum amount of internal biofuel when alpha_b_array(i) and alpha_p_array(j)

are used.

For example,

The (i,j) element of the matrix oscillation_internal_biofuel , i.e.

oscillation_internal_biofuel(i,j), should be assigned the amount of oscillation in internal

biofuel when alpha_b_array(i) and alpha_p_array(j) are used.

The (i,j) element of the matrix final_external_biofuel, i.e. final_external_biofuel(i,j), should

be assigned the amount of biofuel that can be collected when alpha_b_array(i) and

alpha_p_array(j) are used.

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:

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 7/9

data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, alpha_b_array, ALPHA_P_LOWER,

ALPHA_P_UPPER, ALPHA_P_STEP

Output:

alpha_b_array, alpha_p_array, max_internal_biofuel, oscillation_internal_biofuel, final_external_biofuel

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.

Task 2B: Engineering design

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:

Amount of biofuel that can be collected

Maximum amount of internal biofuel

Amount of oscillation of internal biofuel

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:

THRESHOLD_MAX_INTERNAL_FUEL is a threshold on the maximum amount of internal biofuel

THRESHOLD_MAX_OSCILLATION_INTERNAL_FUEL is a threshold on the oscillation of internal biofuel

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

Maximum amount of internal biofuel is less than or equal to THRESHOLD_MAX_INTERNAL_FUEL, and

The amount oscillation of internal biofuel is less than or equal to

THRESHOLD_MAX_OSCILLATION_INTERNAL_FUEL

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_array, alpha_p_array,

max_internal_biofuel, oscillation_internal_biofuel,

final_external_biofuel) :

Output (return values):

best_alpha_b, best_alpha_p, poor_alpha_b, poor_alpha_p

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.

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 8/9

Style

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.

Supplied Files

The supplied files are (in assign2.zip):

The file sim_biofuel_template.py is for Task 1A. You should rename it as sim_biofuel.py

For Task 1B, you need to create file find_max_and_oscillation.py for the function

find_max_and_oscillation

For Task 2A, you need to create file generate.py for the function generate

For Task 2B, you need to create file design.py for the function design

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:

1. System parameters which are the constants you need for the mathematical model in

biofuel_system_parameter_sets.py.

2. Simulation and design parameters in biofuel_simulation_design_parameter_sets.py.

Files for testing

test_1A_1B for testing Tasks 1A and 1B.

test_2A for testing Tasks 2A.

test_2B for testing Tasks 2B.

These files require support files, which are set1_check.pickle and set2_check.pickle files.

Assessment

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)

Groups and submission

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):

1. sim_biofuel.py

2018/5/28 ENGG1811 Assignment 2

http://www.cse.unsw.edu.au/~en1811/18s1/assigns/ass2/ass2.html 9/9

2. find_max_and_oscillation.py

3. generate.py

4. design.py

The submission system will accept the above four filenames.

Submission system is now available. To Submit this assignment, go to the Submission page and click the tab

named "Make Submission".

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.

Originality of Assignments

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.

Further Information

Use the forum to ask general questions about the assignment, and keep an eye on it for updates and responses.

Reference

[1] M.E. Harrison and M.J. Dunlop. Synthetic feedback loop model for increasing microbial biofuel production

using a biosensor. Frontiers in Microbiology, Oct 2012.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp