plasmo-dev / Plasmo.jl

A Platform for Scalable Modeling and Optimization
Other
143 stars 20 forks source link

`aggregate` throws an error for some OptiGraphs when `max_depth` > 0 #76

Closed dlcole3 closed 10 months ago

dlcole3 commented 1 year ago

I found that I am getting an error when trying to aggregate a problem with a max_depth of 1. I believe the issue is coming because the variable nodes in this line has a length of 0. For the problem I am working on, I have an OptiGraph with subgraphs where all OptiNodes are contained on the subgraphs. Consequently, optinodes(graph) is empty since it appears that optinodes only gets the OptiNodes defined on the highest layer. Below is a minimum working example that returns the same error that I am getting.

using Plasmo

graph0 = OptiGraph()

graph1 = OptiGraph()
graph2 = OptiGraph()

@optinode(graph1, node1)
@variable(node1, 0 <= x)
@optinode(graph2, node2)
@variable(node2, 0 <= x)

add_subgraph!(graph0, graph1)
add_subgraph!(graph0, graph2)

@linkconstraint(graph0, graph1[:node1][:x] + graph2[:node2][:x] >= 1)

println(length(optinodes(graph0)) == 0)

agg_1, extras = Plasmo.aggregate(graph0, 1)
jalving commented 1 year ago

thanks for reporting this. I will take a look soon.