We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
using JuMP, Clp, LinearAlgebra solver = Clp.Optimizer # Nutrition guidelines numCategories = 4 categories = ["calories", "protein", "fat", "sodium"] minNutrition = [1800, 91, 0, 0] maxNutrition = [2200, Inf, 65, 1779] # Foods numFoods = 9 foods = ["hamburger", "chicken", "hot dog", "fries", "macaroni", "pizza", "salad", "milk", "ice cream"] cost = [2.49, 2.89, 1.50, 1.89, 2.09, 1.99, 2.49, 0.89, 1.59] nutritionValues = [410 24 26 730; 420 32 10 1190; 560 20 32 1800; 380 4 19 270; 320 12 10 930; 320 15 12 820; 320 31 12 1230; 100 8 2.5 125; 330 8 10 180] # Build model m = Model(with_optimizer(solver)) # Variables for nutrition info @variable(m, minNutrition[i] <= nutrition[i=1:numCategories] <= maxNutrition[i]) # Variables for which foods to buy @variable(m, buy[i=1:numFoods] >= 0) # Objective - minimize cost @objective(m, Min, dot(cost, buy)) # Nutrition constraints for j = 1:numCategories @constraint(m, sum(nutritionValues[i,j]*buy[i] for i=1:numFoods) == nutrition[j]) end @constraint(m, buy[8] + buy[9] <= 6) # Solve JuMP.optimize!(m)
The above code generates an error in Julia v1.0
Coin0506I Presolve 5 (0) rows, 9 (-4) columns and 38 (-4) elements Clp0006I 0 Obj 0 Primal inf 16.526772 (2) Clp0006I 5 Obj 11.828861 Primal inf 2.9401859 (2) Clp0006I 5 Obj 11.828861 Primal inf 2.9401859 (2) Clp0001I Primal infeasible - objective value 11.828861 Coin0505I Presolved problem not optimal, resolve after postsolve Coin0511I After Postsolve, objective 11.828861, infeasibilities - dual 0 (0), primal 3.5614582 (1) Clp0032I PrimalInfeasible objective 11.82886111 - 5 iterations time 0.002, Presolve 0.00 ERROR: MethodError: no method matching Array{Float64,N} where N(::Int64) Closest candidates are: Array{Float64,N} where N(::UndefInitializer, ::Int64) where T at boot.jl:408 Array{Float64,N} where N(::UndefInitializer, ::Int64, ::Int64) where T at boot.jl:409 Array{Float64,N} where N(::UndefInitializer, ::Int64, ::Int64, ::Int64) where T at boot.jl:410 ... Stacktrace: [1] infeasibility_ray(::Clp.ClpCInterface.ClpModel) at /Users/chkwon/.julia/packages/Clp/qWiux/src/ClpCInterface.jl:879 [2] get_farkas_dual!(::Clp.Optimizer, ::Array{Float64,1}) at /Users/chkwon/.julia/packages/Clp/qWiux/src/MOIWrapper.jl:305 [3] optimize!(::Clp.Optimizer) at /Users/chkwon/.julia/packages/LinQuadOptInterface/RY8jg/src/solve.jl:57 [4] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}}) at /Users/chkwon/.julia/packages/MathOptInterface/62rhX/src/Utilities/cachingoptimizer.jl:162 [5] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}},MathOptInterface.Bridges.AllBridgedConstraints{Float64}}) at /Users/chkwon/.julia/packages/MathOptInterface/62rhX/src/Bridges/bridgeoptimizer.jl:73 [6] #optimize!#94(::Bool, ::Function, ::Model, ::Nothing) at /Users/chkwon/.julia/packages/JuMP/LjMor/src/optimizer_interface.jl:65 [7] optimize! at /Users/chkwon/.julia/packages/JuMP/LjMor/src/optimizer_interface.jl:42 [inlined] (repeats 2 times) [8] top-level scope at none:0
When the same code is run at Julia v0.7:
┌ Warning: `Array{T}(m::Int) where T` is deprecated, use `Array{T}(undef, m)` instead. │ caller = infeasibility_ray(::Clp.ClpCInterface.ClpModel) at ClpCInterface.jl:879 └ @ Clp.ClpCInterface ~/.julia/packages/Clp/qWiux/src/ClpCInterface.jl:879
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
The above code generates an error in Julia v1.0
When the same code is run at Julia v0.7:
The text was updated successfully, but these errors were encountered: