{ "cells": [ { "metadata": {}, "cell_type": "markdown", "source": "# Passive Algorithms", "id": "eb9fb4a1a68e633" }, { "metadata": {}, "cell_type": "markdown", "source": "AMLGym includes several algorithms for passive learning domain models from full/partial/noisy trajectories.", "id": "1ac309b575ed4764" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "!pip install amlgym", "id": "3a2c1c2a35c2e0f2" }, { "cell_type": "code", "execution_count": null, "id": "initial_id", "metadata": { "collapsed": true }, "outputs": [], "source": [ "from amlgym.benchmarks import get_domain_path, get_trajectories_path\n", "from amlgym.algorithms import print_algorithms, get_algorithm\n", "print_algorithms()" ] }, { "metadata": {}, "cell_type": "markdown", "source": "## Example 1: passive learning with full observability", "id": "bf47f050c2091de8" }, { "metadata": {}, "cell_type": "markdown", "source": "Instantiate an algorithm for passive learning domain models in fully observable environments (e.g., [SAM](https://proceedings.kr.org/2021/36/)):", "id": "79155f5492207006" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "learner = get_algorithm('sam')", "id": "fd36b0d1fc890673" }, { "metadata": {}, "cell_type": "markdown", "source": "Get an empty IPC domain:", "id": "b2269aec54a3bbdf" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "from amlgym.util.util import empty_domain\n", "\n", "domain_path = get_domain_path('blocksworld')\n", "\n", "domain_empty_path = empty_domain(domain_path)\n", "with open(domain_empty_path, 'r') as f:\n", " print(f.read())" ], "id": "9f69a6f17bb858d8" }, { "metadata": {}, "cell_type": "markdown", "source": "Get a set of trajectories associated with the domain:", "id": "36f783186cfae5ea" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "traj_paths = get_trajectories_path('blocksworld')", "id": "89539b7fd80ffd2e" }, { "metadata": {}, "cell_type": "markdown", "source": "Learn a domain model specified in PDDL:", "id": "cf8aec8f3208ce17" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "model = learner.learn(domain_empty_path, traj_paths)\n", "print(model)" ], "id": "61ccca1a6d88ba94" }, { "metadata": {}, "cell_type": "markdown", "source": "## Example 2: passive learning with partial observability", "id": "9743932cbe218fc2" }, { "metadata": {}, "cell_type": "markdown", "source": "Instantiate an algorithm for passive learning domain models in partially observable environments (e.g., [OffLAM](https://www.sciencedirect.com/science/article/abs/pii/S0004370224001929)):", "id": "bab53c77635504ca" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "learner = get_algorithm('offlam')", "id": "43e369f4736b8347" }, { "metadata": {}, "cell_type": "markdown", "source": "Get an empty IPC domain and associated set of trajectories:", "id": "539d621d2da27455" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "domain_path = get_domain_path('blocksworld')\n", "domain_empty_path = empty_domain(domain_path)\n", "traj_paths = get_trajectories_path('blocksworld')" ], "id": "635700869294d7e9" }, { "metadata": {}, "cell_type": "markdown", "source": "Learn a domain model specified in PDDL:", "id": "5420c1797cfeea5d" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "model = learner.learn(domain_empty_path, traj_paths)\n", "print(model)" ], "id": "44fe1f41db91c3c4" }, { "metadata": {}, "cell_type": "markdown", "source": "## Example 3: passive learning with noisy observability", "id": "2d2085c200ee951" }, { "metadata": {}, "cell_type": "markdown", "source": "Instantiate an algorithm for passive learning domain models in noisy environments (e.g., [NOLAM](https://ojs.aaai.org/index.php/ICAPS/article/view/31493)):", "id": "6716e7dab6fea2f5" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "learner = get_algorithm('nolam', noise=0.1)", "id": "5428b802bec37744" }, { "metadata": {}, "cell_type": "markdown", "source": "Get an empty IPC domain and associated set of trajectories:", "id": "c4e7bae09e022dc4" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "domain_path = get_domain_path('blocksworld')\n", "domain_empty_path = empty_domain(domain_path)\n", "traj_paths = get_trajectories_path('blocksworld')" ], "id": "e8fe833ef5eb441" }, { "metadata": {}, "cell_type": "markdown", "source": "Learn a domain model specified in PDDL:", "id": "767927be0478cf87" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "model = learner.learn(domain_empty_path, traj_paths)\n", "print(model)" ], "id": "e118d39c95031ebb" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }