Skip to content

Approximations using lazy containers? #117

@acostarelli

Description

@acostarelli

I'm considering if the approximations should lazily set/retrieve certain containers. E.g. Bin2 would first check if there is already a quadratic for a variable before creating a new one.

Consider the quadratic formulation for a VSC converter. The loss term needs I^2 and the power term needs VI. For a separable formulation, we can reuse the quadratic I^2 in the bilinear term. For an MDT formulation, we can use the same discretization for both terms. So discretizations sorta sit at a different layer of abstraction than quadratics in this sense, and it's a bit of an API quirk in my opinion.

Additionally, while POM is currently doing this reusing technique to save on model complexity for VSC, it sorta requires POM to know how the specific bilinear approximation works, that Bin2 uses the same quadratic it just built for the loss term, or that MDT can build one discretization and use it in both places. This leads to some weird type-dispatch helpers in POM, which is part of this API quirk problem.

I'm not sure if I explain this well. Anyway, I'm thinking this could be solved by letting approximations lazily make and retrieve containers. The biggest drawback I see to this is the behavior of the approximation functions is sorta murky now, like calling

add_quadratic_approx
add_bilinear_approx

versus just

add_bilinear_approx

have pretty different internal behaviors. For POM maybe it doesn't matter, but maybe from an open-source library perspective this takes too much from the user. But then adding an opt-in/out option (maybe a simple lazy::Bool kwarg) is maybe too clunky? Alternatively, maybe there's a way to post-process the model and identify redundancies like this.

Adding this feature would maybe open the door for other automatic improvements that IOM could make.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions