Skip to content

Commit 1b2f875

Browse files
committed
added worker getter
1 parent 8d861a3 commit 1b2f875

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/Plasmo.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ export OptiGraph,
138138
all_remote_link_constraints,
139139
num_local_remote_link_constraints,
140140
local_remote_link_constraints,
141-
distribute_graph
141+
distribute_graph,
142+
get_worker,
143+
get_graph,
144+
get_darray
142145

143146
include("core_types.jl")
144147

src/distributed/optigraph.jl

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,35 @@ function add_subgraph(rgraph::RemoteOptiGraph, rsubgraph::RemoteOptiGraph)
118118
rsubgraph.parent_graph = rgraph
119119
end
120120
return nothing
121-
end
121+
end
122+
123+
"""
124+
get_worker(rgraph::RemoteOptiGraph)
125+
126+
Get the worker id for the worker on which the OptiGraph of the RemoteOptiGraph is stored
127+
"""
128+
function get_worker(rgraph::RemoteOptiGraph)
129+
return rgraph.worker
130+
end
131+
132+
"""
133+
get_graph(rgraph::RemoteOptiGraph)
134+
135+
Return the DistributedArray object that contains the OptiGraph of `rgraph`. This array has only one entry
136+
"""
137+
function get_graph(rgraph::RemoteOptiGraph)
138+
return rgraph.graph
139+
end
140+
141+
"""
142+
get_darray(rgraph::RemoteOptiGraph)
143+
144+
Return the DistributedArray object that contains the OptiGraph of `rgraph`. This array has only one entry.
145+
This function is equivalent to `get_graph(rgraph)` but has a more intuitive name
146+
"""
147+
function get_darray(rgraph::RemoteOptiGraph)
148+
return rgraph.graph
149+
end
122150

123151
"""
124152
Plasmo.all_nodes(rgraph::RemoteOptiGraph)

0 commit comments

Comments
 (0)