Skip to content
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

Assertion error, explore.jl type expected an Int32 and got an Int64 #1124

Closed
jkhamphousone opened this issue Jan 24, 2024 · 1 comment · Fixed by #1125
Closed

Assertion error, explore.jl type expected an Int32 and got an Int64 #1124

jkhamphousone opened this issue Jan 24, 2024 · 1 comment · Fixed by #1125
Assignees
Labels
bug Something isn't working

Comments

@jkhamphousone
Copy link

jkhamphousone commented Jan 24, 2024

Describe the bug

Coluna
Version 0.7.0 | https://github.com/atoptima/Coluna.jl
***************************************************************************************
**** B&B tree root node
**** Local DB = Inf, global bounds: [ Inf , -Inf ], time = 70.70 sec.
***************************************************************************************
ERROR: TypeError: in typeassert, expected Int32, got a value of type Int64
Stacktrace:
  [1] setindex!(A::Vector{Int32}, x::Coluna.MathProg.VarId, i1::Int64)
    @ Base ./array.jl:1021
  [2] _binarymap_mode_1!(f::typeof(-), mx::Int64, my::Int64, xnzind::Vector{Coluna.MathProg.VarId}, xnzval::Vector{Float64}, ynzind::Vector{Coluna.MathProg.VarId}, ynzval::Vector{Float64}, rind::Vector{Int32}, rval::Vector{Float64})
    @ SparseArrays /raid/home/julien/julia-1.10.0/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1490
  [3] _binarymap(f::Function, x::SparseArrays.SparseVector{Float64, Coluna.MathProg.VarId}, y::SparseArrays.SparseVector{Float64, Coluna.MathProg.VarId}, mode::Int64)
    @ SparseArrays /raid/home/julien/julia-1.10.0/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1427
  [4] -
    @ /raid/home/julien/julia-1.10.0/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1562 [inlined]
  [5] run_colgen_iteration!(context::Coluna.Algorithm.ColGenPrinterContext, phase::Coluna.Algorithm.ColGenPhase0, stage::Coluna.Algorithm.ColGenStage, env::Coluna.Env{Coluna.MathProg.VarId}, ip_primal_sol::Coluna.Algorithm.GlobalPrimalBoundHandler, stab::Coluna.Algorithm.NoColGenStab)
    @ Coluna.ColGen ~/.julia/packages/Coluna/TvRgV/src/ColGen/ColGen.jl:155
  [6] run_colgen_phase!(context::Coluna.Algorithm.ColGenPrinterContext, phase::Coluna.Algorithm.ColGenPhase0, stage::Coluna.Algorithm.ColGenStage, env::Coluna.Env{…}, ip_primal_sol::Coluna.Algorithm.GlobalPrimalBoundHandler, stab::Coluna.Algorithm.NoColGenStab; iter::Int64)
    @ Coluna.ColGen ~/.julia/packages/Coluna/TvRgV/src/ColGen/ColGen.jl:77
  [7] run!(context::Coluna.Algorithm.ColGenPrinterContext, env::Coluna.Env{Coluna.MathProg.VarId}, ip_primal_sol::Coluna.Algorithm.GlobalPrimalBoundHandler; iter::Int64)
    @ Coluna.ColGen ~/.julia/packages/Coluna/TvRgV/src/ColGen/ColGen.jl:46
  [8] run!
    @ ~/.julia/packages/Coluna/TvRgV/src/ColGen/ColGen.jl:35 [inlined]
  [9] run!(algo::Coluna.Algorithm.ColumnGeneration, env::Coluna.Env{Coluna.MathProg.VarId}, reform::Coluna.MathProg.Reformulation{Coluna.MathProg.DwMaster}, input::Coluna.Algorithm.ConquerInputFromBaB)
    @ Coluna.Algorithm ~/.julia/packages/Coluna/TvRgV/src/Algorithm/colgen.jl:252
 [10] run_colgen!
    @ ~/.julia/packages/Coluna/TvRgV/src/Algorithm/conquer.jl:174 [inlined]
 [11] run_colcutgen!(ctx::Coluna.Algorithm.ColCutGenContext, env::Coluna.Env{…}, reform::Coluna.MathProg.Reformulation{…}, input::Coluna.Algorithm.ConquerInputFromBaB, conquer_output::Coluna.Algorithm.OptimizationState{…})
    @ Coluna.Algorithm ~/.julia/packages/Coluna/TvRgV/src/Algorithm/conquer.jl:210
 [12] run_colcutgen_conquer!(ctx::Coluna.Algorithm.ColCutGenContext, env::Coluna.Env{Coluna.MathProg.VarId}, reform::Coluna.MathProg.Reformulation{Coluna.MathProg.DwMaster}, input::Coluna.Algorithm.ConquerInputFromBaB)
    @ Coluna.Algorithm ~/.julia/packages/Coluna/TvRgV/src/Algorithm/conquer.jl:353
 [13] run!(algo::Coluna.Algorithm.ColCutGenConquer, env::Coluna.Env{Coluna.MathProg.VarId}, reform::Coluna.MathProg.Reformulation{Coluna.MathProg.DwMaster}, input::Coluna.Algorithm.ConquerInputFromBaB)
    @ Coluna.Algorithm ~/.julia/packages/Coluna/TvRgV/src/Algorithm/conquer.jl:382
 [14] children(space::Coluna.Algorithm.BaBSearchSpace, current::Coluna.Algorithm.Node, env::Coluna.Env{Coluna.MathProg.VarId}, untreated_nodes::Base.Generator{DataStructures.Stack{Coluna.Algorithm.PrintedNode{Coluna.Algorithm.Node}}, typeof(Coluna.Algorithm._inner_node)})
    @ Coluna.Algorithm ~/.julia/packages/Coluna/TvRgV/src/Algorithm/treesearch.jl:173
 [15] children
    @ ~/.julia/packages/Coluna/TvRgV/src/Algorithm/treesearch/printer.jl:88 [inlined]
 [16] tree_search(::Coluna.TreeSearch.DepthFirstStrategy, space::Coluna.Algorithm.PrinterSearchSpace{…}, env::Coluna.Env{…}, input::Coluna.Algorithm.OptimizationState{…})
    @ Coluna.TreeSearch ~/.julia/packages/Coluna/TvRgV/src/TreeSearch/explore.jl:24
 [17] run!(algo::Coluna.Algorithm.TreeSearchAlgorithm, env::Coluna.Env{Coluna.MathProg.VarId}, reform::Coluna.MathProg.Reformulation{Coluna.MathProg.DwMaster}, input::Coluna.Algorithm.OptimizationState{Coluna.MathProg.Formulation{Coluna.MathProg.DwMaster}})
    @ Coluna.Algorithm ~/.julia/packages/Coluna/TvRgV/src/Algorithm/treesearch.jl:89
 [18] optimize!(reform::Coluna.MathProg.Reformulation{Coluna.MathProg.DwMaster}, env::Coluna.Env{Coluna.MathProg.VarId}, initial_primal_bound::Coluna.ColunaBase.Bound, initial_dual_bound::Coluna.ColunaBase.Bound, initial_columns::Nothing)
    @ Coluna ~/.julia/packages/Coluna/TvRgV/src/optimize.jl:90
 [19] macro expansion
    @ ~/.julia/packages/Coluna/TvRgV/src/optimize.jl:54 [inlined]
 [20] macro expansion
    @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:237 [inlined]
 [21] optimize!(env::Coluna.Env{Coluna.MathProg.VarId}, prob::Coluna.MathProg.Problem, annotations::Coluna.Annotations)
    @ Coluna ~/.julia/packages/Coluna/TvRgV/src/optimize.jl:53
 [22] optimize!(model::Coluna.Optimizer)
    @ Coluna ~/.julia/packages/Coluna/TvRgV/src/MOIwrapper.jl:203
 [23] optimize!(model::JuMP.Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})
    @ JuMP ~/.julia/packages/JuMP/027Gt/src/optimizer_interface.jl:448
 [24] optimize!
    @ ~/.julia/packages/JuMP/027Gt/src/optimizer_interface.jl:409 [inlined]
 [25] optimize!(m::JuMP.Model)
    @ BlockDecomposition ~/.julia/packages/BlockDecomposition/xVj1Y/src/BlockDecomposition.jl:77
 [26] optimize!(model::JuMP.Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})
    @ JuMP ~/.julia/packages/JuMP/027Gt/src/optimizer_interface.jl:437
 [27] optimize!
    @ ~/.julia/packages/JuMP/027Gt/src/optimizer_interface.jl:409 [inlined]
 [28] optimize_getresults(data_sites::DataFrames.DataFrame, data_SPOT::DataFrames.DataFrame, data_PME::DataFrames.DataFrame, pars::EtudeDTSI_Julien.Params)
    @ EtudeDTSI_Julien /raid/home/julien/post-doc/Codes/EtudeDTSI/EtudeDTSI_Julien/src/model_optimize.jl:116
 [29] main(; fileSites::String, fileSPOT::String, filePME::String, NbOfCurtailments2Perform::Int64, NbOfSites2Consider::Int64, powerContractualized::Int64, NbMaxBatUses::Dict{String, Int64}, colReward2consider::Symbol, curtailmentDuration::Int64, min_autonomy::Int64, use_SPOT::Bool)
    @ EtudeDTSI_Julien /raid/home/julien/post-doc/Codes/EtudeDTSI/EtudeDTSI_Julien/src/EtudeDTSI_Julien.jl:32
 [30] top-level scope
    @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

