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

Think about how to build StructJuMP models #5

Open
coroa opened this issue May 27, 2019 · 5 comments
Open

Think about how to build StructJuMP models #5

coroa opened this issue May 27, 2019 · 5 comments

Comments

@coroa
Copy link
Member

coroa commented May 27, 2019

StructJuMP allows to organize and separate the block structure of huge models. In a nutshell one creates variables and constraints on several StructuredModel instances, one of which is the master and several others which define the subproblems.

These instances can then be communicated to parallel solvers like PIPS or DSP.

Do we want to split the variables constraints of a single component? ie Generator dispatch being split from capacity? Are there multiple cuts one would like to make?

@fneum Thoughts?

@coroa
Copy link
Member Author

coroa commented Jun 1, 2019

Most importantly the JuMP model must be dis-entangled from the EnergyModel since with StructJuMP there might now be multiple ones. So, the standard form of build will accept a JuMP.AbstractModel on which it will create its @variable and @constraint!

@coroa
Copy link
Member Author

coroa commented Jun 4, 2019

build(::Component) was replaced by a more general in 31d13df

addto!(::JuMP.AbstractModel, ::EnergyModel, ::Component)

which allows using different jump models per component. Not sure if that is good enough!

@fneum
Copy link
Member

fneum commented Jun 5, 2019

Support for PIPS-IPM interior point solver needs to be done if used: StructJuMP/StructJuMP.jl#24

@fneum
Copy link
Member

fneum commented Jun 5, 2019

There are two interesting ways of structuring:

  • in space: cut by subnetwork and maybe also where the AC-network is weakly connected.
  • in time: cut by snapshot or group of snapshots. In this case investment variables should go in the parent model (more difficult).

One way could be to have addto!() for particular components and snapshots:

T = axis(c, :snapshots)
G = axis(c)
addto!(::JuMP.AbstractModel, ::EnergyModel, c, G[1], T[1])

which would be called in

addto!(::JuMP.AbstractModel, ::EnergyModel, c, G[1])
addto!(::JuMP.AbstractModel, ::EnergyModel, c, T[1])
addto!(::JuMP.AbstractModel, ::EnergyModel, ::Component)

Just a thought. I don't know how good it is and it would probably mess with the current structure a lot.

If one wants to separate the investment variables/constraints from dispatch variables/constraints it gets more messy:

addto!(::JuMP.AbstractModel, ::EnergyModel, c, G[1], T[1], investment_flag=true/false)

I am not sure if this is worth doing.

@coroa
Copy link
Member Author

coroa commented Jun 6, 2019

Ok, here's an idea, which I think solves this seemingly difficult problem cleanly and combines well New repr. of time (#14):

I did simplify my explanation above a tiny bit, the method signatures for the addto! function for each component like

function addto!(jm::ModelView, ::EnergyModel, c::Generator)
     @variable jm ...
     @constraint jm ...
end

and there is a

addto!(jm::JuMP.AbstractModel, m::EnergyModel, c::Component) = addto!(ModelView(jm, c), m, c)

connector, that automatically wraps the jump model in a small jump extension, which redirects where jump objects are stored and prefixes their names with <class>::.

Ok, that was all an unnecessary explanation, because the idea was not finished yet, it's still a bit WIP, but here's the current state:

  • Let's create a new type, which holds the "process" data of a part of the full model, ie. the parameters of defining the subset (buses, snapshots, investment flag), the JuMP.AbstractModel, the variables/constraints.
struct SubEnergyModel   # the name is still WIP
   model::EnergyModel
   subset
   jumpmodel::JuMP.AbstractModel
   objects
end

Then, one could construct such SubEnergyModels

sm = SubEnergyModel(m, Dict(:buses=>some_buses), jm, Dict{Symbol,Any}())
addto!(sm::SubEnergyModel, ::EnergyModel, c::Component)

A typical addto! method would then do the axis calls on sm:

function addto!(sm::SubEnergyModel, ::EnergyModel, c::Generator)
   G = axis(sm, c)
   T = axis(sm, :snapshots) # To be changed to maybe `timeaxis`
   jm = ModelView(sm.jumpmodel, sm, c) # That's a detail the user should not have to know about

   @variable jm ...
end

Open questions:

...

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