@@ -10,12 +10,21 @@ function print_node(io::IO, b::LazyBridgeOptimizer, node::ObjectiveNode)
1010 F, = b. objective_types[node. index]
1111 MOIU. print_with_acronym (io, " |$(node. index) | objective function of type `$F ` is" )
1212end
13- function print_node_info (io:: IO , b:: LazyBridgeOptimizer , node:: AbstractNode )
13+ function print_node_info (
14+ io:: IO , b:: LazyBridgeOptimizer , node:: AbstractNode ;
15+ debug_unsupported = false
16+ )
1417 print (io, " " )
1518 print_node (io, b, node)
1619 d = _dist (b. graph, node)
1720 if d == INFINITY
18- print (io, " not supported\n " )
21+ print (io, " not supported" )
22+ if debug_unsupported
23+ print (io, " because" )
24+ print_unsupported (io, b, node)
25+ else
26+ println (io)
27+ end
1928 else
2029 index = bridge_index (b. graph, node)
2130 if iszero (index) || (node isa VariableNode && ! is_variable_edge_best (b. graph, node))
@@ -28,44 +37,47 @@ function print_node_info(io::IO, b::LazyBridgeOptimizer, node::AbstractNode)
2837 end
2938 end
3039end
31- print_graph (b:: LazyBridgeOptimizer ) = print_graph (Base. stdout , b)
32- function print_graph (io:: IO , b:: LazyBridgeOptimizer )
40+ print_graph (b:: LazyBridgeOptimizer ; kws ... ) = print_graph (Base. stdout , b; kws ... )
41+ function print_graph (io:: IO , b:: LazyBridgeOptimizer ; kws ... )
3342 println (io, b. graph)
34- for node in variable_nodes (b. graph)
35- print_node_info (io, b, node)
43+ print_nodes (io, b, variable_nodes (b. graph), constraint_nodes (b. graph), objective_nodes (b. graph); kws... )
44+ end
45+ function print_nodes (io:: IO , b:: LazyBridgeOptimizer , variable_nodes, constraint_nodes, objective_nodes; kws... )
46+ for node in variable_nodes
47+ print_node_info (io, b, node; kws... )
3648 end
37- for node in constraint_nodes (b . graph)
38- print_node_info (io, b, node)
49+ for node in constraint_nodes
50+ print_node_info (io, b, node; kws ... )
3951 end
40- for node in objective_nodes (b . graph)
41- print_node_info (io, b, node)
52+ for node in objective_nodes
53+ print_node_info (io, b, node; kws ... )
4254 end
4355end
4456
45- function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , node:: AbstractNode )
57+ function print_if_unsupported (io:: IO , b:: LazyBridgeOptimizer , node:: AbstractNode )
4658 if _dist (b. graph, node) != INFINITY
4759 return
4860 end
49- print (io, " " )
61+ print (io, " " )
5062 print_node (io, b, node)
5163 print (io, " not supported\n " )
5264end
5365function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , edge:: Edge )
5466 for node in edge. added_variables
55- print_unsupported (io, b, node)
67+ print_if_unsupported (io, b, node)
5668 end
5769 for node in edge. added_constraints
58- print_unsupported (io, b, node)
70+ print_if_unsupported (io, b, node)
5971 end
6072end
6173function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , edge:: ObjectiveEdge )
6274 for node in edge. added_variables
63- print_unsupported (io, b, node)
75+ print_if_unsupported (io, b, node)
6476 end
6577 for node in edge. added_constraints
66- print_unsupported (io, b, node)
78+ print_if_unsupported (io, b, node)
6779 end
68- print_unsupported (io, b, edge. added_objective)
80+ print_if_unsupported (io, b, edge. added_objective)
6981end
7082function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , edges:: Vector , index_to_bridge:: Function )
7183 no_bridge = true
@@ -74,7 +86,7 @@ function print_unsupported(io::IO, b::LazyBridgeOptimizer, edges::Vector, index_
7486 println (io, " :" )
7587 no_bridge = false
7688 end
77- MOIU. print_with_acronym (io, " Cannot use `$(index_to_bridge (edge. bridge_index)) ` because:\n " )
89+ MOIU. print_with_acronym (io, " Cannot use `$(index_to_bridge (edge. bridge_index)) ` because:\n " )
7890 print_unsupported (io, b, edge)
7991 end
8092 if no_bridge
90102function _bridge_type (b:: LazyBridgeOptimizer , node:: ObjectiveNode , bridge_index:: Int )
91103 return Objective. concrete_bridge_type (b. objective_bridge_types[bridge_index], b. objective_types[node. index]. .. )
92104end
93- function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , variables, constraints, objectives)
94- for node in variables
95- print_node (io, b, node)
96- print (io, " not supported because" )
97- print_unsupported (io, b, b. graph. variable_edges[node. index],
98- bridge_index -> _bridge_type (b, node, bridge_index))
99- print (io, " Cannot add free variables and then constrain them because" )
100- constraint_node = b. graph. variable_constraint_node[node. index]
101- if constraint_node. index == - 1
102- println (io, " free variables are bridged but no functionize bridge was added." )
103- else
104- println (io, " :" )
105- print_unsupported (io, b, constraint_node)
106- end
107- end
108- for node in constraints
109- print_node (io, b, node)
110- print (io, " not supported because" )
111- print_unsupported (io, b, b. graph. constraint_edges[node. index],
112- bridge_index -> _bridge_type (b, node, bridge_index))
113- end
114- for node in objectives
115- print_node (io, b, node)
116- print (io, " not supported because" )
117- print_unsupported (io, b, b. graph. objective_edges[node. index],
118- bridge_index -> _bridge_type (b, node, bridge_index))
105+ function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , node:: VariableNode )
106+ print_unsupported (io, b, b. graph. variable_edges[node. index],
107+ bridge_index -> _bridge_type (b, node, bridge_index))
108+ print (io, " Cannot add free variables and then constrain them because" )
109+ constraint_node = b. graph. variable_constraint_node[node. index]
110+ if constraint_node. index == - 1
111+ println (io, " free variables are bridged but no functionize bridge was added." )
112+ else
113+ println (io, " :" )
114+ print_if_unsupported (io, b, constraint_node)
119115 end
120116end
117+ function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , node:: ConstraintNode )
118+ print_unsupported (io, b, b. graph. constraint_edges[node. index],
119+ bridge_index -> _bridge_type (b, node, bridge_index))
120+ end
121+ function print_unsupported (io:: IO , b:: LazyBridgeOptimizer , node:: ObjectiveNode )
122+ print_unsupported (io, b, b. graph. objective_edges[node. index],
123+ bridge_index -> _bridge_type (b, node, bridge_index))
124+ end
121125
122126function add_unsupported (graph:: Graph , edges:: Vector{Edge} ,
123127 variables, constraints, objectives)
@@ -180,7 +184,8 @@ function debug_unsupported(io::IO, b::LazyBridgeOptimizer, node::AbstractNode)
180184 constraints = Set {ConstraintNode} ()
181185 objectives = Set {ObjectiveNode} ()
182186 add_unsupported (b. graph, node, variables, constraints, objectives)
183- print_unsupported (io, b, _sort (variables), _sort (constraints), _sort (objectives))
187+ print_nodes (io, b, _sort (variables), _sort (constraints), _sort (objectives),
188+ debug_unsupported = true )
184189end
185190
186191const UNSUPPORTED_MESSAGE = " are not supported and cannot be bridged into supported" *
0 commit comments