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

Discourage Finite Models #151

Merged
merged 2 commits into from
Jun 21, 2021
Merged

Discourage Finite Models #151

merged 2 commits into from
Jun 21, 2021

Conversation

pulsipher
Copy link
Collaborator

Before the support check at transcription errored with finite models:

m = InfiniteModel()
@variable(m, y >= 0)
build_optimizer_model!(m)
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
  [1] _empty_reduce_error()
    @ Base .\reduce.jl:299
  [2] mapreduce_empty(f::Function, op::Base.BottomRF{typeof(Base.mul_prod)}, T::Type)
    @ Base .\reduce.jl:342
  [3] reduce_empty(op::Base.MappingRF{typeof(length), Base.BottomRF{typeof(Base.mul_prod)}}, #unused#::Type{Union{}})
    @ Base .\reduce.jl:329
  [4] reduce_empty_iter
    @ .\reduce.jl:355 [inlined]
  [5] reduce_empty_iter
    @ .\reduce.jl:354 [inlined]
  [6] foldl_impl(op::Base.MappingRF{typeof(length), Base.BottomRF{typeof(Base.mul_prod)}}, nt::Base._InitialValue, itr::Tuple{})
    @ Base .\reduce.jl:49
  [7] mapfoldl_impl(f::typeof(length), op::typeof(Base.mul_prod), nt::Base._InitialValue, itr::Tuple{})
    @ Base .\reduce.jl:44
  [8] mapfoldl(f::Function, op::Function, itr::Tuple{}; init::Base._InitialValue)
    @ Base .\reduce.jl:160
  [9] mapfoldl
    @ .\reduce.jl:160 [inlined]
 [10] #mapreduce#218
    @ .\reduce.jl:287 [inlined]
 [11] mapreduce
    @ .\reduce.jl:287 [inlined]
 [12] #prod#224
    @ .\reduce.jl:555 [inlined]
 [13] prod(f::Function, a::Tuple{})
    @ Base .\reduce.jl:555
 [14] build_transcription_model!(trans_model::Model, inf_model::InfiniteModel; check_support_dims::Bool)
    @ InfiniteOpt.TranscriptionOpt ~\src\TranscriptionOpt\transcribe.jl:875
 [15] #build_optimizer_model!#95
    @ ~\src\TranscriptionOpt\optimize.jl:34 [inlined]
 [16] build_optimizer_model!
    @ ~\src\TranscriptionOpt\optimize.jl:32 [inlined]
 [17] build_optimizer_model!(model::InfiniteModel; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ~\InfiniteOpt\8U5IK\src\optimize.jl:525
 [18] build_optimizer_model!
    @ ~\InfiniteOpt\8U5IK\src\optimize.jl:524 [inlined]
 [19] #optimize!#386
    @ ~\InfiniteOpt\8U5IK\src\optimize.jl:921 [inlined]
 [20] optimize!(model::InfiniteModel)
    @ ~\InfiniteOpt\8U5IK\src\optimize.jl:920
 [21] top-level scope
    @ REPL[107]:1

Now we have the following warning and it works (also added docs to discourage doing so):

m = InfiniteModel()
@variable(m, y >= 0)
build_optimizer_model!(m)
┌ Warning: Finite models (i.e., `InfiniteModel`s with no infinite parameters) should be modeled directly via a `Model` in JuMP.jl.
└ @ InfiniteOpt ~\InfiniteOpt\src\optimize.jl:525

@pulsipher pulsipher added this to the v0.4.1 milestone Jun 21, 2021
@pulsipher pulsipher added bug Something isn't working documentation Improvements or additions to documentation labels Jun 21, 2021
@codecov
Copy link

codecov bot commented Jun 21, 2021

Codecov Report

Merging #151 (c72321f) into master (604c41c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #151   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          32       32           
  Lines        6183     6185    +2     
=======================================
+ Hits         6181     6183    +2     
  Misses          2        2           
Impacted Files Coverage Δ
src/TranscriptionOpt/transcribe.jl 99.69% <100.00%> (ø)
src/optimize.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 604c41c...c72321f. Read the comment docs.

@pulsipher pulsipher merged commit a275ada into master Jun 21, 2021
@pulsipher pulsipher deleted the finite_models branch June 21, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant