Sep-13-2020, 08:16 AM
Hi Guys,
I would like to ask a help for my homework
I hope I did an understandable translation for the task.
Thanks in advance:
Cilyt
Optional task for 1 point: Background
A land is divided into 10x10 plots (that means there are 10 plots in each row and there are a total of 10 rows) and we are growing plants in each plot.
We are working on the following simple model:
– The plots initially contain 0.1 units of plants.
– [growth phase] in each plot, the amount of plant increases by a random number between 0.0 and 0.2 in each time unit.
– [harvesting phase] if, by the end of the growth phase, the amount of plant in a plot increases above 1.1, then harvest the contents of the plot so that the remaining quantity is 0.1 (so it is possible that the quantity of harvested is a number above 1).
Optional task for 1 point: Task
Implement the above model in a class called Simulation, which will require the following member variables:
– height: an integer, in this problem is 10.
– width: an integer, in this problem is 10.
– actual_state: a 10x10 table that showing the current state of the land.
– harvest: a list that stores the quantities of harvested (initially empty list).
We implement the following functions:
run(time):
– Input parameter: time, this specifies the number of time units, meanwhile the simulation is running.
– Implements the simulation, i.e.
1. Performs the growth and harvest phases for each time unit and cell.
2. Saves the crop (that is, the quantities harvested) to the harvest variable.
3. Saves the end state of the time unit end to the actual_state variable.
statistics(): returns after the simulation:
– The number of harvests.
– The largest harvested crop
Notes:
– The implementation of the function generating the initial state is given.
– In the run function, a triple for loop implements the simulation (time, rows of land, columns of land).
Have to do on:
http://colab.research.google.com
# Homework
[1]
I would like to ask a help for my homework

I hope I did an understandable translation for the task.
Thanks in advance:
Cilyt
Optional task for 1 point: Background
A land is divided into 10x10 plots (that means there are 10 plots in each row and there are a total of 10 rows) and we are growing plants in each plot.
We are working on the following simple model:
– The plots initially contain 0.1 units of plants.
– [growth phase] in each plot, the amount of plant increases by a random number between 0.0 and 0.2 in each time unit.
– [harvesting phase] if, by the end of the growth phase, the amount of plant in a plot increases above 1.1, then harvest the contents of the plot so that the remaining quantity is 0.1 (so it is possible that the quantity of harvested is a number above 1).
Optional task for 1 point: Task
Implement the above model in a class called Simulation, which will require the following member variables:
– height: an integer, in this problem is 10.
– width: an integer, in this problem is 10.
– actual_state: a 10x10 table that showing the current state of the land.
– harvest: a list that stores the quantities of harvested (initially empty list).
We implement the following functions:
run(time):
– Input parameter: time, this specifies the number of time units, meanwhile the simulation is running.
– Implements the simulation, i.e.
1. Performs the growth and harvest phases for each time unit and cell.
2. Saves the crop (that is, the quantities harvested) to the harvest variable.
3. Saves the end state of the time unit end to the actual_state variable.
statistics(): returns after the simulation:
– The number of harvests.
– The largest harvested crop
Notes:
– The implementation of the function generating the initial state is given.
– In the run function, a triple for loop implements the simulation (time, rows of land, columns of land).
Have to do on:
http://colab.research.google.com
# Homework
[1]
import matplotlib.pyplot as plt class Simulation: def __init__(self): self.width = 10 self.height = 10 self.actual_state = self.init_first_state() def init_first_state(self): init_state = [] for x in range(self.height): row = [] for y in range(self.width): row.append(0.1) init_state.append(row) return init_state def run(self, time): pass def statistics(self): harvest_amount = None maximal_harvest = None return harvest_amount, maximal_harvest[2]
if __name__ == '__main__': # Create Simulation instance sim = Simulation()[3]
if __name__ == '__main__': # Run simulation sim.run(100)[4]
if __name__ == '__main__': # Plot last state plt.imshow(sim.actual_state, cmap='Blues') plt.colorbar() plt.show()[5]
if __name__ == '__main__': # Print statistics amount, max_harv = sim.statistics() print('Number of harvests:', amount) print('Maximal harvest:', max_harv)Do you have any idea how next?