Skip to content

QuestionAnswered step-by-stepdo the following. no copied wor

Do you have a similar question? Our professional writers have done a similar paper in past. Give Us your instructions and wait for a professional assignment!        

QuestionAnswered step-by-stepdo the following. no copied workImage transcription textUnit 5 HW #3 Score: 0/5 0/5 answered Question 1 V Evaluate the integral fat (x5 – 9)do, by making thesubstitution u = – 9 + C NOTE: Your answer should be in terms of a and not u. Submit QuestionThis question builds on the last question. In Scheme, object-oriented basic top-levelenvironment with dispatch. Call this function create-env.The environment env uses the same dotted-pair and list structures to store variables/values andfunction-names/lamb da-b o dies. So, the list ((y . 20) (x . 10)) is the environment withtwo variables y and x that are b ound to 20 and 10, respectively. The env list ((square (lambda(x) (* x x))) (y . -9)) has the symb ol square bound to (lambda (x) (* x x)) and thevariable y b ound to -9.Your dispatcher should implement add-to and get-val while having an abstraction barrierhiding the env list and preventing direct access to the functions add-to and get-val. You mayuse mutative operations.> ( d e f i n e e ( c r e a t e – e n v ‘ ( ) ) )> ( ( e ‘ s h o w – a l l ) )( )> ( ( e ‘ a d d – t o ) ‘ x 1 0 )> ( ( e ‘ a d d – t o ) ‘ y – 5 )> ( ( e ‘ a d d – t o ) ‘ s q u a r e ‘ ( l a m b d a ( x ) ( * x x ) ) )> ( ( e ‘ s h o w – a l l ) )( ( s q u a r e l a m b d a ( x ) ( * x x ) ) ( y . – 5 ) ( x . 1 0 ) )> ( ( e ‘ g e t – v a l ) ‘ s q u a r e )( l a m b d a ( x ) ( * x x ) )> ( ( e ‘ g e t – v a l ) ‘ y )- 5THIS IS THE LAST QUESTIONA basic top-level environment may b e represented as a list. Variables and their values are storedas dotted-pairs. Function names and their lambda forms are stored as lists. So, the list ((y .20) (x . 10)) is the environment with two variables y and x that are b ound to 20 and 10,respectively. The list ((square (lambda (x) (* x x))) (y . -9)) has the symb ol squarebound to (lambda (x) (* x x)) and the variable y b ound to -9.Write Scheme functions add-to-env and get-val-from-env that create new variables (sym-bols) bound with their values in the environment. You may use mutative operationsAnyone know how to use python to create classes, objects and methods? I working on a comp sci project now and I’m so stuck.Your initial implementation consists of three classes and their associated methods, described next.class Disease():Note: the signature of the constructor should read?_init__(self, name=’influenza’, t=0.95, E=2, I=7, r=0.0).Objects in this class describe a particular disease, like influenza, the measles, or rubella. The initialization parameters correspond to the disease?ame, its transmissivity?, the number of days in the exposed state?, the number of days in the infected state?, and the probability that recovery confers lifetime immunity?, respectively (these default values are reasonable values for modeling the flu).class Agent():Note: the signature of the constructor should read?_init__(self, s=0.99).Objects in the class model the individual agents in the simulation. The only initialization parameter is the intrinsic susceptibility of the agent to disease; a higher number may indicate a frail elderly person or someone with a compromised immune system (both highly susceptible) while a lower number may indicate a healthy young adult in peak physical condition. You’ll also need a few additional variables which are not set at initialization, like the agent’s vaccination state,?, and some sort of internal state indicating if the agent is sick or not.This last requirement is easily met by keeping an internal state counter initially set to -1, indicating that the agent is initially in the susceptible state. When the agent is infected, the counter is set to I+E (parameters of the disease), and then decremented on each successive day of the simulation until it reaches 0, the recovered state. At this point, depending on the probability that lifetime immunity to thedisease is achieved upon recovery, the counter may be reset to -1, the susceptible state.1Your agent class will also require a few methods. The first method,?accinate(self, v)?ets the agent’s internal??ariable to indicate that some immunity to the disease has been instantly conferred by immunization. We’ll use this variable to model how quickly we can dampen how fast the disease spreads by starting to innoculate the herd:??lose to 0 indicates the vaccine is very effective, while??lose to 1 indicates very little protection. By default,??hould be 1.0, indicating that no vaccination has taken place.The second method,?nfect(self, other, disease)?ives agent?ther?he chance to infect agent?elf?ith?isease. Of course, first you’ll need to check if?ther?s infective, if?elf?s susceptible, vaccinated, etc.1 How can we model people who die from the disease? Even influenza can be fatal; indeed, there about 35,000 to 40,000 influenza deaths in the USA each year! Interestingly enough, in our simulation, a dead agent is no differ- ent from an agent with lifetime immunity; unlike a dead agent, a recovered but immune agent may hang around, but like a dead agent, they will never again make anyone else sick. This means we can factor the death rate into the per- manent immunity/recovery probability,?.2?evised November 3, 2015before you ”roll the die” to determine if the infection is transmitted. If successful, update?elf’s internal state counter as described above. The general idea here is that, if?elf?s susceptible and?ther?s either exposed or infected, we want to infect?elf?ith probability?elf????elf????isease.?, and adjust?elf’sinternal state accordingly.2 Also, be careful not to interpret this method the other way around ?since only one agent’s internal state is changed, it makes more?elf?o represent that agent, and therefore the agent that is being infected. This better fits with the notion of encapsulation that lies at the heart of the object-oriented worldview.The third method,?tate(self), returns True if?elf?nternal state corresponds to exposed or infected, and False otherwise.The fourth method,?pdate(self), is invoked on each agent every day, and is used to update?elf’s internal state indicating another day has elapsed, putting?elf?ne step closer to recovery if they are exposed or infected.class Simulation():Note: the signature of the constructor should read?_init__(self, D=500).The final class represents a simple simulation that runs at most??ays of simulation (the simulation may terminate early if there are no longer any infected agents remaining). The class must obviously have some internal variables that contain,?.g., a list of instances of Agent that are in the simulation and the instance of Disease that is being simulated. Other variables may also be necessary, such as, for example, a?ixing coefficient m?hat indicates the probability any one agent will encounter any other agent on any particular day. Interactions with instances of this class occur via the following methods.The first method,?oin(self, agent)?dds?gent?o the simulation.The second method,?ntroduce(self, disease)?dds?isease?o the simulation.The third method,?un(self)?tarts the simulation. The simulation runs for at most?elf.D?ays, but may terminate early if there are no longer any infected agents. The value returned should be a list of tuples (Ne,Ni) corresponding to daily snapshots of the simulation, where?e?s the number of exposed agents and?i?s the number of infected agents on the corresponding day (the list returned will contain at most??uples).Let’s play a few games of dice!Here are the rules:ROUND ONERoll one 6-sided die, call it XIf X is 1 or 2, you lose and the game is overIf X is 6, you win and the game is overif X is 3, 4, or 5, proceed to ROUND TWOROUND TWORoll two 6-sided dice independently, and call the result XIf X is 2, 3, 4, 5, 6, you lose and the game is overIf X is 7, 8, 9, 10, 11, or 12, you win and the game is overSimulate 1,000,000 dice games to see what the player’s probability of winning isA running C++ program is given below as your starting templateMake sure to use your “Irvine Chapter 8” understanding of advanced functions: parameter passing, local variables, and return valuesPost ONLY your ASM file here to Blackboard when complete// Includes#include <iostream>using namespace std;// Global variablesint wins = 0;int losses = 0;// One input parameter// One outputint Roll(int SIDES){?/ Return a random number between [1 to SIDES] inclusive on both ends?/ If SIDES is 6, then return a random number in the set { 1,2,3,4,5,6 }?nt eax = rand() % SIDES;?+eax;?eturn eax;}// No input parameters// One output – (0 = LOSS) and (1 = WIN)int Play(){?nt die = Roll(6);?nt eax = 0;?if (die == 6)??ax = 1;?lse if (die >= 3)???ie = Roll(6);?die += Roll(6);?if (die >= 7)??ax = 1;??eturn eax;}void main(){?/ Simulate a ton of games?nt ecx = 1000000;?do???int eax = Play();?if (eax == 0)???+losses;?else??+wins;? while (–ecx != 0);?/ What are the probabilities??out << “WINS: “;?// About 45-46%?out << wins;?out << endl;?out << “LOSSES: “;?// About 54-55%?out << losses;?out << endl;?/ Pause before ending program?ystem(“PAUSE”);Computer ScienceEngineering & TechnologyJava ProgrammingCOM 109Share Question

Get a plagiarism-free order today   we guarantee confidentiality and a professional paper and we will meet the deadline.    

Leave a Reply

Order a plagiarism free paper today. Get 20% off your first order!