Open ZhaogangSu opened 2 months ago
Dear @ZhaogangSu,
Thank you for reporting this bug. I could reproduce it. This is the corrected version of the my_pricing_callback()
function in the pricing example:
function my_pricing_callback(cbdata)
## Retrieve the index of the subproblem (it will be one of the values in M_axis)
cur_machine = BD.callback_spid(cbdata, model)
## Uncomment to see that the pricing callback is called.
## println("Pricing callback for machine $(cur_machine).")
## Retrieve reduced costs of subproblem variables
red_costs = [BD.callback_reduced_cost(cbdata, x[cur_machine, j]) for j in J]
## Run the knapsack algorithm
jobs_assigned_to_cur_machine = solve_knapsack(red_costs, w[cur_machine, :], Q[cur_machine])
sol_cost = sum(red_costs[j] for j in jobs_assigned_to_cur_machine; init=0.0)
if !isempty(jobs_assigned_to_cur_machine)
## Create the solution (send only variables with non-zero values)
sol_vars = [x[cur_machine, j] for j in jobs_assigned_to_cur_machine]
sol_vals = [1.0 for _ in jobs_assigned_to_cur_machine]
## Submit the solution to the subproblem to Coluna
MOI.submit(model, BD.PricingSolution(cbdata), sol_cost, sol_vars, sol_vals)
end
## Submit the dual bound to the solution of the subproblem
## This bound is used to compute the contribution of the subproblem to the lagrangian
## bound in column generation.
MOI.submit(model, BD.PricingDualBound(cbdata), sol_cost) # optimal solution
return
end
We will update the documentation shortly.
Describe the bug I excuted the example in the offcial document : Tutorial / Getting Started / Pricing Callback
Reported error when excuting the whole optimization: ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying
init
to the reducer.So that it couldn't finish properly to give results.
To Reproduce This is the link to this example in official tutorial document of Coluna
Expected behavior It turns out that jobs_assigned_to_cur_machine becomes empty at some stage and causes this bug. jobs_assigned_to_cur_machine should not be empty at any case, since the knapsack subproblem is feasible.
Environment (please complete the following information):
Additional context The tutorial document is very helpful for a beginner like me, I would be grateful if you could handle this little bug promptly.