Open avinashresearch1 opened 1 year ago
Hi @avinashresearch1. Thanks for your interest in the package!
An OptiGraph
does not support adding variables directly. It requires variables to be defined on OptiNodes
(although I have been thinking about adding support for light-weight variable nodes). You can still create your objective function using @objective
, you just have to reference variables on the nodes. For example, you should be able to do something like:
graph = OptiGraph()
@optinode(graph, node1)
@optinode(graph, node2)
@variable(node1, x>=0)
@variable(node2, x>=0)
@objective(graph, Min, node1[:x] + node2[:x])
For your second question, the closest thing is aggregate(graph)
. This copies everything in the optigraph into a new node and returns the node and a dictionary that maps optigraph elements to the new node elements. This would look like:
aggregated_node, ref_dict = aggregate(graph)
aggregated_node_x1 = ref_dict[node1[:x]]
aggregated_node_x2 = ref_dict[node2[:x]]
The OptiGraph
is actually a model object in its own right with a MathOptInterface
backend just like a JuMP model.
Hi, Thanks for the exciting toolkit.
I see in the API documentation that the
OptiGraph
object extends a JuMP.AbstractModel and supports most JuMP.Model functions. My understanding was that one could specify certainOptiNode
objects within theOptiGraph
, and then one could have a customoverall
objective that one would specify in theOptiGraph
taking variables from differentOptiNodes
.For example, I would like to only specify feasibility problems in the
OptiNode
s and then set up an objective for theOptiGraph
(instead of using a linear combination as is default).However, when I try to add a variable or an objective to the
Optigraph
object, I get a MethodError:jump_model(node::OptiNode)
prints out the respective JuMP model. I was wondering if there is a corresponding function for theOptiGraph