-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from probcomp/20190203-marcoct-names
20190203 marcoct names
- Loading branch information
Showing
111 changed files
with
3,273 additions
and
4,046 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 19 additions & 19 deletions
38
docs/src/ref/assignments.md → docs/src/ref/choice_maps.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
# Assignments | ||
# Choice Maps | ||
|
||
Maps from the addresses of random choices to their values are stored in associative tree-structured data structures that have the following abstract type: | ||
```@docs | ||
Assignment | ||
ChoiceMap | ||
``` | ||
|
||
Assignments are constructed by users to express observations and/or constraints on the traces of generative functions. | ||
Assignments are also returned by certain Gen inference methods, and are used internally by various Gen inference methods. | ||
Choice maps are constructed by users to express observations and/or constraints on the traces of generative functions. | ||
Choice maps are also returned by certain Gen inference methods, and are used internally by various Gen inference methods. | ||
|
||
Assignments provide the following methods: | ||
Choice maps provide the following methods: | ||
```@docs | ||
has_value | ||
get_value | ||
get_subassmt | ||
get_submap | ||
get_values_shallow | ||
get_subassmts_shallow | ||
get_submaps_shallow | ||
to_array | ||
from_array | ||
address_set | ||
``` | ||
Note that none of these methods mutate the assignment. | ||
|
||
Assignments also provide `Base.isempty`, which tests of there are no random | ||
Choice maps also provide `Base.isempty`, which tests of there are no random | ||
choices in the assignment, and `Base.merge`, which takes two assignments, and | ||
returns a new assignment containing all random choices in either assignment. | ||
It is an error if the assignments both have values at the same address, or if | ||
one assignment has a value at an address that is the prefix of the address of a | ||
value in the other assignment. | ||
|
||
|
||
## Dynamic Assignment | ||
## Dynamic Choice Map | ||
|
||
One concrete assignment type is `DynamicAssignment`, which is mutable. | ||
Users construct `DynamicAssignments` and populate them for use as observations or constraints, e.g.: | ||
One concrete assignment type is `DynamicChoiceMap`, which is mutable. | ||
Users construct `DynamicChoiceMaps` and populate them for use as observations or constraints, e.g.: | ||
```julia | ||
assmt = DynamicAssignment() | ||
assmt[:x] = true | ||
assmt["foo"] = 1.25 | ||
assmt[:y => 1 => :z] = -6.3 | ||
choices = choicemap() | ||
choices[:x] = true | ||
choices["foo"] = 1.25 | ||
choices[:y => 1 => :z] = -6.3 | ||
``` | ||
|
||
There is also a constructor for `DynamicAssignment` that takes initial (address, value) pairs: | ||
There is also a constructor for `DynamicChoiceMap` that takes initial (address, value) pairs: | ||
```julia | ||
assmt = DynamicAssignment((:x, true), ("foo", 1.25), (:y => 1 => :z, -6.3)) | ||
choices = choicemap((:x, true), ("foo", 1.25), (:y => 1 => :z, -6.3)) | ||
``` | ||
|
||
```@docs | ||
DynamicAssignment | ||
choicemap | ||
set_value! | ||
set_subassmt! | ||
set_submap! | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.