-
Notifications
You must be signed in to change notification settings - Fork 46
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
HypergraphSubstitutionSystem #643
base: master
Are you sure you want to change the base?
Conversation
…ubstitutionSystem
…etween HypergraphSubstitutionSystem and WolframModelEvolutionObject.
…tead of setSubstitutionSystem$cpp (1/?).
…ubstitutionSystem
…ubstitutionSystem
…onSystem; Saving "GlobalAtoms" instead of "GlobalAtomsIndexMap" in the multihistory object.
…ypergraphSubstitutionSystem[...], ...]; Renaming "EventOrderingFunction".
…ng in setSubstitutionSystem.m to avoid message clashing with the new type system message.
…ng All as one of the default deduplication choices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look through all of it yet (as far as I understand it's not completely done yet), but I left a few large-scale comments. We might also need to discuss the whole interaction between match-all/deduplication/event sets in more detail at some point.
Reviewable status: 0 of 19 files reviewed, 4 unresolved discussions (waiting on @daneelsan)
Documentation/Types/Multihistory/HypergraphSubstitutionSystem0.md, line 8 at r4 (raw file):
```wl In[] := multi = GenerateMultihistory[HypergraphSubstitutionSystem[{{a_, b_}, {a_, c_}} :> {{b, c}}],
Why does it take multiset system rules? Shouldn't it take {{1, 2}, {1, 3}} -> {{2, 3}}
since it cannot take anything more general? There is a special case of explicit vertices, but I think it will be better handled with something like {{1, Global[2]}, {1, 3}} -> {{Global[2], 3}}
, meaning, {{a_, 2}, {a_, b_}} :> {{2, b}}
.
Documentation/Types/Multihistory/HypergraphSubstitutionSystem0.md, line 17 at r4 (raw file):
<img src="/Documentation/Images/HypergraphMultihistory.png" width="607.8"> It uses the hypergraph related C++ code found in the [libSetReplace](/libSetReplace/), same as what **WolframModel**
I think if we are going to refer to WolframModel
, it would be best to do it in the past tense or otherwise make it clear that it is not deprecated (otherwise, it's not clear why we have both).
Documentation/Types/Multihistory/HypergraphSubstitutionSystem0.md, line 25 at r4 (raw file):
hypergraph object is kept inside (see [Managed Library Expressions](https://reference.wolfram.com/language/LibraryLink/tutorial/InteractionWithWolframLanguage#353220453)):
It might be useful to discuss the implications of this (such as that it won't work with parallel kernels and cannot be stored in a notebook).
Kernel/HypergraphSubstitutionSystem.m, line 229 at r4 (raw file):
<|"MaxGeneration" -> {Infinity, "NonNegativeIntegerOrInfinity"}, "MaxDestroyerEvents" -> {Infinity, "NonNegativeIntegerOrInfinity"}, "EventSeparation" -> {"Spacelike", {"Spacelike", "Any"}}|>,
Nice! That's probably a better place to put it than anything I came up with before. Arguably, GenerateFullEventSet
should set this to "Any"
automatically, and MultisetSubstitutionSystem
should support the case where "EventSeparation"
is "Spacelike"
, but token deduplication is All
.
## Changes * This is a complete rewrite of the generator system. * Old `GenerateMultihistory` syntax is removed. * Instead, all generators have the format ```wl Generator[System[rules], param1 -> value1, ...] @ init ``` Note that `param1`, etc. are symbols rather than strings. They have usage messages, etc. Also, one can use lists or associations instead, e.g., ```wl Generator[System[rules], {param1 -> value1}, <|param2 -> value2|>, param3 -> value3] @ init ``` * Parameters are now declared separately from systems and generators. * Systems need to declare a logical expression specifying which parameters can be specified. For example, ```wl Implies[MaxEvents || MaxDestroyerEvents, EventOrder] ``` means that `EventOrder` needs to be specified if either `MaxEvents` or `MaxDestroyerEvents` are specified. * Generators have predefined values for some parameters. E.g., `GenerateSingleHistory` sets `MaxDestroyerEvents -> 1`, which can no longer be changed. ## Comments * Apologies for a huge PR. There is a lot of refactoring here as all instances of `GenerateMultihistory` had to be changed. * Ordering functions page is deleted for now but should return as a page for the `EventOrder` parameter once it is used somewhere. * @daneelsan, unfortunately, it will break #643, but on the flip side, it should make it a lot easier to define parameters (as one does not need to think where to put them anymore). ## Examples * `GenerateSingleHistory`: ```wl In[] := #["StatesList"] & @ SetReplaceTypeConvert[{WolframModelEvolutionObject, 2}] @ GenerateSingleHistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxEvents -> 4] @ {1, 2, 3} Out[] = {{1, 2, 3}, {3, 3}, {6}} ``` * `GenerateAllHistories`: ```wl In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ SetReplaceTypeConvert[{WolframModelEvolutionObject, 2}] @ GenerateMultihistory[ MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}], MaxGeneration -> 2] @ Range[3] ``` <img width="399" alt="image" src="https://user-images.githubusercontent.com/1479325/122285946-f08ade80-ceb4-11eb-882d-7da3fdeb75fb.png">
Changes
HypergraphSubstitutionSystem
, which uses the existing low-level Hypergraph-related code to compute the evolution of hypergraphs.GenerateMultihistory
generates aMultihistory
object that contains a handle to the C++ instance, instead of an association representing the entire state of the "finished" object. This will allow us, in the future, to continue the evolution of multistory objects (see Support WolframModelEvolutionObject as an argument for WolframModel #436).SetReplace*
andWolframModel
symbols now callGenerateMultihistory[HypergraphSubstitutionSystem[...], ...]
, and covert the resultingmultihistory
object to a{WolframModelEvolutionObject, 2}
.Comments
Tests
Documentation
Examples
This change is