Expected behavior
When lauching a BlockModel with coluna:

                set_sites        = 1:10000
                set_curtailments = 1:170
                model = BlockModel(coluna; direct_model = true)
                @axis(C_axis, set_curtailments)
                @info "Creating variables..."
                @variable(model, x[s in set_sites, c in C_axis],Bin)
                @variable(model, y[c in C_axis],Bin)
                @variable(model, z[s in set_sites, c in C_axis],Bin)
                @info "Creating objective function..."
                @objective(model, Max,
                sum(y[c]*data_PME[set_curtailments[c],column_reward]*pars.powerContractualized for c in C_axis) + 
                sum(sum(z[s,c]*data_sites[s, 2]*(data_PME.SPOT_prices[set_curtailments[c]] - 
                data_PME[set_curtailments[c],:spot_recharge]) for s in set_sites) for c in C_axis)
                )
                @info "Creating Linearization constraints... [1/3]"
                @constraint(model, linearization_yx_1[s = set_sites, c = C_axis], z[s,c] <= x[s,c])
                @info "Creating Linearization constraints... [2/3]"
                @constraint(model, linearization_yx_2[s = set_sites, c = C_axis], z[s,c] <= y[c])
                @info "Creating Linearization constraints... [3/3]"
                @constraint(model, linearization_yx_3[s = set_sites, c = C_axis], z[s,c] >= x[s,c] + y[c] - 1)
                @show objective_function(model)
                @info "Starting Dantzig_Wolfe decomposition..."
                @dantzig_wolfe_decomposition(model, decomposition, C_axis)
                master = getmaster(decomposition)
                subproblems = getsubproblems(decomposition)
                specify!.(subproblems, lower_multiplicity = 0, upper_multiplicity = 1)
                getsubproblems(decomposition)
                optimize!(model)

All dataframe values, Data_PME, powerContractualized etc. can be replaced by numercal values powerContractualized = 21000 etc.

Environment (please complete the following information):

  • Julia version 1.10
  • OS: Linux
    [6cde8614] BlockDecomposition v1.15.0
    [a076750e] CPLEX v1.0.2
    [88b4ec78] Coluna v0.7.0
    [4076af6c] JuMP v1.18.1

Additional context

@jkhamphousone jkhamphousone added the bug Something isn't working label Jan 24, 2024
@rrsadykov
Copy link
Collaborator

Thank you for reporting the bug. We are aware of it, as it is related to #1118. We are working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants