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

Problem Formulation Conventions #61

Closed
ccoffrin opened this issue Jul 18, 2018 · 8 comments
Closed

Problem Formulation Conventions #61

ccoffrin opened this issue Jul 18, 2018 · 8 comments
Labels

Comments

@ccoffrin
Copy link
Member

Based on @frederikgeth's most recent PR, https://github.com/lanl-ansi/ThreePhasePowerModels.jl/pull/60, I am wondering if it would be better if the ThreePhase problem formulations adopted the following convention,

  1. when we define an three-phase function (i.e. _tp_) then the conductors are handled inside that function
  2. when we use a function from PowerModels or a function that is always separable by conductor, then we pass the conductor as an argument.

Below is an example of how this might work. For many formulations the _tp_ variants will likely just delegate to some PowerModels base function, but for the more advanced formulations they may do other things.

The goal here would be able to support a wide variety formulation variants with a shared problem specification, and reuse PowerModels base implementation, as much as possible. @frederikgeth if we adopted this convention, would you be able to eliminate the mat problem variants you propose in https://github.com/lanl-ansi/ThreePhasePowerModels.jl/pull/60?

Thoughts?

function post_tp_opf(pm::GenericPowerModel)
    variable_tp_voltage(pm)

    for c in PMs.conductor_ids(pm)
        PMs.variable_generation(pm, cnd=c)
        PMs.variable_branch_flow(pm, cnd=c)
        PMs.variable_dcline_flow(pm, cnd=c)
    end

    constraint_tp_voltage(pm)

    for i in ids(pm, :ref_buses)
        constraint_tp_theta_ref(pm, i)
    end

    for i in ids(pm, :bus), c in PMs.conductor_ids(pm)
        PMs.constraint_kcl_shunt(pm, i, cnd=c)
    end

    for i in ids(pm, :branch)
        constraint_ohms_tp_yt_from(pm, i)
        constraint_ohms_tp_yt_to(pm, i)

        for c in PMs.conductor_ids(pm)
            PMs.constraint_voltage_angle_difference(pm, i, cnd=c)

            PMs.constraint_thermal_limit_from(pm, i, cnd=c)
            PMs.constraint_thermal_limit_to(pm, i, cnd=c)
        end
    end

    for i in ids(pm, :dcline), for c in PMs.conductor_ids(pm)
        PMs.constraint_dcline(pm, i, cnd=c)
    end

    PMs.objective_min_fuel_cost(pm)
end
@pseudocubic
Copy link
Collaborator

I think this is a good idea if we will be relying more heavily on matrix formulations in constraints, which I strayed away from early on due to their inability to be used in NLconstraint (is this still the case? can matrix formulations still only be used in constraint?).

@frederikgeth
Copy link
Collaborator

I am also in favour of a shared problem definition! I'll update accordingly. I don't foresee any problems eliminating the mat constraint variants extending your updated problem definition to the BFM variant.

Matrix expressions are still not supported in @NLconstraint. But debugging an equivalent scalar formulation will be hard without having a baseline. So I prioritised this. Also, for supporting more than 3 conductors, the matrix-based formulations may make development a bit easier.

@ccoffrin
Copy link
Member Author

Great.

As in PowerModels, we can have two branches in the type hierarchy one that targets conic / matrix formulations and the other that is QCQP/NLP.

I agree that having a baseline to compare to will help build and debug equivalent formulations.

ccoffrin pushed a commit that referenced this issue Aug 3, 2018
* Change of phase order + add fixed voltage magnitude bus support

Partially updated tests

* fixes per discussion in PR TPPM

* Validation of Linearised (simplified) Branch Flow model

preliminary fixes
- current variable set to zero in simplified branch flow
- line losses only the shunts

TODO:
- fix unit tests
- support transformer?
- phase order (rotation direction)

* Support transformer + fix phase rotation + remove current variable

* Updated unit tests

* Adding support for SDP and SOC BFM

* Correct reference bus + updated linear approximation

- .values need to remain
- got rid of n_cond=3 throughout
- docstrings for formulations
- corrected constraint_tp_theta_ref
- better distinction between LinDist3Flow and Simplified BFM by Gan and Low
- remove debug codes
- added test case, to be expanded in unit tests

