Skip to content

Commit

Permalink
partition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jalving committed Jun 19, 2024
1 parent 338953c commit 5bc26dd
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 493 deletions.
File renamed without changes
255 changes: 0 additions & 255 deletions docs/plasmo2.svg

This file was deleted.

18 changes: 14 additions & 4 deletions src/Plasmo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export OptiGraph, NodeVariableRef,

graph_backend, graph_index,

add_node, add_edge, add_subgraph,

has_edge, get_edge,
add_node, add_edge, add_subgraph, has_edge, get_edge,

collect_nodes, local_nodes, all_nodes, local_edges, all_edges,

Expand All @@ -40,16 +38,28 @@ set_to_node_objectives,

containing_optigraphs, source_graph, assemble_optigraph,

Partition, apply_partition!, aggregate, aggregate!, aggregate_to_depth,
# partition

Partition, apply_partition, apply_partition!, n_subpartitions, all_subpartitions,

# aggregate

aggregate, aggregate!, aggregate_to_depth,

# projections

hyper_projection, edge_hyper_projection, clique_projection,

edge_clique_projection, bipartite_projection,

# topoology

incident_edges, induced_edges, identify_nodes, identify_edges,

neighborhood, expand,

# macros

@optinode, @nodevariables, @linkconstraint

include("core_types.jl")
Expand Down
23 changes: 9 additions & 14 deletions src/graph_functions/partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ end
@deprecate getpartitionlist get_partition_list
@deprecate partition_list get_partition_list

### Partition constructors
#
# Partition constructors
#

"""
Partition(graph::OptiGraph, node_membership_vector::Vector{Int64})
Expand Down Expand Up @@ -122,16 +124,9 @@ function Partition(projection::GraphProjection, membership_vector::Vector{Int64}
return partition
end

# function Partition(membership_vector::Vector{Int64}, ref_map::ProjectionMap; kwargs...)
# optigraph = ref_map.optigraph
# partition_vectors = Plasmo._partition_list(membership_vector)
# induced = Plasmo.induced_elements(ref_map.projected_graph, partition_vectors; kwargs...)
# partition_elements = Plasmo._identify_partitions(induced, ref_map) #could be optinode_vectors, optiedge_vectors, or subgraphs
# partition = Partition(optigraph, partition_elements)
# return partition
# end

# Partition utilities
#
# partition utilities
#

function _check_valid_partition(
graph::OptiGraph, optinode_vectors::Vector{Vector{OptiNode}}
Expand Down Expand Up @@ -282,7 +277,9 @@ function _build_partition_list(membership_vector::Vector)
return partitions
end

### Partition methods
#
# partition methods
#

function all_subpartitions(partition::Partition)
subparts = partition.subpartitions
Expand All @@ -309,8 +306,6 @@ function all_nodes(partition::Partition)
return nodes
end

### Create and modify optigraphs with partitions

"""
Assemble a new optigraph from a given `Partition`.
"""
Expand Down
43 changes: 1 addition & 42 deletions src/optiedge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,45 +136,4 @@ end
function JuMP.is_valid(edge::OptiEdge, cref::ConstraintRef)
return edge === JuMP.owner_model(cref) &&
MOI.is_valid(graph_backend(edge), cref)
end

#
# MOI Methods
#

# function MOI.get(edge::OptiEdge, attr::MOI.AbstractConstraintAttribute, ref::ConstraintRef)
# return MOI.get(graph_backend(edge), attr, ref)
# end

# function MOI.get(edge::OptiEdge, attr::MOI.ListOfConstraintTypesPresent)
# cons = graph_backend(edge).element_constraints[edge]
# con_types = unique(typeof.(cons))
# type_tuple = [(type.parameters[1],type.parameters[2]) for type in con_types]
# return type_tuple
# end

# function MOI.get(
# edge::OptiEdge,
# attr::MOI.NumberOfConstraints{F,S}
# ) where {F <: MOI.AbstractFunction, S <: MOI.AbstractSet}
# num_cons = 0
# for con in graph_backend(edge).element_constraints[edge]
# if (typeof(con).parameters[1] == F && typeof(con).parameters[2] == S)
# num_cons += 1
# end
# end
# return num_cons
# end

# function MOI.get(
# edge::OptiEdge,
# attr::MOI.ListOfConstraintIndices{F,S}
# ) where {F <: MOI.AbstractFunction, S <: MOI.AbstractSet}
# con_inds = MOI.ConstraintIndex{F,S}[]
# for con in graph_backend(edge).element_constraints[edge]
# if (typeof(con).parameters[1] == F && typeof(con).parameters[2] == S)
# push!(con_inds, con)
# end
# end
# return con_inds
# end
end
Loading

0 comments on commit 5bc26dd

Please sign in to comment.