@@ -17,6 +17,21 @@ function resolve(model_old, instance::Instance; optimizer = nothing)::OrderedDic
17
17
lp_optimizer = _get_default_lp_optimizer ()
18
18
end
19
19
20
+ @info " Filtering candidate locations..."
21
+ selected_pairs = Set ()
22
+ for ((node_old, t), var_old) in model_old[:is_open ]
23
+ if JuMP. value (var_old) > 0.1
24
+ push! (selected_pairs, (node_old. location. plant_name, node_old. location. location_name))
25
+ end
26
+ end
27
+ filtered_plants = []
28
+ for p in instance. plants
29
+ if (p. plant_name, p. location_name) in selected_pairs
30
+ push! (filtered_plants, p)
31
+ end
32
+ end
33
+ instance. plants = filtered_plants
34
+
20
35
@info " Building new graph..."
21
36
graph = build_graph (instance)
22
37
_print_graph_stats (instance, graph)
@@ -48,10 +63,12 @@ function _fix_plants!(model_old, model_new)::Nothing
48
63
# Fix open_plant variables
49
64
for ((node_old, t), var_old) in model_old[:open_plant ]
50
65
value_old = JuMP. value (var_old)
51
- node_new = model_new[ :graph ] . name_to_process_node_map[ (
66
+ key = (
52
67
node_old. location. plant_name,
53
68
node_old. location. location_name,
54
- )]
69
+ )
70
+ key ∈ keys (model_new[:graph ]. name_to_process_node_map) || continue
71
+ node_new = model_new[:graph ]. name_to_process_node_map[key]
55
72
var_new = model_new[:open_plant ][node_new, t]
56
73
JuMP. unset_binary (var_new)
57
74
JuMP. fix (var_new, value_old)
@@ -61,10 +78,12 @@ function _fix_plants!(model_old, model_new)::Nothing
61
78
for ((node_old, t), var_old) in model_old[:is_open ]
62
79
t > 0 || continue
63
80
value_old = JuMP. value (var_old)
64
- node_new = model_new[ :graph ] . name_to_process_node_map[ (
81
+ key = (
65
82
node_old. location. plant_name,
66
83
node_old. location. location_name,
67
- )]
84
+ )
85
+ key ∈ keys (model_new[:graph ]. name_to_process_node_map) || continue
86
+ node_new = model_new[:graph ]. name_to_process_node_map[key]
68
87
var_new = model_new[:is_open ][node_new, t]
69
88
JuMP. unset_binary (var_new)
70
89
JuMP. fix (var_new, value_old)
@@ -73,10 +92,12 @@ function _fix_plants!(model_old, model_new)::Nothing
73
92
# Fix plant capacities
74
93
for ((node_old, t), var_old) in model_old[:capacity ]
75
94
value_old = JuMP. value (var_old)
76
- node_new = model_new[ :graph ] . name_to_process_node_map[ (
95
+ key = (
77
96
node_old. location. plant_name,
78
97
node_old. location. location_name,
79
- )]
98
+ )
99
+ key ∈ keys (model_new[:graph ]. name_to_process_node_map) || continue
100
+ node_new = model_new[:graph ]. name_to_process_node_map[key]
80
101
var_new = model_new[:capacity ][node_new, t]
81
102
JuMP. delete_lower_bound (var_new)
82
103
JuMP. delete_upper_bound (var_new)
@@ -87,10 +108,12 @@ function _fix_plants!(model_old, model_new)::Nothing
87
108
for ((node_old, t), var_old) in model_old[:expansion ]
88
109
t > 0 || continue
89
110
value_old = JuMP. value (var_old)
90
- node_new = model_new[ :graph ] . name_to_process_node_map[ (
111
+ key = (
91
112
node_old. location. plant_name,
92
113
node_old. location. location_name,
93
- )]
114
+ )
115
+ key ∈ keys (model_new[:graph ]. name_to_process_node_map) || continue
116
+ node_new = model_new[:graph ]. name_to_process_node_map[key]
94
117
var_new = model_new[:expansion ][node_new, t]
95
118
JuMP. delete_lower_bound (var_new)
96
119
JuMP. delete_upper_bound (var_new)
0 commit comments