Solved–Lab 3– Solution

$30.00 $19.00

The connection of the road network is speci ed as a matrix M ( lename is \road.txt”). There are 10 sites indexed as (0; 1; : : : ; 9). Entry M(i; j) denotes the length of the road between site i and j in kms (the roads are uni-directional). The roads are uni-directional (i.e.,…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)
  1. The connection of the road network is speci ed as a matrix M ( lename is \road.txt”). There are 10 sites indexed as (0; 1; : : : ; 9). Entry M(i; j) denotes the length of the road between site i

and j in kms (the roads are uni-directional). The roads are uni-directional (i.e., there could be a road from A to B, but not from B to A). If the entry is 0, it means no connection. Vehicles depart from a source and then take a path ( lename \vehicle.txt”). The time of departure (in minutes) is given in lename \time.txt”, nth vehicle departs at time instance n. The speed (in kmph) of the vehicle in a road is given by the formula e0:5x=(1 + e0:5x) + 15=(1 + e0:5x), where x is the number of vehicles ahead in a given road. If there are n vehicles in the road, then for the rst vehicle x = 0, second vehicle x = 1, and for the last vehicle x = n 1. The time taken

to travel the road is dist/speed. Implement a function that takes time as input and reports

the position of various vehicles at that given time. [20]

2. There is an under-powered car stuck in the bottom of a 1-dim valley. It needs to nd its way to the top. The car has three actions namely A = f 1; 0; +1g which means accelerate backward, no acceleration and accelerate forward, respectively. A chosen action is applied for a xed duration of time, after which a new action is chosen. The ranges for position and velocity are

  • 1:2; 0:5] and [ 0:07; 0:07], respectively. The car is needs to reach the top on the right, i.e., position of 0:5. The dynamics is according to the equations:

vn+1 = vn + 0:001an 0:0025 cos(3pn)

pn+1 = pn + vn

(a) Implement a function which takes in the current position and action and outputs the

position and velocity at the next step.

[25]

  1. Implement a random agent which at each time instant chooses one of the three actions uniformly at random. Plot f(pn; vn); n 1g produced by the random agent. Take the

initial position to be 0:5, and initial velocity to be 0. [15]

(c) Implement another agent which accelerates in the direction of the current velocity. Plot f(pn; vn); n 1g produced by this agent. Take the initial position to be 0:5, and initial

velocity to be 0. [10]

3. Read the text le \speeches.txt”

(a)

Compute the next word probabilities.

[10]

(b)

Based on the next word probabilities, write down a code that will produce random text

of length 5000.

[10]

(c)

Compute the next word probability from the previous task and show that it converges to

the next word probabilities calculated from the original text.

[10]

End of paper