ModelGraph
Constructor
The ModelGraph is the primary object for creating graph-based models in Plasmo.jl.  A ModelGraph is a collection of ModelNodes which are connected by LinkConstraints (i.e. edges) over variables.  One way to think of the structure of a ModelGraph is a HyperGraph wherein edges represent linking constraints that can link multiple ModelNode variables.
A ModelGraph does not require any arguments to construct:
mg = ModelGraph()A ModelGraph solver can be specified upon construction using the solver keyword argument.  A solver can be any JuMP compatible solver or a Plasmo.jl provided solver (see solvers section).   For example, we could construct a ModelGraph that uses the IpoptSolver from the Ipopt package:
graph = ModelGraph(solver = IpoptSolver())Adding Nodes
Nodes can be added to a ModelGraph using the add_node! function.  By default, a node contains an empty JuMP Model object.
n1 = add_node!(graph)A model can be set upon creation by providing a second argument. For example:
model = JuMP.Model()
n1 = add_node!(graph,model)  #sets model to n1where model is a JuMP Model object.  We can also set a model on a node after construction:
setmodel(n1,model)This can be helpful in instances where a user wants to swap out a model on a node without changing the graph topology.  Keep in mind however that swapping out a model will by default remove any link-constraints that involve that node.  Also note that any single JuMP Model can only be assigned to a single node.
We can also iterate over the nodes in a ModelGraph using the getnodes function.  For example
for node in getnodes(graph)
    println(node)
endwill print the string for every node in the ModelGraph graph.  
ModelNodes can also be retrieved based on their index within a ModelGraph or vic versa.   For example, since n1 was the first node added to mg, it will have an index of 1.
n1 == getnode(mg,1)   #will return true
getindex(graph,n1) == 1  #will also return trueVariables within a JuMP Model can be accessed directly from their enclosing node.  
jump_model = Model()
@variable(jump_model,x >= 0)
setmodel(n1,jump_model)
println(n1[:x])    #accesses variable x on jump_modelAdding LinkConstraints
LinkConstraints are linear constraints that couple variables across different ModelNodes.  The simplest way to add LinkConstraints is to use the @linkconstraint macro.  This macro accepts the same input as a JuMP @constraint macro and creates linear constraints over multiple nodes within the same graph.
jump_2 = Model()
@variable(jump_2,x >= 0)
n2 = add_node!(graph,jump_2)
@linkconstraint(graph,n1[:x] == n2[:x])  #creates a linear constraint between nodes n1 and n2Subgraph Structures
It is possible to create subgraphs within a ModelGraph object.  This is helpful when a user wants to develop to separate systems and link them together within a higher level graph.
(Section TBD)
Methods
ModelGraph
The ModelGraph contains the following useful methods:
ModelGraph()
The ModelGraph Type. Represents a graph containing models (nodes) and the linkconstraints (edges) between them. A ModelGraph wraps a BasePlasmoGraph and can use its methods. A ModelGraph also wraps a LinkModel object which extends a JuMP AbstractModel to provide model management functions.
JuMP.getobjectivevalue — Function.Get the ModelGraph objective value
Get node objective value
Plasmo.PlasmoModelGraph.getinternaljumpmodel — Function.Get the current created JuMP model for the ModelGraph. Only created when solving using a JuMP compliant solver.
JuMP.setsolver — Method.setsolver(model::AbstractModelGraph,solver::AbstractMathProgSolver)
Set the graph solver to use an AbstractMathProg compliant solver
JuMP.setsolver — Method.setsolver(model::AbstractModelGraph,solver::AbstractPlasmoSolver)
Set the graph solver to use an AbstractMathProg compliant solver
Plasmo.PlasmoModelGraph.getsolver — Function.Get the ModelGraph solver
ModelNode
ModelNodes contain methods for managing their contained JuMP models.
The ModelNode type
ModelNode()
Creates an empty ModelNode. Does not add it to a graph.
Plasmo.PlasmoGraphBase.add_node! — Method.add_node!(graph::AbstractModelGraph)
Add a ModelNode to a ModelGraph.
Plasmo.PlasmoModelGraph.setmodel — Method.setmodel(node::ModelNode,m::AbstractModel)
Set the model on a node. This will delete any link-constraints the node is currently part of
Plasmo.PlasmoModelGraph.is_nodevar — Function.is_nodevar(node::ModelNode,var::AbstractJuMPScalar)
Check whether a JuMP variable belongs to a ModelNode
Plasmo.PlasmoGraphBase.getnode — Method.getnode(model::AbstractModel)
Get the ModelNode corresponding to a JuMP Model
Plasmo.PlasmoGraphBase.getnode — Method.getnode(model::AbstractModel)
Get the ModelNode corresponding to a JuMP Variable
LinkConstraints
getlinkconstraints(graph::AbstractModelGraph)
Return Array of all LinkConstraints in the ModelGraph graph
Plasmo.PlasmoModelGraph.getsimplelinkconstraints — Function.getsimplelinkconstraints(model::AbstractModelGraph)
Retrieve link-constraints that only connect two nodes"
Plasmo.PlasmoModelGraph.gethyperlinkconstraints — Function.gethyperlinkconstraints(model::AbstractModelGraph)
Retrieve link-constraints that connect three or more nodes"
Plasmo.PlasmoModelGraph.get_all_linkconstraints — Function.getalllinkconstraints(graph::AbstractModelGraph)
Get a list containing every link constraint in the graph, including its subgraphs
Plasmo.PlasmoModelGraph.addlinkconstraint — Function.Add a single link-constraint to the ModelGraph
Add a vector of link-constraints to the ModelGraph
getlinkconstraints(graph::AbstractModelGraph,node::ModelNode)
Return Array of LinkConstraints for the node
getlinkconstraints(node::ModelNode)
Return a Dictionary of LinkConstraints for each graph the node is a member of