Skip to content

Model equality #18

Open
Open
@ajkeller34

Description

@ajkeller34

AdmittanceModels are not considered equal if columns of the input/output port matrices are permuted, with port names correspondingly permuted. I think it should be safe to consider such models equal---the ordering is entirely arbitrary and not even tied to gauge choice. Columns of the port matrix are not indexed directly, rather only after looking up the column index using the port names vector. Likewise, I think Circuits should be considered equal if equal up to a permutation of the vertices.

Furthermore, I noticed there is an isapprox method defined for AdmittanceModels. It appears convenient for some tests but I am not sure how correct it is to implement this because the atol and rtol flags are inaccessible. atol and rtol would be most useful if they were able to be specified for each matrix separately in the case of a PSOModel (or Circuit, which is not an AdmittanceModel but has a method similarly defined). As implemented, the method does not work in general, because isapprox is not defined for arrays of String port names, for example. Finally, I think there is a sense in which one could speak of different kinds of models approximating each other but that's not allowed here.

function Base. ==(am1::AdmittanceModel, am2::AdmittanceModel)
t = typeof(am1)
if typeof(am2) != t
return false
end
return all([getfield(am1, name) == getfield(am2, name) for name in fieldnames(t)])
end
function Base.isapprox(am1::AdmittanceModel, am2::AdmittanceModel)
t = typeof(am1)
if typeof(am2) != t
return false
end
return all([getfield(am1, name) getfield(am2, name) for name in fieldnames(t)])
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions