Skip to content

Commit

Permalink
Merge pull request #66 from StructJuMP/bl/updates
Browse files Browse the repository at this point in the history
Updates to latest JuMP master
  • Loading branch information
blegat committed Dec 7, 2018
2 parents 7b711ae + 88a4257 commit 1a23f00
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
notifications:
Expand All @@ -16,6 +15,6 @@ addons:
- libgmp-dev
- libglpk-dev
before_script:
- julia -e 'if VERSION >= v"0.7-"; using Pkg; Pkg.add(PackageSpec(name="JuMP", rev="master")); Pkg.add(PackageSpec(url="https://github.com/JuliaStochOpt/ParameterJuMP.jl.git")); else Pkg.add("JuMP"); Pkg.checkout("JuMP"); Pkg.clone("https://github.com/JuliaStochOpt/ParameterJuMP.jl.git"); end'
- julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuMP", rev="master")); Pkg.add(PackageSpec(url="https://github.com/JuliaStochOpt/ParameterJuMP.jl.git"))'
after_success:
- julia -e 'cd(Pkg.dir("StructJuMP")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ i.e. JuMP v0.18.x, to try this package with JuMP v0.18, simply do
```
The development of this package for JuMP v0.18.x is done in the `release-0.1`
branch.
The `master` branch of this package works with the JuMP v0.19-alpha. To try this
package with JuMP v0.19-alpha, do:
The `master` branch of this package works with the JuMP development version. To
try this package with JuMP master, do:
```julia
] add JuMP#v0.19-alpha
] add JuMP#master
] add StructJuMP#master
```

Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
julia 0.6
julia 0.7
MathOptInterface 0.6
JuMP 0.18.2+
ParameterJuMP
Compat 0.70
6 changes: 3 additions & 3 deletions src/Benders_pmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function optimize(model::ParametrizedModel)
variable_value = Dict{JuMP.VariableRef, Float64}()
if feasible
for vref in values(model.variable_map)
variable_value[vref] = JuMP.result_value(vref)
variable_value[vref] = JuMP.value(vref)
end
for θ in values(model.θ)
variable_value[θ] = JuMP.result_value(θ)
variable_value[θ] = JuMP.value(θ)
end
end
parameter_dual = Dict{Parameter, Float64}()
for parameter in values(model.parameter_map)
parameter_dual[parameter] = JuMP.result_dual(parameter)
parameter_dual[parameter] = JuMP.dual(parameter)
end
Solution(feasible, objective_value, variable_value, parameter_dual)
end
Expand Down
10 changes: 3 additions & 7 deletions src/StructJuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module StructJuMP

export StructuredModel

using Compat

using MathOptInterface
const MOI = MathOptInterface

Expand All @@ -19,7 +17,7 @@ end

mutable struct StructuredModel <: JuMP.AbstractModel
# Structured data
parent::Union{StructuredModel, Compat.Nothing}
parent::Union{StructuredModel, Nothing}
children::Dict{Int, StructuredModel}
probability::Dict{Int, Float64}
num_scen::Int
Expand Down Expand Up @@ -74,7 +72,7 @@ getprobability(model::StructuredModel) = model.probability
num_scenarios(model::StructuredModel) = model.num_scen

default_probability(model::StructuredModel) = 1 / num_scenarios(model)
default_probability(::Compat.Nothing) = 1.0
default_probability(::Nothing) = 1.0

#### Model ####

Expand All @@ -85,9 +83,7 @@ struct StructuredVariableRef <: JuMP.AbstractVariableRef
model::StructuredModel # `model` owning the variable
idx::Int # Index in `model.variables`
end
if VERSION >= v"0.7-"
Base.broadcastable(v::StructuredVariableRef) = Ref(v)
end
Base.broadcastable(v::StructuredVariableRef) = Ref(v)
Base.copy(v::StructuredVariableRef) = v
Base.:(==)(v::StructuredVariableRef, w::StructuredVariableRef) = v.model === w.model && v.idx == w.idx
JuMP.owner_model(v::StructuredVariableRef) = v.model
Expand Down
3 changes: 1 addition & 2 deletions test/benderstest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ using StructJuMP

using ECOS
using GLPK
using Compat
using Compat.Test
using Test

#misocp_solver = CbcSolver()
misocp_solver = with_optimizer(GLPK.Optimizer)
Expand Down
2 changes: 1 addition & 1 deletion test/examples_smoketest.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Compat, Compat.Test
using Test


include("../examples/easy_test.jl")
Expand Down
3 changes: 1 addition & 2 deletions test/farmer.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Compat
using Compat.Test
using Test

using GLPK

Expand Down
3 changes: 1 addition & 2 deletions test/printhook.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Compat
using Compat.Test
using Test

using StructJuMP

Expand Down

0 comments on commit 1a23f00

Please sign in to comment.