-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example of column generation #2006
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2006 +/- ##
=========================================
- Coverage 89.13% 89.1% -0.04%
=========================================
Files 33 33
Lines 4324 4312 -12
=========================================
- Hits 3854 3842 -12
Misses 470 470
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the style of the other examples: place everything inside a function, and add an informative docstring.
Here is an update example, with a lot more description (the problem to solve, a general description of the technique), but I did not write a column-generation tutorial. However, I did not change the dividing in functions, as there is just a main function and the pricing problem: merging the two would make things less clear, I fear. |
@dourouc05 cool that you're using it. Instead of a repo I will archive both the post and code in a reproducible state (with Manifest and all) to cite something stable |
|
||
using JuMP, GLPK | ||
using SparseArrays | ||
const MOI = JuMP.MathOptInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already exported by JuMP
@dourouc05 you can use @misc{mathieu_besancon_2019_3329389,
author = {Mathieu Besançon},
title = {{A column generation example in Julia and JuMP}},
month = jul,
year = 2019,
doi = {10.5281/zenodo.3329388},
url = {https://doi.org/10.5281/zenodo.3329388}
} |
I did not add the full BibTeX entry, as it is easy enough to find from Zenodo. Is that good enough for you? |
Yup all good thanks |
new_pattern = try | ||
solve_pricing(dual.(demand_satisfaction), maxwidth, widths, rollcost, demand, prices) | ||
catch | ||
# At the final iteration, GLPK has dual values, but at least one of them is 0.0, and thus GLPK crashes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does a dual value of 0.0 cause GLPK to crash? That shouldn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's more GPLK.jl that gives an error (Cbc.jl too):
ERROR: LoadError: AssertionError: dual >= 0.0
Stacktrace:
[1] __assert_dual_sense__ at C:\Users\…\.julia\packages\LinQuadOptInterface\ZMx9f\src\solve.jl:210 [inlined]
[2] get at C:\Users\…\.julia\packages\LinQuadOptInterface\ZMx9f\src\solve.jl:217 [inlined]
[3] get(::MathOptInterface.Bridges.LazyBridgeOptimizer{GLPK.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.ConstraintDual, ::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.GreaterThan{Float64}}) at C:\Users\…\.julia\packages\MathOptInterface\C3lip\src\Bridges\bridgeoptimizer.jl:236
[4] get(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}, ::MathOptInterface.ConstraintDual, ::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.GreaterThan{Float64}}) at C:\Users\…\.julia\packages\MathOptInterface\C3lip\src\Utilities\cachingoptimizer.jl:453
[5] _moi_get_result(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}, ::MathOptInterface.ConstraintDual, ::Vararg{Any,N} where N) at C:\Users\…\.julia\dev\JuMP\src\JuMP.jl:618
[6] get(::Model, ::MathOptInterface.ConstraintDual, ::ConstraintRef{Model,MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.GreaterThan{Float64}},ScalarShape}) at C:\Users\…\.julia\dev\JuMP\src\JuMP.jl:649
[7] _constraint_dual(::ConstraintRef{Model,MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.GreaterThan{Float64}},ScalarShape}) at C:\Users\…\.julia\dev\JuMP\src\constraints.jl:545
[8] dual(::ConstraintRef{Model,MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.GreaterThan{Float64}},ScalarShape}) at C:\Users\…\.julia\dev\JuMP\src\constraints.jl:538
[9] _broadcast_getindex_evalf at .\broadcast.jl:625 [inlined]
[10] _broadcast_getindex at .\broadcast.jl:598 [inlined]
[11] getindex at .\broadcast.jl:558 [inlined]
[12] copyto_nonleaf!(::Array{Float64,1}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(dual),Tuple{Base.Broadcast.Extruded{Array{ConstraintRef{Model,C,Shape} where Shape<:AbstractShape where C,1},Tuple{Bool},Tuple{Int64}}}}, ::Base.OneTo{Int64}, ::Int64, ::Int64) at .\broadcast.jl:982
[13] copy at .\broadcast.jl:836 [inlined]
[14] materialize at .\broadcast.jl:798 [inlined]
[15] #example_cutting_stock#3(::Int64, ::typeof(example_cutting_stock)) at C:\Users\…\Desktop\a.jl:126
[16] example_cutting_stock() at C:\Users\…\Desktop\a.jl:88
[17] top-level scope at C:\Users\…\Desktop\a.jl:175
* Add optional kwargs to optimize! for optimize_hook * Add test for unexpected kwarg error * Add documentation on kwargs to optimize! * Formatting tweak
9b23c69
to
790da29
Compare
790da29
to
4c19ef8
Compare
I'm messing up with the rebase, I'll open a new PR. |
* Restore the old PR. #2006 * Use the new function set_objective_coefficient. * Add the standard license header. * Remove the workaround for current GLPK.jl. * Update to JuMP 0.20.
Follows #2004