-
Notifications
You must be signed in to change notification settings - Fork 6
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
Nstratify good #87
Merged
Xiaoyan-Li
merged 24 commits into
AlgebraicJulia:master
from
neonWhiteout:nstratify_good
Sep 27, 2023
Merged
Nstratify good #87
Xiaoyan-Li
merged 24 commits into
AlgebraicJulia:master
from
neonWhiteout:nstratify_good
Sep 27, 2023
Conversation
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
…ssv, etc to StockFlow.jl, several methods to Syntax.jl (incl infer_links, which is now exported), and a Stratification.jl file. Also created a Stratification tests file and added more tests to Syntax.
…v, etc. getter methods
…ch are unmapped. Was previously two separate loops.
…ssary variables. Additional type annotations.
… and replaced a few sfstratify calls in the test file with the macro call.
… end block. Minor docstring updates.
…ant information. Contains dictionaries and vectors which are updated as it goes along. Created macro n_stratify, which generalizes stratify and can take an arbitrary number of stockflows as arguments. Still needs tests. Updated tests to reflect changes in stratification functions.
… System Structure so instead of folding right, it checks all vops are equal (line 195)
removed testing code
neonWhiteout
force-pushed
the
nstratify_good
branch
from
September 6, 2023 19:44
20dbeb5
to
8c0fc74
Compare
…ally make sense to take the pullback of 0 items so removed that as an option. Now allow single symbols to be interpreted as a tuple with one element, so n_stratify is far less cumbersome to write for.
age_weight_6 = @n_stratify WeightModel ageWeightModel l_type begin
:flows
[~Death, ~Death] => f_death
[~id, ~aging] => f_aging
[~Becoming, ~id] => f_fstOrder
[_, f_NB] => f_birth
:dynamic_variables
[v_NewBorn, v_NB] => v_birth
[~Death, ~Death] => v_death
[~id, (v_agingCA, v_agingAS)] => v_aging
[(v_BecomingOverWeight, v_BecomingObese), (v_idC, v_idA, v_idS)] => v_fstOrder
:parameters
[μ, μ] => μ
[(δw, δo), (δC, δA, δS)] => δ
[(rw, ro), r] => rFstOrder
[rage, (rageCA, rageAS)] => rage
end is equivalent to age_weight_3 = @stratify WeightModel l_type ageWeightModel begin
:flows
f_NewBorn => f_birth <= f_NB
~Death => f_death <= ~Death
~id => f_aging <= ~aging
~Becoming => f_fstOrder <= ~id
:dynamic_variables
v_NewBorn => v_birth <= v_NB
~Death => v_death <= ~Death
~id => v_aging <= ~aging
~Becoming => v_fstOrder <= ~id
:parameters
μ => μ <= μ
~δ => δ <= ~δ
rage => rage <= rageCA, rageAS
_ => rFstOrder <= _
end is equivalent to l_type_noatts = map(l_type, Name=NothingFunction, Op=NothingFunction, Position=NothingFunction);
begin
s, = parts(l_type, :S)
N, = parts(l_type, :SV)
lsn, = parts(l_type, :LS)
f_aging, f_fstorder, f_birth, f_death = parts(l_type, :F)
i_aging, i_fstorder, i_birth = parts(l_type, :I)
o_aging, o_fstorder, o_death = parts(l_type, :O)
v_aging, v_fstorder, v_birth, v_death = parts(l_type, :V)
lv_aging1, lv_fstorder1, lv_death1 = parts(l_type, :LV)
lsv_birth1, = parts(l_type, :LSV)
p_μ, p_δ, p_rfstOrder, p_rage = parts(l_type, :P)
lpv_aging2, lpv_fstorder2, lpv_birth2, lpv_death2 = parts(l_type, :LPV)
end;
typed_WeightModel=ACSetTransformation(WeightModel, l_type_noatts,
S = [s,s,s],
SV = [N],
LS = [lsn,lsn,lsn],
F = [f_birth, f_death, f_fstorder, f_death, f_fstorder, f_death, f_aging, f_aging, f_aging],
I = [i_birth, i_aging, i_fstorder, i_aging, i_fstorder, i_aging],
O = [o_death, o_fstorder, o_aging, o_death, o_fstorder, o_aging, o_death, o_aging],
V = [v_birth, v_death, v_fstorder, v_death, v_fstorder, v_death, v_aging, v_aging, v_aging],
LV = [lv_death1, lv_fstorder1, lv_death1, lv_fstorder1, lv_death1, lv_aging1, lv_aging1, lv_aging1],
LSV = [lsv_birth1],
P = [p_μ, p_δ, p_rfstOrder, p_rfstOrder, p_δ, p_rage],
LPV = [lpv_birth2, lpv_death2, lpv_fstorder2, lpv_death2, lpv_fstorder2, lpv_death2, lpv_aging2, lpv_aging2, lpv_aging2],
Name=NothingFunction, Op=NothingFunction, Position=NothingFunction
);
@assert is_natural(typed_WeightModel);
typed_ageWeightModel=ACSetTransformation(ageWeightModel, l_type_noatts,
S = [s,s,s],
SV = [N],
LS = [lsn,lsn,lsn],
F = [f_birth, f_fstorder, f_death, f_aging, f_fstorder, f_death, f_aging, f_fstorder, f_death],
I = [i_birth, i_fstorder, i_aging, i_fstorder, i_aging, i_fstorder],
O = [o_fstorder, o_death, o_aging, o_fstorder, o_death, o_aging, o_fstorder, o_death],
V = [v_birth, v_death, v_fstorder, v_aging, v_death, v_fstorder, v_aging, v_death, v_fstorder],
LV = [lv_death1, lv_fstorder1, lv_aging1, lv_death1, lv_fstorder1, lv_aging1, lv_death1, lv_fstorder1],
LSV = [lsv_birth1],
P = [p_μ, p_δ, p_δ, p_δ, p_rage, p_rage, p_rfstOrder],
LPV = [lpv_birth2, lpv_death2, lpv_fstorder2, lpv_aging2, lpv_death2, lpv_fstorder2, lpv_aging2, lpv_death2, lpv_fstorder2],
Name =NothingFunction, Op=NothingFunction, Position=NothingFunction
);
@assert is_natural(typed_ageWeightModel);
aged_weight = pullback(typed_WeightModel, typed_ageWeightModel) |> apex |> rebuildStratifiedModelByFlattenSymbols; |
I think I'm going to try holding off on any further edits on this until I hear from @Xiaoyan-Li |
Passes test on my computer, if it passes here should be able to merge. |
ok @Xiaoyan-Li the remaining tests are the notebooks which shouldn't have been modified so hopefully it's good at this point |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't like this syntax, but it works, and it's really easy to deal with.
Anyways, still need to write a lot of tests, but both normal stratification and stratification of arbitrary length seems to work.