* Updating naming conventions #61

* Unit tests for matrix helper functions

* Bugfix in matrix-wise problem types

* Making sure all unit tests run

* Tighter bounds + SDP unit tests

* Fix for travis

* Exploring SOC relaxation properties further

* Debug SDP to SOC relaxation

* Debugging shunts

* Support multiphase reference bus

* finishing PR

- finish type hierarchy of unbalanced BFM
- rename files ('mx' for matrix)
- capitals for matrix variables
- add unit tests for linear models

* fix test parameters and solver output
pseudocubic pushed a commit that referenced this issue Aug 3, 2018
* Change of phase order + add fixed voltage magnitude bus support

Partially updated tests

* fixes per discussion in PR TPPM

* Validation of Linearised (simplified) Branch Flow model

preliminary fixes
- current variable set to zero in simplified branch flow
- line losses only the shunts

TODO:
- fix unit tests
- support transformer?
- phase order (rotation direction)

* Support transformer + fix phase rotation + remove current variable

* Updated unit tests

* Add support for parsing OpenDSS' PVSystem

* Adding support for SDP and SOC BFM

* Correct reference bus + updated linear approximation

- .values need to remain
- got rid of n_cond=3 throughout
- docstrings for formulations
- corrected constraint_tp_theta_ref
- better distinction between LinDist3Flow and Simplified BFM by Gan and Low
- remove debug codes
- added test case, to be expanded in unit tests

* Updating naming conventions #61

* Unit tests for matrix helper functions

* Bugfix in matrix-wise problem types

* Making sure all unit tests run

* Tighter bounds + SDP unit tests

* Fix for travis

* Exploring SOC relaxation properties further

* Debug SDP to SOC relaxation

* Debugging shunts

* Support multiphase reference bus

* finishing PR

- finish type hierarchy of unbalanced BFM
- rename files ('mx' for matrix)
- capitals for matrix variables
- add unit tests for linear models

* Support for OpenDSS PVSystem

* REM: import_all requirement to support PVSystem

Removes requirement of import_all flag for supporting parse of PVSystem components
@ccoffrin ccoffrin mentioned this issue Aug 12, 2018
@pseudocubic pseudocubic added the Category: Problem Specifications Problem specification label Nov 27, 2018
@pseudocubic
Copy link
Collaborator

This seems to be resolved, closing

@ccoffrin
Copy link
Member Author

Still work to be done. :-)

@pseudocubic
Copy link
Collaborator

Ah, I misread part of the original post just now. For future reference for myself, functions like constraint_ohms_tp_yt_from(pm, i, cnd=c) used in e.g. the tp_opf problem specification still need to be rewritten such that cnd=c is not passed as an argument, but handled inside of the function

@ccoffrin
Copy link
Member Author

I am not 100% sure that is the best solution, this issue is reminder to think about this in general and try to find a clean and intuitive design.

@frederikgeth
Copy link
Collaborator

frederikgeth commented Nov 27, 2018

I'm experimenting here with how improve the matrix-based problem definition and the use of matrix variables for generators/loads and matrix equations for nodal KCL. I'll come back to this afterwards with lessons learned.

pseudocubic added a commit that referenced this issue Sep 5, 2019
This refactor ensures that all variable and constraint functions internal to PowerModelsDistribution, e.g. those containing `_mc_`, have any loops over the phases internal to that function, instead of requiring an explicit loop inside the problem definition.

Updates changelog

Closes #81
Closes #61
Closes #152
pseudocubic added a commit that referenced this issue Sep 5, 2019
This refactor ensures that all variable and constraint functions internal to PowerModelsDistribution, e.g. those containing `_mc_`, have any loops over the phases internal to that function, instead of requiring an explicit loop inside the problem definition.

Updates changelog

Closes #81
Closes #61
Closes #152
pseudocubic added a commit that referenced this issue Sep 5, 2019
This refactor ensures that all variable and constraint functions internal to PowerModelsDistribution, e.g. those containing `_mc_`, have any loops over the phases internal to that function, instead of requiring an explicit loop inside the problem definition.

Updates changelog

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

No branches or pull requests

3 participants