Open In Colab

2. Passive Algorithms

AMLGym includes several algorithms for passive learning domain models from full/partial/noisy trajectories.

[ ]:
!pip install amlgym
[ ]:
from amlgym.benchmarks import get_domain_path, get_trajectories_path
from amlgym.algorithms import print_algorithms, get_algorithm
print_algorithms()

2.1. Example 1: passive learning with full observability

Instantiate an algorithm for passive learning domain models in fully observable environments (e.g., SAM):

[ ]:
learner = get_algorithm('sam')

Get an empty IPC domain:

[ ]:
from amlgym.util.util import empty_domain

domain_path = get_domain_path('blocksworld')

domain_empty_path = empty_domain(domain_path)
with open(domain_empty_path, 'r') as f:
    print(f.read())

Get a set of trajectories associated with the domain:

[ ]:
traj_paths = get_trajectories_path('blocksworld')

Learn a domain model specified in PDDL:

[ ]:
model = learner.learn(domain_empty_path, traj_paths)
print(model)

2.2. Example 2: passive learning with partial observability

Instantiate an algorithm for passive learning domain models in partially observable environments (e.g., OffLAM):

[ ]:
learner = get_algorithm('offlam')

Get an empty IPC domain and associated set of trajectories:

[ ]:
domain_path = get_domain_path('blocksworld')
domain_empty_path = empty_domain(domain_path)
traj_paths = get_trajectories_path('blocksworld')

Learn a domain model specified in PDDL:

[ ]:
model = learner.learn(domain_empty_path, traj_paths)
print(model)

2.3. Example 3: passive learning with noisy observability

Instantiate an algorithm for passive learning domain models in noisy environments (e.g., NOLAM):

[ ]:
learner = get_algorithm('nolam', noise=0.1)

Get an empty IPC domain and associated set of trajectories:

[ ]:
domain_path = get_domain_path('blocksworld')
domain_empty_path = empty_domain(domain_path)
traj_paths = get_trajectories_path('blocksworld')

Learn a domain model specified in PDDL:

[ ]:
model = learner.learn(domain_empty_path, traj_paths)
print(model)