Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 8 Homework 8 will be part of Project 2 EAS520/DSC520 High-Performance Scientific Computing 1 / 3 Problem 1 Use the message passing technique to

Homework 8 Homework 8 will be part of Project 2 EAS520/DSC520 High-Performance Scientific Computing 1 / 3 Problem 1 Use the message passing technique to simulate a random walk of n objects on a "periodic" or "circular" integer lattice. The rules are described as the following: 1. The lattice can be discretized as N grid points with a location at 1, 2, ..., N. 2. Initially, the n objects can be placed anywhere randomly in the lattice. One or more objects can occupy the same grid point at any given time. 3. Each object must flip a coin before moving a step: Move 1 step to the right (Head) or Move 1 step to the left (Tail). 4. If an object located at grid point N moves 1 step to the right, it should land in grid point 1. If an object located at grid point 1 moves 1 step to the left, it should land in grid point N. The lattice should be distributed into np partitions where np is the number of workers (cpus/cores). For example, for the case where N=10 and np=2, worker 1 is taking care of grid 1, ..., 5, and worker 2 is taking care of grid 6, ..., 10. Utilize the commands labSend, labProbe, labReceive, and labBarrier to deal with objects crossing partitions. Stop the simulation when all objects achieve M steps. Plot the initial and final positions of all objects. 2 / 3 Problem 2 Use the message passing technique to simulate online gambling. The rules are described as the following: 1. There is one dealer and n players (bettors). Initially, the dealer has an M amount of money, and each player has amount of funds in the bank, respectively. You may also assume that the dealer has much more money than all players combined. 2. Each player will make a bet. Initial bet can range from $1 to the maximum available money in the bettor's bank. 3. The chance of winning and losing is 50-50 (like flipping a coin). If one wins, the dealer pays the bettor, and that individual will put half of the amount of winning money for the next bet. If one loses, the bettor pays the dealer and then puts one-fourth of the remaining money in the bank for the next bet. 4. A player or a dealer is declared bankrupt if there is only less than $1 in the bank. Simulate the gambling process until either the dealer or all players went bankrupt. For example, for the case with 1 dealer and n=3 players, you can use 4 cores. Core 1 is reserved for the dealer, core 2 for bettor 1, core 3 for bettor 2, core 4 for bettor 3. 3 / 3

Attachments:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions