Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMDN #140

Merged
merged 211 commits into from
Nov 23, 2021
Merged

AMDN #140

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
e139e2b
Initial commit
e-cal Jul 7, 2021
ae68d93
Merge branch 'dev' into arms
e-cal Jul 7, 2021
e025007
Fix typing
e-cal Jul 7, 2021
7abf275
Make partial observation method selection use string instead of full …
e-cal Jul 7, 2021
3dcc176
Add arms test
e-cal Jul 7, 2021
8d4ea67
Add ARMS to Extract
e-cal Jul 7, 2021
79fe6d5
Add functions to ARMS
e-cal Jul 8, 2021
a6dcc54
Merge branch 'obs-changes' into arms
e-cal Jul 8, 2021
4a085a7
Merge branch 'obs-changes' into arms
e-cal Jul 8, 2021
1478be8
Simplify extract imports
e-cal Jul 8, 2021
d58ff9e
Merge branch 'dev' into arms
e-cal Jul 8, 2021
006b226
Use sets for action obj_params
e-cal Jul 10, 2021
b764b4f
Add getters to ObservationLists
e-cal Jul 10, 2021
9ec0ba4
step 1
e-cal Jul 10, 2021
5538cbc
Framework of step 2
e-cal Jul 10, 2021
3460b21
Split step 2 into substeps
e-cal Jul 12, 2021
69a390c
Add substeps
e-cal Jul 12, 2021
728daf7
Step 2A
e-cal Jul 12, 2021
39e75fb
Merge branch 'obs-changes' into arms
e-cal Jul 12, 2021
dc46ec2
Merge branch 'obs-changes' into arms
e-cal Jul 12, 2021
f2957f8
Step 2I1 and Step 2I2
e-cal Jul 15, 2021
96252ba
Step 2I3
e-cal Jul 16, 2021
2fcaf5b
Implement the Apriori algorithm
e-cal Jul 19, 2021
13efa29
Add comments and pseudocode for step 2P
e-cal Jul 19, 2021
c0d4fad
Step 2P
e-cal Jul 21, 2021
97b59b0
Add more typing, start step 3
e-cal Jul 21, 2021
9e945f7
Use negate instead of parsing negatives
e-cal Jul 21, 2021
4f150c2
Add pysat WCNF encoder based on encoder in python-nnf
e-cal Jul 21, 2021
cab1b11
Seperate weights from constraints, calculate special weights
e-cal Jul 21, 2021
6e77f4c
Add args, check for valid threshold
e-cal Jul 21, 2021
45c831b
Step 3
e-cal Jul 22, 2021
fb0563b
Merge branch 'trace-gen-w-goal' into arms
e-cal Jul 22, 2021
3017910
Rename SLAF.py slaf.py
e-cal Jul 22, 2021
2281d60
Use tarski devel branch
e-cal Jul 22, 2021
7587619
Add comparison function to Trace
e-cal Jul 22, 2021
1da7c48
Add test file
e-cal Jul 22, 2021
d9708fc
Add nnf to dependencies
e-cal Jul 22, 2021
937a8ad
Add testing
e-cal Jul 23, 2021
b788885
Fix trace bug
e-cal Jul 23, 2021
848f620
Fix missing actions
e-cal Jul 23, 2021
7c70e12
Use connectors to get relevant relations in 2P
e-cal Jul 23, 2021
3ebf6f5
Add more strict typing
e-cal Jul 23, 2021
27ffe0a
Delay conjunction of I1 and I2 constraints
e-cal Jul 23, 2021
a7e2003
Fix pysat translator typing
e-cal Jul 23, 2021
b55d2bc
Add Step 4
e-cal Jul 23, 2021
32469e8
Remove problem simplification
e-cal Jul 23, 2021
559c1d6
Remove test file
e-cal Jul 23, 2021
497a457
Remove test model
e-cal Jul 23, 2021
74c8e6a
Fix tests
e-cal Jul 26, 2021
518a5ec
Add InconsistentConstraintWeight exception
e-cal Jul 26, 2021
13059e6
Remove duplicate constraints and check for consistent weight assignment
e-cal Jul 26, 2021
93a4df1
Fix incorrect weight list
e-cal Jul 26, 2021
2143068
Simplify test
e-cal Jul 26, 2021
9ccae55
Filter nnf.false from constraints
e-cal Jul 26, 2021
5d17d30
Add InvalidMaxSATModel exception
e-cal Jul 26, 2021
5c68431
Check for a valid model, strict typing on the model
e-cal Jul 26, 2021
1435261
Remove goal check (goal isn't saved)
e-cal Jul 27, 2021
cc35ef8
Cleanup pysat typing
e-cal Jul 27, 2021
9c02314
Decode in Step 4 and add Step 5
e-cal Jul 27, 2021
f355338
Split constraints into its parts
e-cal Jul 27, 2021
13db5f9
Add ConstraintContradiction exception
e-cal Jul 27, 2021
ca45acd
Step 5: decode MAX-SAT solution into learned action models
e-cal Jul 27, 2021
114e9af
Add upper bound
e-cal Jul 28, 2021
b15adec
Add debug arg to Extract API
e-cal Jul 28, 2021
0101fc9
Use reversed action map for learning actions
e-cal Jul 28, 2021
4c82d90
Fix missing message
e-cal Jul 29, 2021
17b5399
Add typing to LearnedAction obj_params
e-cal Jul 29, 2021
94ea2ee
Add main ARMS loop
e-cal Jul 29, 2021
55ce324
Fix get_fluents removed from ObservationLists
e-cal Jul 29, 2021
53228f9
Add more debugging functionalty
e-cal Jul 29, 2021
689fda1
Fix possible missing action in info constraints
e-cal Jul 29, 2021
268eb30
More verbose debugging info
e-cal Jul 29, 2021
5d3bd67
Clean up debugging output
e-cal Jul 29, 2021
2de59b0
Add early action pointers and early state update
e-cal Jul 30, 2021
14f643f
Merge branch 'main' into arms
e-cal Aug 3, 2021
88f6e60
Fix intermediate observation state updates
e-cal Aug 3, 2021
af24881
Add debugging functionality for step 1
e-cal Aug 4, 2021
34a63b3
Add debug menus for each step in debug mode
e-cal Aug 4, 2021
dae2d11
Parse plan constraints after action and info
e-cal Aug 6, 2021
c57092d
Mutate action effects based on plan constraints
e-cal Aug 6, 2021
aeba37c
Fix constraint parsing
e-cal Aug 6, 2021
132692d
set up disorder and parallel constraints
Aug 8, 2021
c69428f
Update docs
e-cal Aug 9, 2021
f84fc9c
Add debugging to step 5
e-cal Aug 9, 2021
54449c2
Cleanup code
e-cal Aug 10, 2021
64edaa8
Merge branch 'amdn-tokenization' into amdn
Aug 10, 2021
26ffd34
add amdn option
Aug 10, 2021
916d4de
Merge branch 'amdn-tokenization' into amdn
Aug 10, 2021
68d0465
full algorithm implementation first pass
Aug 11, 2021
b04e297
Change constraint breakpoint to make it more readable
e-cal Aug 11, 2021
a507f44
Add ARMS testing
e-cal Aug 11, 2021
1232362
update algorithms to iterate through all traces
Aug 11, 2021
a9dc7f3
noise constraint bug fix
Aug 11, 2021
7b13532
fix noise constraint 7
Aug 12, 2021
57679a6
Add observation lists visualization
e-cal Aug 12, 2021
f924dda
import pysat
Aug 13, 2021
1412092
Add vizualization functions to ObservationLists
e-cal Aug 13, 2021
25b05c3
Add SAS triples to ObservationLists
e-cal Aug 13, 2021
fb062b3
Merge branch 'obs-viz' into arms
e-cal Aug 13, 2021
1e731ac
Remove SAS triples from ObservationLists (use get_transitions instead)
e-cal Aug 13, 2021
506df42
Make all observations hashable
e-cal Aug 13, 2021
5f0dbc5
Add warning for generic Observation hashes
e-cal Aug 13, 2021
2dc7a1a
Fix type errors
e-cal Aug 13, 2021
ad8a481
Fix typing on ObservationLists functions
e-cal Aug 13, 2021
2ba6141
Move detail generation to Observation
e-cal Aug 13, 2021
6521253
Overload ObservationLists constructor
e-cal Aug 13, 2021
dd7162d
Remove debugging code
e-cal Aug 13, 2021
5e45a67
fix disorder constraints weight, make amdn cls
Aug 16, 2021
0ea58c0
fix constraint weights
Aug 16, 2021
dab5841
convert to model
Aug 17, 2021
372085e
split up functions in pysat, get 1 proper wcnf
Aug 17, 2021
2f4b9b1
Make AtomicPartialObservation work like PartialObservation, add atomi…
e-cal Aug 18, 2021
29b05d2
Fix tests
e-cal Aug 18, 2021
2733bb6
Use list for LearnedAction obj_params
e-cal Aug 18, 2021
b9fcf4e
Filter out fluents that don't match the action schemata in step 2I
e-cal Aug 18, 2021
244a9ca
Update pysat module
e-cal Aug 18, 2021
1e25c1f
Merge branch 'amdn-tokenization' into amdn
Aug 19, 2021
7725e16
Add debug arg to Observer
e-cal Aug 19, 2021
158093a
optimize prob calculation
Aug 19, 2021
7099f16
Replace logging.warn with warnings.warn
e-cal Aug 19, 2021
5bc104e
Merge branch 'amdn-tokenization' into amdn
Aug 19, 2021
885a4e5
Fix test_trace
e-cal Aug 19, 2021
51a2096
Merge pull request #133 from QuMuLab/amdn-tokenization
haz Aug 20, 2021
ef5d89b
Merge main
e-cal Aug 20, 2021
05bf5a1
Update test_arms
e-cal Aug 20, 2021
a9fbfc5
Fix tests
e-cal Aug 20, 2021
9533dd5
add repr to actionpair, add all_states attribute
Aug 20, 2021
dd63a06
Fix path to test pddl
e-cal Aug 20, 2021
10f8833
Add test for DisorderedParallelActionsObservationLists
e-cal Aug 20, 2021
2ae9711
Restore trace Action effects
e-cal Aug 20, 2021
70a51ce
make test tracelist for debugging
Aug 20, 2021
39dc9a0
Merge main
e-cal Aug 20, 2021
60906b1
Remove Disordered... test
e-cal Aug 20, 2021
ee2daf8
Cleanup Action
e-cal Aug 23, 2021
eb8a821
Cleanup NoisyObservation
e-cal Aug 23, 2021
c449807
Replace if with return in all __eq__ functions
e-cal Aug 23, 2021
71cf99e
Fix Action test
e-cal Aug 23, 2021
5319125
Merge pull request #141 from QuMuLab/atomic-part-obs-rework
haz Aug 23, 2021
0042798
Add 5x try catch to response from planning.domains solver
e-cal Aug 23, 2021
f7d9daf
Merge branch 'main' into arms
e-cal Aug 23, 2021
1a01fec
Add sleep to later try-catch attempts
e-cal Aug 23, 2021
8307d1c
add repr for debugging purposes
Aug 23, 2021
eb311f3
add last state with empty action to tokens
Aug 23, 2021
dc70253
make larger test trace, accomodate "None" action
Aug 23, 2021
0505825
Update test_slaf
e-cal Aug 24, 2021
cf03bbe
refactor disorder constraints
Aug 24, 2021
a14ca54
Restore test_slaf dir
e-cal Aug 24, 2021
44ac0c3
Update README.md
e-cal Aug 24, 2021
86aa67c
Remove redundant code
e-cal Aug 24, 2021
c114bed
refactor constraints to set weights appropriately
Aug 24, 2021
dfb7f90
fix soft parallel constraints
Aug 24, 2021
1355ab2
document amdn paper issues
Aug 24, 2021
85b22a1
add dom/prob, update gen to handle atomic actions
Aug 24, 2021
624c978
ObservationLists inherits from MutableSequence, moved to observation API
e-cal Aug 24, 2021
0467d33
Check for matching token type on insert
e-cal Aug 24, 2021
125be77
Fix token type-check
e-cal Aug 24, 2021
d5bb605
TraceList inherits from MutableSequence
e-cal Aug 24, 2021
acc2cca
Cleanup unnessecary code
e-cal Aug 24, 2021
b885f4c
write debug mode for dc constr and replace noisy f
Aug 25, 2021
e0d1146
debug disorder constraints
Aug 25, 2021
b3c5def
Add Observer usage documentation
e-cal Aug 25, 2021
51cb92e
Add index page
e-cal Aug 25, 2021
13c38ac
Add SLAF usage
e-cal Aug 25, 2021
20a8cbf
Add AMDN usage section
e-cal Aug 25, 2021
86a7f05
Add ARMS usage
e-cal Aug 25, 2021
3e1c6b2
Merge branch 'arms' into usage-docs
e-cal Aug 25, 2021
03fa7b0
Ignore docs folder
e-cal Aug 25, 2021
f0d836f
Document ObservationLists init docstring
e-cal Aug 25, 2021
9e8137f
Add documentation for pysat utils module
e-cal Aug 25, 2021
b27316b
Cleanup api response handling
e-cal Aug 25, 2021
01d55be
Re-add hash function to IdentityObservation
e-cal Aug 25, 2021
9116287
Import pysat functionality from pysat utils module
e-cal Aug 25, 2021
6e150b8
Add steps to ARMS docstrings
e-cal Aug 25, 2021
96d41a3
Replace ternary operators with dictionary redirect
e-cal Aug 25, 2021
681fbfd
Merge pull request #145 from QuMuLab/separate-obs-trace
haz Aug 26, 2021
7b0732d
add debug mode to observe certain fluents
Aug 26, 2021
97ffdc2
Merge branch 'main' into arms
e-cal Aug 26, 2021
a5e244d
Fix ObservationLists import in ARMS
e-cal Aug 26, 2021
048de78
Make step functions public (so docs show), add documentation
e-cal Aug 26, 2021
8301cb8
fix model parsing
Aug 26, 2021
e1402b6
Add documentation for remaining steps
e-cal Aug 26, 2021
a9dcd9d
Merge branch 'arms' into usage-docs
e-cal Aug 26, 2021
8a797c5
Add ARMS usage docs
e-cal Aug 26, 2021
350ae82
Add Extract documentation
e-cal Aug 26, 2021
6f08ec5
attempt to debug door domain
Aug 27, 2021
ff130da
truck domain debug
Aug 27, 2021
c5d9860
Merge pull request #109 from QuMuLab/arms
haz Aug 30, 2021
4630832
add wrappers to add timer parameters
Aug 30, 2021
519470c
update docs, add error for invalid time
Aug 30, 2021
c3a6bb4
Merge branch 'main' into generators-dynamically-change-timer
Aug 30, 2021
20c9ab1
Add doc generation to CONTRIBUTING.md
e-cal Aug 30, 2021
34fe41b
Add ... to SLAF docs
e-cal Aug 30, 2021
f1686a5
Merge branch 'main' into amdn
Aug 30, 2021
5ed6e30
fix init issue from merge
Aug 30, 2021
0bb753c
show current time attribute when error is raised
Aug 30, 2021
d640101
update to match observationlist changes
Aug 30, 2021
e82dc44
Add progress module to utils, select function based on tqdm avail.
e-cal Aug 30, 2021
70ade32
Merge pull request #146 from QuMuLab/usage-docs
haz Aug 31, 2021
590d5b9
Merge pull request #148 from QuMuLab/generators-dynamically-change-timer
haz Aug 31, 2021
e9d71cc
Add tqdm redirect, and fallback progress counter
e-cal Aug 31, 2021
57530d8
use union of action effs for states in between
Aug 31, 2021
89cb011
clean up
Aug 31, 2021
2fa042d
cleanup, move common function in amdn out to pysat
Aug 31, 2021
7929ce9
Handle Sized and Unsized iterables
e-cal Aug 31, 2021
dfa18d5
Use Any as return type
e-cal Aug 31, 2021
5bfecf7
Wrap trace generation with progress bar
e-cal Aug 31, 2021
102987e
Merge branch 'main' into progress-bar
e-cal Aug 31, 2021
553ffcc
Add documentation
e-cal Aug 31, 2021
aaa27cb
update docs and readme, clean up
Aug 31, 2021
57cb1f4
Merge pull request #149 from QuMuLab/progress-bar
haz Nov 23, 2021
e220510
Merge branch 'main' into amdn
haz Nov 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ __init__.pyc
generated_testing_files/
new_domain.pddl
new_prob.pddl
test_model.json
test_model.json
results.txt
html/
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
### Installing

Install macq for development by cloning the repository and running
`pip install .[dev]`
`pip install -e .[dev]`

We recommend installing in a virtual environment to avoid package version
conflicts.

**Note: `tarski` requires [`clingo`](https://potassco.org/clingo/) be installed to work.**

### Formatting

We use [black](https://black.readthedocs.io/en/stable/) for easy and consistent
Expand All @@ -34,3 +36,12 @@ report, run `pytest --cov=macq --cov-report=html`, and open `htmlcov/index.html`
in a browser. This will provide detailed line by line test coverage information,
so you can identify what specifically still needs testing.

### Generating Docs
To generate the HTML documentation, run `pdoc --html macq --config latex_math=True`.

During development, you can run a local HTTP server to reference/see live
changes to the documentation: `pdoc --http : macq --config latex_math=True`.

*Note: `--config latex_math=True` is required to properly render the latex found
in many extraction techniques' documentation.*

52 changes: 4 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This library is a collection of tools for planning-like action model acquisition
## Usage <a name="usage" />
```python
from macq import generate, extract
from macq.observation import IdentityObservation
from macq.observation import IdentityObservation, AtomicPartialObservation

# get a domain-specific generator: uses api.planning.domains problem_id/
# generate 100 traces of length 20 using vanilla sampling
Expand All @@ -39,50 +39,6 @@ trace.actions
trace.get_pre_states(action) # get the state before each occurance of action
trace.get_post_states(action) # state after each occurance of action
trace.get_total_cost()

######################################################################
# Model Extraction - OBSERVER Technique
######################################################################
observations = traces.tokenize(IdentityObservation)
model = extract.Extract(observations, extract.modes.OBSERVER)
model.details()

Model:
Fluents: at stone stone-03 location pos-04-06, at stone stone-01 location pos-04-06, at stone stone-02 location pos-05-06, at stone stone-06 location pos-07-04, at stone stone-11 ...
Actions:
push-to-goal stone stone-04 location pos-04-05 location pos-04-06 direction dir-up location pos-04-04 player player-01:
precond:
at player player-01 location pos-04-06
at stone stone-04 location pos-04-05
clear location pos-05-06
...
add:
at stone stone-04 location pos-04-04
clear location pos-04-06
at-goal stone stone-04
at player player-01 location pos-04-05
delete:
at stone stone-04 location pos-04-05
clear location pos-04-04
at player player-01 location pos-04-06
...
######################################################################
# Model Extraction - SLAF Technique
######################################################################
traces = generate.pddl.VanillaSampling(problem_id = 123, plan_len = 2, num_traces = 1).traces
observations = traces.tokenize(PartialObservabilityToken, method=PartialObservabilityToken.random_subset, percent_missing=0.10)
model = Extract(observations, modes.SLAF)
model.details()

Model:
Fluents: clear location pos-06-09, clear location pos-02-05, clear location pos-08-08, clear location pos-10-05, clear location pos-02-06, clear location pos-10-02, clear location pos-01-01, at stone stone-05 location pos-08-05, at stone stone-07 location pos-08-06, at stone stone-03 location pos-07-04, clear location pos-03-06, clear location pos-10-06, clear location pos-10-10, clear location pos-05-09, clear location pos-05-07, clear location pos-02-07, clear location pos-09-01, at stone stone-06 location pos-04-06, clear location pos-02-03, clear location pos-07-05, clear location pos-09-10, clear location pos-06-05, at stone stone-01 location pos-05-04, clear location pos-02-10, clear location pos-06-10, clear location pos-11-03, at stone stone-11 location pos-06-08, at stone stone-08 location pos-04-07, clear location pos-01-10, clear location pos-07-03, clear location pos-02-11, clear location pos-03-01, clear location pos-06-02, clear location pos-03-02, clear location pos-11-01, clear location pos-06-03, clear location pos-08-04, clear location pos-09-11, at stone stone-09 location pos-08-07, clear location pos-09-07, clear location pos-06-07, clear location pos-10-01, clear location pos-11-09, clear location pos-03-05, clear location pos-07-06, clear location pos-05-05, at stone stone-12 location pos-07-08, clear location pos-10-03, clear location pos-11-11, clear location pos-10-09, clear location pos-02-01, clear location pos-02-02, clear location pos-01-02, at stone stone-02 location pos-06-04, clear location pos-03-10, clear location pos-05-10, clear location pos-07-10, clear location pos-09-05, clear location pos-07-09, clear location pos-05-03, clear location pos-10-11, clear location pos-01-03, at stone stone-04 location pos-04-05, clear location pos-07-02, clear location pos-09-06, clear location pos-10-07, clear location pos-01-09, clear location pos-03-07, clear location pos-04-04, clear location pos-01-11
Actions:
move player player-01 direction dir-left location pos-05-02 location pos-06-02:
precond:
add:
delete:
(clear location pos-05-02)
(at player player-01 location pos-06-02)
```

## Coverage <a name="coverage"></a>
Expand All @@ -92,9 +48,9 @@ Model:
- [x] [Learning Planning Operators by Observation and Practice](https://aaai.org/Papers/AIPS/1994/AIPS94-057.pdf) (AIPS'94)
- [ ] [Learning by Experimentation: Incremental Refinement of Incomplete Planning Domains](https://www.sciencedirect.com/science/article/pii/B9781558603356500192) (ICML'94)
- [ ] [Learning Probabilistic Relational Planning Rules](https://people.csail.mit.edu/lpk/papers/2005/zpk-aaai05.pdf) (ICAPS'04)
- [ ] [Learning Action Models from Plan Examples with Incomplete Knowledge](https://www.aaai.org/Papers/ICAPS/2005/ICAPS05-025.pdf) (ICAPS'05)
- [x] [Learning Action Models from Plan Examples with Incomplete Knowledge](https://www.aaai.org/Papers/ICAPS/2005/ICAPS05-025.pdf) (ICAPS'05)
- [ ] [Learning Planning Rules in Noisy Stochastic Worlds](https://people.csail.mit.edu/lpk/papers/2005/zpk-aaai05.pdf) (AAAI'05)
- [ ] [Learning action models from plan examples using weighted MAX-SAT](https://www.sciencedirect.com/science/article/pii/S0004370206001408) (AIJ'07)
- [x] [Learning action models from plan examples using weighted MAX-SAT](https://www.sciencedirect.com/science/article/pii/S0004370206001408) (AIJ'07)
- [ ] [Learning Symbolic Models of Stochastic Domains](https://www.aaai.org/Papers/JAIR/Vol29/JAIR-2910.pdf) (JAIR'07)
- [x] [Learning Partially Observable Deterministic Action Models](https://www.aaai.org/Papers/JAIR/Vol33/JAIR-3310.pdf) (JAIR'08)
- [ ] [Acquisition of Object-Centred Domain Models from Planning Examples](https://ojs.aaai.org/index.php/ICAPS/article/view/13391) (ICAPS'09)
Expand All @@ -113,7 +69,7 @@ Model:
- [ ] [Learning STRIPS Action Models with Classical Planning](https://arxiv.org/abs/1903.01153) (ICAPS'18)
- [ ] [Learning Planning Operators from Episodic Traces](https://aaai.org/ocs/index.php/SSS/SSS18/paper/view/17594/15530) (AAAI-SS'18)
- [ ] [Learning action models with minimal observability](https://www.sciencedirect.com/science/article/abs/pii/S0004370218304259) (AIJ'19)
- [ ] [Learning Action Models from Disordered and Noisy Plan Traces](https://arxiv.org/abs/1908.09800) (arXiv'19)
- [x] [Learning Action Models from Disordered and Noisy Plan Traces](https://arxiv.org/abs/1908.09800) (arXiv'19)
- [ ] [Bridging the Gap: Providing Post-Hoc Symbolic Explanations for Sequential Decision-Making Problems with Black Box Simulators](https://arxiv.org/abs/2002.01080) (ICML-WS'20)
- [ ] [STRIPS Action Discovery](https://arxiv.org/abs/2001.11457) (arXiv'20)
- [ ] [Learning First-Order Symbolic Representations for Planning from the Structure of the State Space](https://arxiv.org/abs/1909.05546) (ECAI'20)
Expand Down
13 changes: 13 additions & 0 deletions docs/extract/amdn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Usage

```python
from macq import generate, extract

print(model.details())
```

**Output:**
```text
```

# API Documentation
77 changes: 77 additions & 0 deletions docs/extract/arms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Usage

```python
from macq import generate, extract
from macq.trace import PlanningObject, Fluent, TraceList
from macq.observation import PartialObservation

def get_fluent(name: str, objs: list[str]):
objects = [PlanningObject(o.split()[0], o.split()[1]) for o in objs]
return Fluent(name, objects)

traces = TraceList()
generator = generate.pddl.TraceFromGoal(problem_id=1801)

generator.change_goal(
{
get_fluent("communicated_soil_data", ["waypoint waypoint2"]),
get_fluent("communicated_rock_data", ["waypoint waypoint3"]),
get_fluent(
"communicated_image_data", ["objective objective1", "mode high_res"]
),
}
)
traces.append(generator.generate_trace())

generator.change_goal(
{
get_fluent("communicated_soil_data", ["waypoint waypoint2"]),
get_fluent("communicated_rock_data", ["waypoint waypoint3"]),
get_fluent(
"communicated_image_data", ["objective objective1", "mode high_res"]
),
}
)
traces.append(generator.generate_trace())

observations = traces.tokenize(PartialObservation, percent_missing=0.60)
model = extract.Extract(
observations,
extract.modes.ARMS,
upper_bound=2,
min_support=2,
action_weight=110,
info_weight=100,
threshold=0.6,
info3_default=30,
plan_default=30,
)

print(model.details())
```

**Output:**
```text
Model:
Fluents: (at rover rover0 waypoint waypoint2), (have_soil_analysis rover rover0 waypoint waypoint2), (have_soil_analysis rover rover0 waypoint waypoint3), ...
Actions:
(communicate_image_data rover waypoint mode objective lander waypoint):
precond:
calibrated camera rover
have_rock_analysis rover waypoint
communicated_rock_data waypoint
channel_free lander
at_soil_sample waypoint
at_rock_sample waypoint
add:
calibrated camera rover
at rover waypoint
have_image rover objective mode
channel_free lander
communicated_image_data objective mode
delete:
calibrated camera rover
...
```

# API Documentation
9 changes: 9 additions & 0 deletions docs/extract/extract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Usage

## Debugging
Include the argument `debug=True` to `Extract` to enable debugging for any
extraction technique.

*Note: debugging output and interfaces are unique to each method.*

# API Documentation
37 changes: 37 additions & 0 deletions docs/extract/observer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Usage

```python
from macq import generate, extract
from macq.observation import IdentityObservation

traces = generate.pddl.VanillaSampling(problem_id=123, plan_len=20, num_traces=100).traces
observations = traces.tokenize(IdentityObservation)
model = extract.Extract(observations, extract.modes.OBSERVER)

print(model.details())
```

**Output:**
```text
Model:
Fluents: at stone stone-03 location pos-04-06, at stone stone-01 location pos-04-06, at stone stone-02 location pos-05-06, at stone stone-06 location pos-07-04, at stone stone-11 ...
Actions:
push-to-goal stone stone-04 location pos-04-05 location pos-04-06 direction dir-up location pos-04-04 player player-01:
precond:
at player player-01 location pos-04-06
at stone stone-04 location pos-04-05
clear location pos-05-06
...
add:
at stone stone-04 location pos-04-04
clear location pos-04-06
at-goal stone stone-04
at player player-01 location pos-04-05
delete:
at stone stone-04 location pos-04-05
clear location pos-04-04
at player player-01 location pos-04-06
...
```

# API Documentation
28 changes: 28 additions & 0 deletions docs/extract/slaf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Usage

```python
from macq import generate, extract
from macq.observation import AtomicPartialObservation

traces = generate.pddl.VanillaSampling(problem_id=123, plan_len=2, num_traces=1).traces
observations = traces.tokenize(AtomicPartialObservation, percent_missing=0.10)
model = Extract(observations, extract.modes.SLAF)
print(model.details())
```

**Output:**
```text
Model:
Fluents: clear location pos-06-09, clear location pos-02-05, clear location pos-08-08, clear location pos-10-05, ...
Actions:
move player player-01 direction dir-left location pos-05-02 location pos-06-02:
precond:
add:
delete:
(clear location pos-05-02)
(at player player-01 location pos-06-02)
...
...
```

# API Documentation
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Usage Documentation

## Trace Generation
- [VanillaSampling](extract/observer/#usage)

## Tokenization
- [IdentityObservation](extract/observer#usage)
- [AtomicPartialObservation](extract/slaf#usage)

## Extraction Techniques
- [Observer](extract/observer#usage)
- [SLAF](extract/slaf#usage)
- [ARMS](extract/arms#usage)
- [AMDN](extract/amdn#usage)


# API Documentation
3 changes: 3 additions & 0 deletions macq/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
.. include:: ../docs/index.md
"""
13 changes: 7 additions & 6 deletions macq/extract/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from .model import Model
from .extract import Extract, modes, IncompatibleObservationToken, SLAF
from .learned_fluent import LearnedFluent
from .learned_action import LearnedAction
from .model import Model, LearnedAction
from .extract import Extract, modes
from .exceptions import IncompatibleObservationToken
from .model import Model

__all__ = [
"LearnedAction",
"LearnedFluent",
"Model",
"Extract",
"modes",
"IncompatibleObservationToken",
"LearnedAction",
"SLAF",
"LearnedFluent",
]
]
Loading