Skip to content

Commit

Permalink
got new formulation working
Browse files Browse the repository at this point in the history
  • Loading branch information
jalving committed Aug 14, 2023
1 parent 008e9bb commit 326923b
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 696 deletions.
70 changes: 70 additions & 0 deletions examples/cut_kKaHyPar_sea20.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# general
mode=direct
objective=cut
seed=-1
cmaxnet=1000
vcycles=0
# main -> preprocessing -> min hash sparsifier
p-use-sparsifier=true
p-sparsifier-min-median-he-size=28
p-sparsifier-max-hyperedge-size=1200
p-sparsifier-max-cluster-size=10
p-sparsifier-min-cluster-size=2
p-sparsifier-num-hash-func=5
p-sparsifier-combined-num-hash-func=100
# main -> preprocessing -> community detection
p-detect-communities=true
p-detect-communities-in-ip=true
p-reuse-communities=false
p-max-louvain-pass-iterations=100
p-min-eps-improvement=0.0001
p-louvain-edge-weight=hybrid
# main -> coarsening
c-type=ml_style
c-s=1
c-t=160
# main -> coarsening -> rating
c-rating-score=heavy_edge
c-rating-use-communities=true
c-rating-heavy_node_penalty=no_penalty
c-rating-acceptance-criterion=best_prefer_unmatched
c-fixed-vertex-acceptance-criterion=fixed_vertex_allowed
# main -> initial partitioning
i-mode=recursive
i-technique=multi
# initial partitioning -> coarsening
i-c-type=ml_style
i-c-s=1
i-c-t=150
# initial partitioning -> coarsening -> rating
i-c-rating-score=heavy_edge
i-c-rating-use-communities=true
i-c-rating-heavy_node_penalty=no_penalty
i-c-rating-acceptance-criterion=best_prefer_unmatched
i-c-fixed-vertex-acceptance-criterion=fixed_vertex_allowed
# initial partitioning -> initial partitioning
i-algo=pool
i-runs=20
# initial partitioning -> bin packing
i-bp-algorithm=worst_fit
i-bp-heuristic-prepacking=false
i-bp-early-restart=true
i-bp-late-restart=true
# initial partitioning -> local search
i-r-type=twoway_fm
i-r-runs=-1
i-r-fm-stop=simple
i-r-fm-stop-i=50
# main -> local search
r-type=kway_fm_hyperflow_cutter
r-runs=-1
r-fm-stop=adaptive_opt
r-fm-stop-alpha=1
r-fm-stop-i=350
# local_search -> flow scheduling and heuristics
r-flow-execution-policy=exponential
# local_search -> hyperflowcutter configuration
r-hfc-size-constraint=mf-style
r-hfc-scaling=16
r-hfc-distance-based-piercing=true
r-hfc-mbc=true
72 changes: 46 additions & 26 deletions examples/optimal_control.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using SchwarzOpt

T = 100 #number of time points
d = sin.(1:T) #a disturbance vector
imbalance = 0.1 #partition imbalance
distance = 5 #expand distance
n_parts = 6 #number of partitions
imbalance = 0.05 #partition imbalance
distance = 2 #expand distance
n_parts = 4 #number of partitions

#Create the model (an optigraph)
graph = OptiGraph()
Expand All @@ -34,35 +34,55 @@ end
#Partition the optigraph using recrusive bisection over a hypergraph
hypergraph,hyper_map = hyper_graph(graph) #create hypergraph object based on graph

partition_vector = KaHyPar.partition(hypergraph,n_parts,
configuration = (@__DIR__)*"/cut_rKaHyPar_sea20.ini",
imbalance = imbalance)

partition = Partition(hypergraph,partition_vector,hyper_map)
apply_partition!(graph,partition)
partition_vector = KaHyPar.partition(
hypergraph,
n_parts,
configuration = (@__DIR__)*"/cut_kKaHyPar_sea20.ini",
imbalance = imbalance
)

#Inspect the graph structure. It should be RECURSIVE_GRAPH
# println(Plasmo.graph_structure(graph))
partition = Partition(hypergraph, partition_vector, hyper_map)
apply_partition!(graph, partition)

#calculate subproblems using expansion distance
subgraphs = getsubgraphs(graph)
expanded_subgraphs = Plasmo.expand.(graph,subgraphs,distance)
sub_optimizer = optimizer_with_attributes(Ipopt.Optimizer,"print_level" => 0)
expanded_subgraphs = Plasmo.expand.(graph, subgraphs, distance)
sub_optimizer = optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0)


# optimizer = SchwarzOpt.Optimizer(
# graph,
# expanded_subgraphs;
# sub_optimizer=sub_optimizer,
# max_iterations=50,
# mu=1.0
# )
# SchwarzOpt._initialize_optimizer!(optimizer)

optimizer = SchwarzOpt.Optimizer(
graph,
expanded_subgraphs;
sub_optimizer=sub_optimizer,
max_iterations=50,
mu=1.0
)
SchwarzOpt._initialize_optimizer!(optimizer)
# for subgraph in optimizer.subproblem_graphs
# JuMP.set_optimizer(subgraph, optimizer.sub_optimizer)
# end

# for subproblem_graph in optimizer.subproblem_graphs
# SchwarzOpt._update_subproblem!(optimizer, subproblem_graph)
# end

# # sg1 = optimizer.subproblem_graphs[1]
# # xk,lk = SchwarzOpt._do_iteration(sg1)

# for subproblem_graph in optimizer.subproblem_graphs
# xk,lk = SchwarzOpt._do_iteration(subproblem_graph)
# println(xk)
# println(lk)
# end

# inc_edges = SchwarzOpt._find_boundaries(graph, optimizer.subproblem_graphs)

#optimize using schwarz overlapping decomposition
# SchwarzOpt.optimize!(graph;
# subgraphs = expanded_subgraphs,
# sub_optimizer = sub_optimizer,
# max_iterations = 50
# )
SchwarzOpt.optimize!(
graph;
subgraphs = expanded_subgraphs,
sub_optimizer = sub_optimizer,
max_iterations = 200,
mu=0.001
)
Loading

0 comments on commit 326923b

Please sign in to comment.