Skip to content

Commit

Permalink
Additional, project-wide conversion from four spaces to two spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
neonWhiteout committed Sep 28, 2023
1 parent a3ad45a commit dbf4419
Show file tree
Hide file tree
Showing 8 changed files with 1,526 additions and 1,526 deletions.
108 changes: 54 additions & 54 deletions src/CausalLoop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ add_edges!(c::AbstractCausalLoop,n,s,t;kw...) = add_parts!(c,:E,n,s=s,t=t;kw...)
Create causal loop diagram from collection of nodes and collection of edges.
"""
CausalLoop(ns,es) = begin
c = CausalLoop()
ns = vectorify(ns)
es = vectorify(es)
ns_idx=state_dict(ns)
add_nodes!(c, length(ns), nname=ns)

s=map(first,es)
t=map(last,es)
add_edges!(c, length(es), map(x->ns_idx[x], s), map(x->ns_idx[x], t))

c
c = CausalLoop()
ns = vectorify(ns)
es = vectorify(es)

ns_idx=state_dict(ns)
add_nodes!(c, length(ns), nname=ns)

s=map(first,es)
t=map(last,es)
add_edges!(c, length(es), map(x->ns_idx[x], s), map(x->ns_idx[x], t))

c
end

# return the count of each components
Expand All @@ -62,25 +62,25 @@ nnames(c::AbstractCausalLoop) = [nname(c, n) for n in 1:nn(c)]


function convertToCausalLoop(p::AbstractStockAndFlowStructure)
sns=snames(p)
fns=fnames(p)
svns=svnames(p)
flowVariableIndexs=[flowVariableIndex(p,f) for f in 1:nf(p)]
vNotf=setdiff(1:nvb(p),flowVariableIndexs)
vNotfns=[vname(p,v) for v in vNotf]
ns=vcat(sns,fns,svns,vNotfns)

lses=[sname(p,subpart(p,ls,:lss))=>svname(p,subpart(p,ls,:lssv)) for ls in 1:nls(p)]
lsvfes=[svname(p,subpart(p,lsv,:lsvsv))=>subpart(p,lsv,:lsvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lsv,:lsvv),:fv))) : vname(p,subpart(p,lsv,:lsvv)) for lsv in 1:nlsv(p)]
lfves=[sname(p,subpart(p,lv,:lvs))=>subpart(p,lv,:lvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvv),:fv))) : vname(p,subpart(p,lv,:lvv)) for lv in 1:nlv(p)]
fies=[fname(p,subpart(p,i,:ifn))=>sname(p,subpart(p,i,:is)) for i in 1:ni(p)]
foes=[fname(p,subpart(p,o,:ofn))=>sname(p,subpart(p,o,:os)) for o in 1:no(p)]

es=vcat(lses,lsvfes,lfves,fies,foes)

return CausalLoop(ns,es)

sns=snames(p)
fns=fnames(p)
svns=svnames(p)
flowVariableIndexs=[flowVariableIndex(p,f) for f in 1:nf(p)]
vNotf=setdiff(1:nvb(p),flowVariableIndexs)
vNotfns=[vname(p,v) for v in vNotf]

ns=vcat(sns,fns,svns,vNotfns)

lses=[sname(p,subpart(p,ls,:lss))=>svname(p,subpart(p,ls,:lssv)) for ls in 1:nls(p)]
lsvfes=[svname(p,subpart(p,lsv,:lsvsv))=>subpart(p,lsv,:lsvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lsv,:lsvv),:fv))) : vname(p,subpart(p,lsv,:lsvv)) for lsv in 1:nlsv(p)]
lfves=[sname(p,subpart(p,lv,:lvs))=>subpart(p,lv,:lvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvv),:fv))) : vname(p,subpart(p,lv,:lvv)) for lv in 1:nlv(p)]
fies=[fname(p,subpart(p,i,:ifn))=>sname(p,subpart(p,i,:is)) for i in 1:ni(p)]
foes=[fname(p,subpart(p,o,:ofn))=>sname(p,subpart(p,o,:os)) for o in 1:no(p)]

es=vcat(lses,lsvfes,lfves,fies,foes)

return CausalLoop(ns,es)
end

"""
Expand All @@ -89,27 +89,27 @@ Nodes: stocks, flows, sum variables, parameters, nonflow dynamic variables
Edges: morphisms in stock flow
"""
function convertToCausalLoop(p::AbstractStockAndFlowStructureF)
sns=snames(p)
fns=fnames(p)
svns=svnames(p)
pns=pnames(p)
flowVariableIndexs=[flowVariableIndex(p,f) for f in 1:nf(p)]
vNotf=setdiff(1:nvb(p),flowVariableIndexs)
vNotfns=[vname(p,v) for v in vNotf]
ns=vcat(sns,fns,svns,vNotfns,pns)

lses=[sname(p,subpart(p,ls,:lss))=>svname(p,subpart(p,ls,:lssv)) for ls in 1:nls(p)]
lsvfes=[svname(p,subpart(p,lsv,:lsvsv))=>subpart(p,lsv,:lsvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lsv,:lsvv),:fv))) : vname(p,subpart(p,lsv,:lsvv)) for lsv in 1:nlsv(p)]
lfves=[sname(p,subpart(p,lv,:lvs))=>subpart(p,lv,:lvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvv),:fv))) : vname(p,subpart(p,lv,:lvv)) for lv in 1:nlv(p)]
fies=[fname(p,subpart(p,i,:ifn))=>sname(p,subpart(p,i,:is)) for i in 1:ni(p)]
foes=[fname(p,subpart(p,o,:ofn))=>sname(p,subpart(p,o,:os)) for o in 1:no(p)]
lpvs=[pname(p,subpart(p,lp,:lpvp))=>subpart(p,lp,:lpvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lp,:lpvv),:fv))) : vname(p,subpart(p,lp,:lpvv)) for lp in 1:nlpv(p)]
lvvs=[subpart(p,lv,:lvsrc) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvsrc),:fv))) : vname(p,subpart(p,lv,:lvsrc))=>subpart(p,lv,:lvtgt) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvtgt),:fv))) : vname(p,subpart(p,lv,:lvtgt)) for lv in 1:nlvv(p)]


es=vcat(lses,lsvfes,lfves,fies,foes,lpvs,lvvs)

return CausalLoop(ns,es)

sns=snames(p)
fns=fnames(p)
svns=svnames(p)
pns=pnames(p)
flowVariableIndexs=[flowVariableIndex(p,f) for f in 1:nf(p)]
vNotf=setdiff(1:nvb(p),flowVariableIndexs)
vNotfns=[vname(p,v) for v in vNotf]

ns=vcat(sns,fns,svns,vNotfns,pns)

lses=[sname(p,subpart(p,ls,:lss))=>svname(p,subpart(p,ls,:lssv)) for ls in 1:nls(p)]
lsvfes=[svname(p,subpart(p,lsv,:lsvsv))=>subpart(p,lsv,:lsvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lsv,:lsvv),:fv))) : vname(p,subpart(p,lsv,:lsvv)) for lsv in 1:nlsv(p)]
lfves=[sname(p,subpart(p,lv,:lvs))=>subpart(p,lv,:lvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvv),:fv))) : vname(p,subpart(p,lv,:lvv)) for lv in 1:nlv(p)]
fies=[fname(p,subpart(p,i,:ifn))=>sname(p,subpart(p,i,:is)) for i in 1:ni(p)]
foes=[fname(p,subpart(p,o,:ofn))=>sname(p,subpart(p,o,:os)) for o in 1:no(p)]
lpvs=[pname(p,subpart(p,lp,:lpvp))=>subpart(p,lp,:lpvv) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lp,:lpvv),:fv))) : vname(p,subpart(p,lp,:lpvv)) for lp in 1:nlpv(p)]
lvvs=[subpart(p,lv,:lvsrc) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvsrc),:fv))) : vname(p,subpart(p,lv,:lvsrc))=>subpart(p,lv,:lvtgt) in flowVariableIndexs ? fname(p,only(incident(p,subpart(p,lv,:lvtgt),:fv))) : vname(p,subpart(p,lv,:lvtgt)) for lv in 1:nlvv(p)]


es=vcat(lses,lsvfes,lfves,fies,foes,lpvs,lvvs)

return CausalLoop(ns,es)
end
Loading

0 comments on commit dbf4419

Please sign in to comment.