Skip to content

Commit c3c9bc8

Browse files
authored
Merge pull request #613 from BlockScience/0.4.0
V0.4.0
2 parents 38a3098 + eb5a381 commit c3c9bc8

File tree

10 files changed

+523
-45
lines changed

10 files changed

+523
-45
lines changed

dev/Issue Matrix.ipynb

Lines changed: 27 additions & 32 deletions
Large diffs are not rendered by default.

docs/CanonicalExamples.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ As part of MSML, there are multiple canonical examples which are meant to showca
1212
| Feature/Attribute | [MSML Template](https://github.com/BlockScience/MSML-Template) | [Predator Prey](https://github.com/BlockScience/Predator-Prey-MSML) | [Root Finding](https://github.com/SeanMcOwen/Root-Finding-Simulation) | [Retirement Planning](https://github.com/BlockScience/Retirement-Planning-MSML) |
1313
| --- | --- | --- | --- | --- |
1414
| Description | A template for using MSML. It implements very basic functionality. | An example of building out an agent based simulation for modeling predators and prey based on multiple actions. | A simulation of different root finding techniques and their relative speed/accuracy | A canonical example to showcase how to simulate changing behavioral patterns and their impacts on final results|
15+
| Complexity (1-5) | 1 | 4 | 3 | 2 |
1516
| Spec Implementation Complete? | X | X | WIP | WIP |
1617
| Code Implementations Complete? | X | X | | WIP |
1718
| Simulations/Experiments Complete? | X | WIP| | |

docs/GettingStarted.md

Lines changed: 366 additions & 1 deletion
Large diffs are not rendered by default.

docs/index.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ Writing mathematical specifications can be a difficult process, especially when
3737
## How does MSML work?
3838

3939

40-
```mermaid
41-
graph TD
42-
A[JSON Object \n\n Each spec has a repo for tracking changes \n Must conform to the json specification \n Defines all aspects of the spec including blocks, spaces and actions] -->B[MSML Object \n\n JSON file is parsed, with validations and mappings along the way \n Can show different views on the fly]
43-
B --> C[Report Outputs & Obsidian Directory \n\n Automatically build reports for the full spec or subviews \n Example: all blocks with an effect on variable XYZ\n Also builds an entire Obsidian directory of all components as linked notes]
44-
D[Python Function Implementations \n\n Optional enhancement to actually execute code\n Done for each referenced policy option, mechanism, etc. \n Just needs a function definition for each] --> B
45-
B --> E[Python Wirings & Simulations \n\n MSML can be used to run blocks \n Wirings automatically work to pass between domain/codomains \n Entire simulations can be built up as composed wirings]
46-
```
40+
![mermaid](mermaid.png)
4741

4842
## MSML in the Engineering Lifecycle
4943

docs/mermaid.png

767 KB
Loading

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
44
[project]
55
name = "math-spec-mapping"
6-
version = "0.3.21"
6+
version = "0.4.0"
77
authors = [
88
{ name="Sean McOwen", email="[email protected]" },
99
]

research_notes/2025-01-07 V0.5 Plan.md

Lines changed: 47 additions & 0 deletions
Large diffs are not rendered by default.

research_notes/WIP V0.4 Update.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,83 @@
1-
# MSML v0.3 Update
1+
# MSML v0.4 Update
22

3-
Updated through V0.3.6
3+
Updated through V0.3.14
44

55
## MSML Review
66

77
MSML is a library for standardizing the creation of mathematical specifications as JSON objects as well as aiding in the automation of report and visualization creation from these standardized JSON. Please see the [README](../README.md) for more information.
88

99
## Updates from to v0.3.0 to V0.4.0
1010

11-
A total of XX issues were closed out over the development cycle, which broadly fall into the following categories:
11+
A total of XX issues were closed out over the development cycle, which broadly fall into the following categories below. However, for brevity, only the main updates will be covered, many smaller updates such as bug fixes, small improvements, etc. will not be noted here but can be found in the research journal.
1212

1313
### Implementations / Executable Code Blocks
1414

1515
- Boundary actions are now added in as an implementation
1616
- Full wiring runs are now working/executing
1717
- New functionality for validation of state and params before running wiring or blocks
1818
- Stateful metrics were implemented and now are passed in as a module in the state that implementations can access and use
19+
- State and parameter preparation function paradigms were added into MSML to allow for setting up parameters and state prior to simulations / executable codes
20+
- Metrics were added into implementations to allow for mapping code to them
21+
- Functionality was added in for linking source code to the blocks for easy viewing and writing into markdown reports; as well a source code printing function was added
22+
- An enhanced version of the components running was created which acts as a wrapper around executable code and checks things like the actual spaces match even when doing the code execution side
1923

2024
### Metaprogramming
2125

2226
- Initial R&D into metaprogramming for Julia has yielded some success on metaprogramming for spaces and types in cadCAD.jl from MSML
2327
- Boundary action metaprogramming has been started
2428

29+
### Simulations
30+
31+
- The mini-simulation runner was created
32+
- Post-processing function paradigm was added into the mini-simulation runner
33+
- Metric functions were added to the runner for post processing of data
34+
- Ability to run lists of blocks built out
35+
- Mapping of parameter changes to columns for experiments was added in
36+
2537
### Canonical Examples
2638

39+
- The MSML template was added as both a canonical example as well as a forkable template for getting started quickly with MSML
40+
- The predator prey canonical example was created and has been completed up to simulations
2741
- Introduction of the retirement planning canonical example as a guided walk through example
2842
- Introduction of the Rideshare Modeling canonical example for building a massive end-to-end model of a rideshare simulation
29-
- Big improvements to the starter repo including adding in executable code blocks and better naming
43+
- Big improvements to the starter repo including adding in executable code blocks and better naming, which was later rolled into the MSML template
3044

3145
## Research Notes
3246

3347
- A research note on metrics was created and worked through with stakeholders
3448
- A research note on parameter class names and different ways that it could be implemented (plan is for a "bring your own ontology" approach moving forward)
3549
- Development note on working through an issue with Latex escape characters
3650
- Development research note for future proposals of changes to MSML
51+
- Predator-Prey-Ideation through reverse engineering research note
52+
- Multi-processing research note for aiding with cadCAD performance (and eventual dogfooding on MSML)
53+
- V0.5 release plan was created
54+
- V0.4 update note was created
3755

3856
## Improvements and Convenience Functions
3957

4058
- A lot of bugs were discovered and fixed through dogfooding on client work and canonical examples
4159
- Some major improvements across the board in terms of quality of life stuff; a lot of new assertions that are more descriptive added to easily see where the issues are
4260
- New convenience functions such as one to remove dummy repo components after the starter repo scaffolding is no longer needed
61+
- A parameter table creation function was built which automatically creates a markdown table of parameters, descriptions, and default values for experiment notebooks
62+
- Improvements of assertions
63+
- An automatic README writer was added in
64+
- A functionality that automatically writes issues from an MSML scaffold into a github issues was built out
65+
- Large amount of small updates to the reporting sections
66+
- Functionality was added which puts the actual bound code into the markdown reports and also adds links to both the definitions of code as well as the spec component definitions for making it easier to develop
67+
- Depth of 1 mermaid wiring charts were created to make it cleaner to look at different wirings
68+
- The nodes in mermaid graphics are now clickable and bring you to the Obsidian note for that component
69+
- Automated github table creation functionality for project management improvement
70+
- Full issue inventory and tagging of all 200 issues within the MSML repository
71+
- The remove starter repo functionality was refactored for the new MSML template
72+
- The official [MSML documentation](https://blockscience.github.io/MSML/) has been launched
73+
- A getting started guide was built
74+
75+
## Presentations
76+
77+
- The annual presentation was given in June 2024 during the town hall
78+
- A governance pod presentation titled "Obsidian, the Mathematical Specification Mapping Library, and End-to-End Modeling" was given
79+
- October seminar presentation
80+
- A research note on Predator-Prey-Ideation through reverse engineering was completed which shows how to turn legacy code into an MSML scaffold then automatically port it into github issues for easy organization of the next step (the actual MSML spec), presented in seminar
4381

4482
## Future Research Arc
4583

src/math_spec_mapping/Classes/MathSpec.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,13 @@ def run_experiments(
727727
state_preperation_functions=None,
728728
parameter_preperation_functions=None,
729729
metrics_functions=None,
730+
append_param_change_columns=False,
730731
):
731732
state_l = []
732733
params_l = []
733734
df_l = []
734735
metrics_l = []
736+
param_mods = set()
735737
for experiment in experiments:
736738
for i in range(experiment["Monte Carlo Runs"]):
737739
state, params, msi, df, metrics = self.run_experiment(
@@ -743,6 +745,11 @@ def run_experiments(
743745
parameter_preperation_functions=parameter_preperation_functions,
744746
metrics_functions=metrics_functions,
745747
)
748+
if append_param_change_columns:
749+
if experiment["Param Modifications"]:
750+
for key in experiment["Param Modifications"]:
751+
df[key] = experiment["Param Modifications"][key]
752+
param_mods.add(key)
746753
df["Monte Carlo Run"] = i + 1
747754
df["Experiment"] = experiment["Name"]
748755
metrics.loc["Monte Carlo Run"] = i + 1
@@ -753,6 +760,9 @@ def run_experiments(
753760
df_l.append(df)
754761
metrics_l.append(metrics)
755762
df = pd.concat(df_l)
763+
if append_param_change_columns:
764+
for key in param_mods:
765+
df[key] = df[key].fillna(params_base[key])
756766
metrics = pd.concat(metrics_l, axis=1).T
757767
return df, metrics, state_l, params_l
758768

@@ -1022,6 +1032,12 @@ def load_control_actions(self):
10221032
), "No functional parameterization for {}. To fix this error, add {} to the parameters passed to ms.build_implementation. Option can be: {}".format(
10231033
ca.name, "FP " + ca.name, [x.name for x in opts]
10241034
)
1035+
assert (
1036+
self.params["FP {}".format(ca.name)]
1037+
in self.ms.functional_parameters["FP {}".format(ca.name)]
1038+
), "{} is not a valid functional parameterization for {}".format(
1039+
self.params["FP {}".format(ca.name)], ca.name
1040+
)
10251041
opt = self.ms.functional_parameters["FP {}".format(ca.name)][
10261042
self.params["FP {}".format(ca.name)]
10271043
]
@@ -1061,6 +1077,13 @@ def load_boundary_actions(self):
10611077
ba.name, "FP " + ba.name, [x.name for x in opts]
10621078
)
10631079

1080+
assert (
1081+
self.params["FP {}".format(ba.name)]
1082+
in self.ms.functional_parameters["FP {}".format(ba.name)]
1083+
), "{} is not a valid functional parameterization for {}".format(
1084+
self.params["FP {}".format(ba.name)], ba.name
1085+
)
1086+
10641087
opt = self.ms.functional_parameters["FP {}".format(ba.name)][
10651088
self.params["FP {}".format(ba.name)]
10661089
]
@@ -1165,6 +1188,12 @@ def load_policies(self):
11651188
), "No functional parameterization for {}. To fix this error, add {} to the parameters passed to ms.build_implementation. Option can be: {}".format(
11661189
p.name, "FP " + p.name, [x.name for x in opts]
11671190
)
1191+
assert (
1192+
self.params["FP {}".format(p.name)]
1193+
in self.ms.functional_parameters["FP {}".format(p.name)]
1194+
), "{} is not a valid functional parameterization for {}".format(
1195+
self.params["FP {}".format(p.name)], p.name
1196+
)
11681197
opt = self.ms.functional_parameters["FP {}".format(p.name)][
11691198
self.params["FP {}".format(p.name)]
11701199
]

src/math_spec_mapping/Convenience/github.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ def create_milestone_label_matrix(df, exclude_milestones=None):
9292
labels = list(df.columns[4:])
9393
labels = sorted([x for x in labels if x not in priority_labels])
9494
milestones = sorted(list(df[~pd.isnull(df["Milestone"])]["Milestone"].unique()))
95+
try:
96+
milestones = sorted(
97+
milestones,
98+
key=lambda x: int(x.split(".")[0][1:]) * 10000
99+
+ int(x.split(".")[1]) * 100
100+
+ int(x.split(".")[2]),
101+
)
102+
except:
103+
pass
95104

96105
table = []
97106
for label in labels:

0 commit comments

Comments
 (0)