PCTExamples class provides methods to load a PCT hierarchy from a configuration file, summarize the hierarchy, get the configuration, draw the hierarchy, run the hierarchy for a specified number of steps, and close the environment. Attributes: hierarchy (PCTHierarchy): The loaded PCT hierarchy. env (Environment): The environment associated with the PCT hierarchy.
Below are several usage examples demonstrating the new keyword-argument-based interface for run_example.
# Basic run with MountainCar configfilename ='testfiles/MountainCar/MountainCar-cdf7cc.properties'result_basic = PCTExamples.run_example(filename)result_basic# Full featured runresult_full = PCTExamples.run_example( config_file=filename, run_hierarchy=True, render=False, early_termination=True, steps=5000, print_summary=False, return_config=False, verbose=False, image_params={'figsize': (16, 10), 'with_labels': True}, video_params={'fps': 60, 'filename': '/tmp/mountaincar_demo.mp4'}, plot_params={'plots_figsize': (14, 8), 'title_prefix': 'MountainCar_'})result_full# Just create image and get configresult_image = PCTExamples.run_example( config_file=filename, run_hierarchy=False, return_config=True, print_summary=False,# plot_params={'single_plot': True, 'plots': {'title': 'position_plot', 'plot_items': ['position']}})result_image# Display usage helpPCTExamples.run_example('', display_usage=True)
PCTExamples.run_example() Usage:
Basic usage:
PCTExamples.run_example('testfiles/MountainCar/MountainCar-cdf7cc1497ad143c0b04a3d9e72ab783.properties')
With options:
PCTExamples.run_example(
config_file='testfiles/MountainCar/MountainCar-cdf7cc1497ad143c0b04a3d9e72ab783.properties',
run_hierarchy=True, # Run the hierarchy
render=True, # Render environment
image_params={...}, # Create hierarchy diagram if not None
video_params={...}, # Create video if not None
plot_params={...}, # Create plots if not None
early_termination=True, # Enable early termination
steps=1000, # Override step count
print_summary=True, # Print hierarchy summary
return_config=True, # Return configuration
verbose=True # Verbose output
)
Returns dictionary with results and any requested outputs.
C:\Users\ruper\Versioning\python\nbdev\pct\pct\hierarchy.py:340: UserWarning:
This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.