I posted this on Slack, and was recommended to also post it here.
I am setting up a problem in Plasmo, in which some nodes have (some of) the same variables & constraints as other nodes. So I wanted to write a function that takes in a graph, and a symbol, and adds a node (with some constraints) to the graph with that node. Then afterwards, I could add the constraints specific to that node.
The below is a small MWE, however it doesn’t work. I was told on Slack that @optinode doesn’t see that name is actually :trial .
using Plasmo
graph = OptiGraph()
function CreateNode!(graph, name)
@optinode(graph, name)
@variable(name, y >= 2)
end
CreateNode!(graph, :trial)
@linkconstraint(graph, trail[:y] == 10)
I suppose that an alternative would be to create the node out of the function, and then have the function add variables/constraints to the node. Is there a cleaner way to do this?