Skip to content
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

SelectedUnknown -> SelectedState #2494

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/structural_transformation/partial_state_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function pss_graph_modia!(structure::SystemStructure, maximal_top_matching, varl
# Find Strongly connected components. Note that after pantelides, we expect
# a balanced system, so a maximal matching should be possible.
var_sccs::Vector{Union{Vector{Int}, Int}} = find_var_sccs(graph, maximal_top_matching)
var_eq_matching = Matching{Union{Unassigned, SelectedUnknown}}(ndsts(graph))
var_eq_matching = Matching{Union{Unassigned, SelectedState}}(ndsts(graph))
for vars in var_sccs
# TODO: We should have a way to not have the scc code look at unassigned vars.
if length(vars) == 1 && maximal_top_matching[vars[1]] === unassigned
Expand Down Expand Up @@ -72,7 +72,7 @@ function pss_graph_modia!(structure::SystemStructure, maximal_top_matching, varl
removed_vars = Int[]
for var in old_level_vars
old_assign = var_eq_matching[var]
if isa(old_assign, SelectedUnknown)
if isa(old_assign, SelectedState)
push!(removed_vars, var)
continue
elseif !isa(old_assign, Int) ||
Expand Down Expand Up @@ -114,7 +114,7 @@ function pss_graph_modia!(structure::SystemStructure, maximal_top_matching, varl
for var in remaining_vars
if nlsolve_matching[var] === unassigned &&
var_eq_matching[var] === unassigned
var_eq_matching[var] = SelectedUnknown()
var_eq_matching[var] = SelectedState()
end
end
end
Expand All @@ -127,7 +127,7 @@ function pss_graph_modia!(structure::SystemStructure, maximal_top_matching, varl
return complete(var_eq_matching, nsrcs(graph))
end

struct SelectedUnknown end
struct SelectedState end
function partial_state_selection_graph!(structure::SystemStructure, var_eq_matching)
@unpack eq_to_diff, var_to_diff, graph, solvable_graph = structure
eq_to_diff = complete(eq_to_diff)
Expand Down Expand Up @@ -349,13 +349,13 @@ function tearing_with_dummy_derivatives(structure, dummy_derivatives)
end
var_eq_matching, full_var_eq_matching, var_sccs = tear_graph_modia(structure,
Base.Fix1(isdiffed, (structure, dummy_derivatives)),
Union{Unassigned, SelectedUnknown};
Union{Unassigned, SelectedState};
varfilter = Base.Fix1(getindex, can_eliminate))
for v in eachindex(var_eq_matching)
is_present(structure, v) || continue
dv = var_to_diff[v]
(dv === nothing || !is_some_diff(structure, dummy_derivatives, dv)) && continue
var_eq_matching[v] = SelectedUnknown()
var_eq_matching[v] = SelectedState()
end
return var_eq_matching, full_var_eq_matching, var_sccs, can_eliminate
end
12 changes: 6 additions & 6 deletions src/structural_transformation/symbolics_tearing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function substitution_graph(graph, slist, dlist, var_eq_matching)

newmatching = Matching(ns)
for (v, e) in enumerate(var_eq_matching)
(e === unassigned || e === SelectedUnknown()) && continue
(e === unassigned || e === SelectedState()) && continue
iv = vrename[v]
ie = erename[e]
iv == 0 && continue
Expand Down Expand Up @@ -228,7 +228,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching;
# A general DAE is in the form of `F(u'(t), u(t), p, t) == 0`. We can
# characterize variables in `u(t)` into two classes: differential variables
# (denoted `v(t)`) and algebraic variables (denoted `z(t)`). Differential
# variables are marked as `SelectedUnknown` and they are differentiated in the
# variables are marked as `SelectedState` and they are differentiated in the
# DAE system, i.e. `v'(t)` are all the variables in `u'(t)` that actually
# appear in the system. Algebraic variables are variables that are not
# differential variables.
Expand All @@ -255,7 +255,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching;
for var in 1:length(fullvars)
dv = var_to_diff[var]
dv === nothing && continue
if var_eq_matching[var] !== SelectedUnknown()
if var_eq_matching[var] !== SelectedState()
dd = fullvars[dv]
v_t = setio(diff2term(unwrap(dd)), false, false)
for eq in 𝑑neighbors(graph, dv)
Expand Down Expand Up @@ -283,7 +283,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching;
end
end

# `SelectedUnknown` information is no longer needed past here. State selection
# `SelectedState` information is no longer needed past here. State selection
# is done. All non-differentiated variables are algebraic variables, and all
# variables that appear differentiated are differential variables.

Expand Down Expand Up @@ -569,10 +569,10 @@ function tearing(state::TearingState; kwargs...)
var_eq_matching′, = tear_graph_modia(state.structure;
varfilter = var -> var in algvars,
eqfilter = eq -> eq in aeqs)
var_eq_matching = Matching{Union{Unassigned, SelectedUnknown}}(var_eq_matching′)
var_eq_matching = Matching{Union{Unassigned, SelectedState}}(var_eq_matching′)
for var in 1:ndsts(graph)
if isdiffvar(state.structure, var)
var_eq_matching[var] = SelectedUnknown()
var_eq_matching[var] = SelectedState()
end
end
var_eq_matching
Expand Down
2 changes: 1 addition & 1 deletion src/systems/diffeqs/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct ODESystem <: AbstractODESystem
Dependent (unknown) variables. Must not contain the independent variable.

N.B.: If `torn_matching !== nothing`, this includes all variables. Actual
ODE unknowns are determined by the `SelectedUnknown()` entries in `torn_matching`.
ODE unknowns are determined by the `SelectedState()` entries in `torn_matching`.
"""
unknowns::Vector
"""Parameter variables. Must not contain the independent variable."""
Expand Down
2 changes: 1 addition & 1 deletion src/systems/systemstructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ function Base.show(io::IO, mime::MIME"text/plain", ms::MatchedSystemStructure)
printstyled(io, "(Unsolvable + Matched)", color = :magenta)
print(io, " | ")
printstyled(io, " ∫", color = :cyan)
printstyled(io, " SelectedUnknown")
printstyled(io, " SelectedState")
end

# TODO: clean up
Expand Down
Loading