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

Fix minor bug in aggregate #108

Merged
merged 2 commits into from
Jul 30, 2024
Merged

Conversation

dlcole3
Copy link
Collaborator

@dlcole3 dlcole3 commented Jul 30, 2024

I found that the code below gave an error when I called aggregate. It appeared to be caused by this line because the objective function being passed was zero and so was not attached to any specific node. I added a second OR statement so that it also allows for the objective to be zero. In addition, I added a @warn statement to the aggregate function so that, if the graph has no objective function but the nodes do, the user is warned that the objectives will be lost in the aggregation.

MWE:

using JuMP, Plasmo, HiGHS
g = OptiGraph()
@optinode(g, nodes[1:4])

for node in nodes
    @variable(node, 0 <= x)
    @objective(node, Min, x)
end
@linkconstraint(g, nodes[1][:x] + nodes[2][:x] >= 1)
@linkconstraint(g, nodes[2][:x] + nodes[3][:x] >= 1)
@linkconstraint(g, nodes[3][:x] + nodes[4][:x] >= 1)
@linkconstraint(g, nodes[4][:x] + nodes[1][:x] >= 1)

node_membership_vector = [1, 1, 2, 2]
partition = Plasmo.Partition(g, node_membership_vector)

apply_partition!(g, partition)
#set_to_node_objectives(g)

agg_graph, agg_map = aggregate(g)

@dlcole3 dlcole3 requested a review from jalving July 30, 2024 22:10
@jalving jalving merged commit 4fe7507 into plasmo-dev:main Jul 30, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants