Reference no: EM132260873
Concurrent Programming and Actors
Solve the following three problems using Java with Akka Actors. Read the submission instructions carefully.
Problem 1: Fibonacci Numbers 1. Develop an actor program for computing Fibonacci numbers concurrently. Particularly, create an actor which receives a request for a particular Fibonacci number from a client actor. If it is one of the base cases, the actor replies with a message containing the answer; otherwise, it creates the two sub-problems you would normally create in a recursive implementation. It then creates two new (Fibonacci) actors, and sends one subproblem to each. Once it has received replies from these actors, it adds them to produce its result, and sends it back to the computation's client.
Problem 2: Fibonacci Numbers 2. Develop an implementation of Fibonacci which uses fewer actors. Particularly, create an actor which receives a request for a particular Fibonacci number from a client actor. If it is one of the base cases, the actor replies with a message containing the answer; otherwise, it breaks down the problem into two sub-problems, sends the smaller of the two to a new Fibonacci actor and and the larger one to itself. When it receives the two replies, it adds them to produce its result, and sends it back to the computation's client.
Problem 3: Sorting. It is possible to sort a number of values using a pipeline of filter actors, each responsible for one value: the first actor picks the smallest values, the second, the second smallest and so on. Particularly, the first actor receives all the values, one by one. If there are more than one values received by an actor, it creates another actor; it keeps the smallest value received so far for itself, and sends all other values forward to the other actor. Each filter actor does the same thing.
Assume that each filter actor has local storage for only two of the values to be sorted: the next incoming value and the minimum value seen thus far.
A sentinel is used to indicate the end of the values to be sorted. The sentinel is then sent down the pipeline to inform all actors of the end of the input. On receiving the sentinel, each filter actor replies to the sender of the sentinel with its smallest value. All actors simply forward back the values they receive from actors down the pipeline from them, so that the first actor receives all the values in a sorted order, and sends them forward to the original requester, one value at a time.
Develop actor code to implement this for sorting positive integers. Use 0 to indicate the end of the values to be sorted.
Submission:
Create a directory with your nsid as its name. Inside this directory, create separate sub-directories with names like problem2, problem3, etc. for each programming problem. Under each programming problem's folder, place the entire Eclipse project for that problem. You may use other IDEs for your development; however, the submission must be a valid Eclipse project for the versions of Java and Akka introduced in tutorials.
Note: Only Need problem 2 and 3.