@@ -139,7 +139,8 @@ function annealing(param, graph, I0; kwargs...)
139139
140140 # rng(0) # set the seed of random number generator for replicability
141141 acceptance_str = [" rejected" , " accepted" ]
142-
142+ all_vars = all_variables_except_kappa_ex (model)
143+ start_values = start_value .(all_vars)
143144 while T > T_min
144145 accepted = false
145146
@@ -160,26 +161,26 @@ function annealing(param, graph, I0; kwargs...)
160161 end
161162
162163 k = 0
164+ set_start_value .(all_vars, start_values) # reset start values
163165 while k <= num_deepening - 1
164166
165167 auxdata = create_auxdata (param, graph, edges, I1)
166168 set_parameter_value .(model. obj_dict[:kappa_ex ], auxdata. kappa_ex)
167169
168170 optimize! (model)
169171
170- if ! is_solved_and_feasible (model, allow_almost = true ) && param. verbose # optimization failed
172+ results = recover_allocation (model, auxdata)
173+ score = results[:welfare ]
174+
175+ if (! is_solved_and_feasible (model, allow_almost = true ) || isnan (score)) && param. verbose # optimization failed
171176 println (" optimization failed! k=$(k) , return flag=$(termination_status (model)) " )
172177 k = num_deepening - 1
173178 score = - Inf
174179 end
175180
176- results = recover_allocation (model, auxdata)
177- score = results[:welfare ]
178-
179181 if param. warm_start
180- vars = all_variables (model)
181- vars_solution = value .(vars)
182- set_start_value .(vars, vars_solution)
182+ vars_solution = value .(all_vars)
183+ set_start_value .(all_vars, vars_solution)
183184 end
184185
185186 if score > best_score
@@ -237,6 +238,7 @@ function annealing(param, graph, I0; kwargs...)
237238 # Last deepening before returning found optimum
238239 has_converged = false
239240 I0 = best_I
241+ set_start_value .(all_vars, start_values) # reset start values
240242 while ! has_converged && counter < 100
241243 # Update auxdata
242244 auxdata = create_auxdata (param, graph, edges, I0)
@@ -245,16 +247,16 @@ function annealing(param, graph, I0; kwargs...)
245247 # Solve allocation
246248 optimize! (model)
247249 if ! is_solved_and_feasible (model, allow_almost = true )
248- error (" Solver returned with error code $(termination_status (model)) ." )
250+ println (" Solver returned with error code $(termination_status (model)) ." )
249251 end
250252 results = recover_allocation (model, auxdata)
251253 score = results[:welfare ]
252254
253- if param . warm_start
254- vars = all_variables (model)
255- vars_solution = value .(vars )
256- set_start_value .(vars , vars_solution)
257- end
255+ # # Fajgelbaum & Schaal always use initial values here.
256+ # if param.warm_start
257+ # vars_solution = value.(all_vars )
258+ # set_start_value.(all_vars , vars_solution)
259+ # end
258260
259261 if options. display
260262 display (plot_graph (graph, I0, node_sizes = results[:Lj ]))
@@ -293,7 +295,7 @@ function annealing(param, graph, I0; kwargs...)
293295 counter += 1
294296
295297 if param. verbose
296- println (" Iteration No.$counter - final iterations - distance=$distance - welfare=$(score) " )
298+ println (" Iteration No.$( counter) - final iterations - distance=$( distance) - welfare=$(score) " )
297299 end
298300 end
299301
0 commit comments