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

[BUG]: Model states with different names but shared identifiers are not merged by model composition #409

Closed
liunelson opened this issue Dec 18, 2024 · 1 comment

Comments

@liunelson
Copy link

I have 3 cases of concepts in model composition:

  1. both concepts have the same name and same identifier
  2. both concepts have the same name but different identifiers
  3. both concepts have different names but same identifier
  4. both concepts have the same name but one has no identifier

Case 1, the models compose as expected
Case 2, the models do not compose as expected
Case 3 (modelAB13), the models do not compose (should?)
Case 4 (modelAB34), the models do not compose (should?)

@bgyori
Is the behaviour above intentional?

S1 = Concept(name="Susceptible", identifiers={"ido": "0000514"})
I1 = Concept(name="Infected", identifiers={"ido": "0000511"})
R1 = Concept(name="Recovery", identifiers={"ido": "0000592"})

S2 = Concept(name="Susceptible", identifiers={"ido": "0000513"})
I2 = Concept(name="Infected", identifiers={"ido": "0000512"})
R2 = Concept(name="Recovery", identifiers={"ido": "0000593"})

S3 = Concept(name="S", identifiers={"ido": "0000514"})
I3 = Concept(name="I", identifiers={"ido": "0000511"})
R3 = Concept(name="R", identifiers={"ido": "0000592"})

S4 = Concept(name="S")
I4 = Concept(name="I")
R4 = Concept(name="R")
model_A1 = TemplateModel(
    templates = [
        ControlledConversion(
            name = 'Infection',
            subject = S1,
            outcome = I1,
            controller = I1
        )
    ],
    parameters = {
        'b': Parameter(name = 'b', value = 1.0)
    }
)

model_B1 = TemplateModel(
    templates = [
        NaturalConversion(
            name = 'Recovery',
            subject = I1,
            outcome = R1
        )
    ],
    parameters = {
        'g': Parameter(name = 'g', value = 1.0)
    }
)

model_B2 = TemplateModel(
    templates = [
        NaturalConversion(
            name = 'Recovery',
            subject = I2,
            outcome = R2
        )
    ],
    parameters = {
        'g': Parameter(name = 'g', value = 1.0)
    }
)

model_B3 = TemplateModel(
    templates = [
        NaturalConversion(
            name = 'Recovery',
            subject = I3,
            outcome = R3
        )
    ],
    parameters = {
        'g': Parameter(name = 'g', value = 1.0)
    }
)

model_B4 = TemplateModel(
    templates = [
        NaturalConversion(
            name = 'Recovery',
            subject = I4,
            outcome = R4
        )
    ],
    parameters = {
        'g': Parameter(name = 'g', value = 1.0)
    }
)

model_A3 = TemplateModel(
    templates = [
        ControlledConversion(
            name = 'Infection',
            subject = S3,
            outcome = I3,
            controller = I3
        )
    ],
    parameters = {
        'b': Parameter(name = 'b', value = 1.0)
    }
)
# %%
# Compose the two models together

# (matching name and ids)
model_AB11 = compose([model_A1, model_B1])
model_AB11.draw_jupyter()

# composed

# %%
# matching names, mismatched ids
model_AB12 = compose([model_A1, model_B2])
model_AB12.draw_jupyter()

# no composition

# %%
# mismatched names, matching ids
model_AB13 = compose([model_A1, model_B3])
model_AB13.draw_jupyter()

# no composition

# %%
# matching names, no id + yes id
model_AB34 = compose([model_A3, model_B4])
model_AB34.draw_jupyter()

# no composition

# %%
# matching names, no id + no id
model_AB44 = compose([model_A4, model_B4])
model_AB44.draw_jupyter()

# composed
@bgyori
Copy link
Member

bgyori commented Jan 14, 2025

Done in #415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants