Skip to content

Commit

Permalink
dont require metis
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbynum committed Sep 5, 2023
1 parent 972439f commit 90a1cb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion coramin/domain_reduction/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
from pyomo.core.expr.visitor import replace_expressions
import logging
import networkx
import metis
try:
import metis
metis_available = True
except ImportError:
metis_available = False
import numpy as np
import math
from pyomo.core.base.block import declare_custom_block, _BlockData
Expand Down Expand Up @@ -306,6 +310,8 @@ def choose_metis_partition(graph, max_size_diff_trials, seed_trials):
max_size_diff_selected: float
seed_selected: float
"""
if not metis_available:
raise ImportError('Cannot perform graph partitioning without metis. Please install metis (including the python bindings).')
cut_list = list()
for _max_size_diff in max_size_diff_trials:
for _seed in seed_trials:
Expand Down Expand Up @@ -486,6 +492,8 @@ def split_metis(graph, model):
-------
tree: _Tree
"""
if not metis_available:
raise ImportError('Cannot perform graph partitioning without metis. Please install metis (including the python bindings).')
max_size_diff, seed = choose_metis_partition(graph, max_size_diff_trials=[0.15], seed_trials=list(range(10)))
if seed is None:
edgecuts, parts = metis.part_graph(_networkx_to_adjacency_list(graph), nparts=2, ubvec=[1 + max_size_diff])
Expand Down
2 changes: 1 addition & 1 deletion coramin/domain_reduction/filters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyomo.common.collections import ComponentSet
from coramin.domain_reduction.obbt import _bt_prep, _bt_cleanup
import pyomo.environ as pe
from pyomo.core.expr.current import LinearExpression
from pyomo.core.expr.numeric_expr import LinearExpression
import logging
from pyomo.contrib import appsi
from pyomo.core.base.var import _GeneralVarData
Expand Down

0 comments on commit 90a1cb5

Please sign in to comment.