Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python help: Part 2 : Comparing Control Methods I In Part 2 , you will compare the performance of Monte Carlo control and Q -
python help:
Part : Comparing Control Methods I
In Part you will compare the performance of Monte Carlo control and Qlearning by running both algorithms on a small environment and then analyzing their progress toward finding the optimal policy and optimal state value function. For the sake of comparison, we will use value iteration to find the optimal policy.
A Value Iteration
Create a x instance of the FrozenPlatform environment with sprange a start position of which is the default no holes, and with randomstate
Create an instance of the DPAgent class with gamma and randomstate and use it to run value iteration to find the optimal policy for the environment.
Display the environment, setting fill to shade the the cells according to their value under the optimal policy, and setting contents to display the optimal policy.
B MC Control
Create an instance of MCAgent class for the environment created in Step A setting gamma and randomstate Do NOT set a policy for the agent, instead allowing the initial policy to be randomly generated.
Run Monte Carlo control with episodes, setting epsilon and alpha Then calculate the mean absolute difference between the optimal statevalue function found by value iteration and the current Monte Carlo estimate. Print the following message with the blank filled in with the appropriate value, rounded to decimal places
The mean absolute difference in V is
C Display the Policy
Display the environment from A setting fill to shade the the cells according to their value under the policy found by MC control, and set contents to display that policy.
D History Plot
Replace the first blank in the cell below the instance of MCAgent created in B Set the target parameter of the method to be equal to the statevalue function for the optimal policy as found by value iteration and then run this cell to show the history plot for the MC estimate of the state value function.
E QLearning
Create an instance of the TDAgent class for the environment created in Step A setting gamma and randomstate Do NOT set a policy for the agent, instead allowing the initial policy to be randomly generated.
Run Qlearning with episodes, setting epsilon and alpha Then calculate the mean absolute difference between the optimal statevalue function found by value iteration and the current Qlearning estimate. Print the following message with the blank filled in with the appropriate value, rounded to decimal places.
The mean absolute difference in V is
F Display the Policy
Display the environment from A setting fill to shade the the cells according to their value under the policy found by QLearning, and set contents to display that policy.
G History Plot
Replace the first blank in the cell below the instance of TDAgent created in E Set the target parameter of the method to be equal to the statevalue function for the optimal policy as found by value iteration and then run this cell to show the history plot for the QLearning estimate of the state value function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started