Skip to content

Commit

Permalink
update dependent package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kibaekkim committed Apr 8, 2022
1 parent 8fc76f5 commit 90a4634
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 27 deletions.
10 changes: 5 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StructJuMP"
uuid = "34f15cae-5318-50c9-93d3-9feadd34e321"
repo = "https://github.com/StructJuMP/StructJuMP.jl.git"
version = "0.2.0"
version = "0.3.0"

[deps]
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Expand All @@ -10,10 +10,10 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
ParameterJuMP = "774612a8-9878-5177-865a-ca53ae2495f9"

[compat]
JuMP = "0.21.3"
MathOptInterface = "0.9.14"
ParameterJuMP = "0.2"
julia = "1"
JuMP = "0.23, 1"
MathOptInterface = "1"
ParameterJuMP = "0.4.1"
julia = "1.6"

[extras]
ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199"
Expand Down
2 changes: 1 addition & 1 deletion examples/parmodel1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ firststage = StructuredModel()
@constraint(firststage, x[1] * x[2] == 10)

for scen in 1:2
bl = StructuredModel(parent=firststage, id=scen)
local bl = StructuredModel(parent=firststage, id=scen)
@variable(bl, y)
@constraint(bl, x[2]^2 + x[1]*y 5)
@objective(bl, Min, (x[1]+x[2])*y)
Expand Down
2 changes: 1 addition & 1 deletion examples/parmodel2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ firststage = StructuredModel()
@objective(firststage, Min, x[1]^2 + x[2]^2)

for scen in 1:2
bl = StructuredModel(parent=firststage, id=scen)
local bl = StructuredModel(parent=firststage, id=scen)
@variable(bl, y[1:2])
@constraint(bl, x[3-scen] + sum(y) 0)
@constraint(bl, x[3-scen] + sum(y) 50)
Expand Down
2 changes: 1 addition & 1 deletion examples/parmodel3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ firststage = StructuredModel()
@objective(firststage, Min, x[1]^2 + x[2]^2 + x[1]*x[2])

for scen in 1:2
bl = StructuredModel(parent=firststage, id=scen)
local bl = StructuredModel(parent=firststage, id=scen)
@variable(bl, y[1:2])
@constraint(bl, x[3-scen] + sum(y) 0)
@constraint(bl, x[3-scen] + sum(y) 50)
Expand Down
2 changes: 1 addition & 1 deletion examples/parmodel4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ firststage = StructuredModel()
@objective(firststage, Min, x[1]^2 + x[2]^2 + x[1]*x[2])

for scen in 1:100
bl = StructuredModel(parent=firststage, id=scen)
local bl = StructuredModel(parent=firststage, id=scen)
@variable(bl, y[1:2])
idx = (isodd(scen) ? 1 : 2)
@constraint(bl, x[idx] + sum(y) 0)
Expand Down
2 changes: 1 addition & 1 deletion examples/transportation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ for i in factories
end

for (s, elem) in enumerate(scenarios)
bl = StructuredModel(parent=m, id=s)
local bl = StructuredModel(parent=m, id=s)
@variable(bl, 0 <= salesw[i=centers] <= demand[i,s])
@variable(bl, wastew[centers] >= 0)
@objective(bl, Max, sum(price*prob[s]*salesw[j] for j=centers) - sum(wastecost*prob[s]*wastew[j] for j=centers))
Expand Down
6 changes: 1 addition & 5 deletions src/BendersBridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ struct ParametrizedModel
θ::Dict{Int, JuMP.VariableRef}
end
function ParametrizedModel(structured_model::StructuredModel, args...; kwargs...)
if structured_model.parent === nothing
model = Model(args...; kwargs...)
else
model = ModelWithParams(args...; kwargs...)
end
model = Model(args...; kwargs...)
variable_map = Dict{Int, JuMP.VariableRef}()
for (index, var) in structured_model.variables
name = structured_model.varnames[index]
Expand Down
4 changes: 2 additions & 2 deletions src/Benders_pmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function set_parent_solution!(model::ParametrizedModel, parent::ParametrizedMode
for (index, parameter) in model.parameter_map
vref = parent.variable_map[index]
value = parent_solution.variable_value[vref]
JuMP.fix(parameter, value)
JuMP.set_value(parameter, value)
end
end

Expand All @@ -66,7 +66,7 @@ function add_cutting_planes(master_model, master_solution, sub_models, sub_solut
if sol.feasible
JuMP.add_to_expression!(aff, -1.0, master_model.θ[id])
# Check if the cut is useful
if JuMP.value(aff, vref -> master_solution.variable_value[vref]) - TOL < 0
if JuMP.value(vref -> master_solution.variable_value[vref], aff) - TOL < 0
continue
end
else
Expand Down
2 changes: 0 additions & 2 deletions src/StructJuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ 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
JuMP.isequal_canonical(v::StructuredVariableRef, w::StructuredVariableRef) = v == w
JuMP.variable_type(::StructuredModel) = StructuredVariableRef
function JuMP.add_variable(m::StructuredModel, v::JuMP.AbstractVariable, name::String="")
m.nextvaridx += 1
vref = StructuredVariableRef(m, m.nextvaridx)
Expand Down Expand Up @@ -231,7 +230,6 @@ struct StructuredConstraintRef
model::StructuredModel # `model` owning the constraint
idx::Int # Index in `model.constraints`
end
JuMP.constraint_type(::StructuredModel) = StructuredConstraintRef
function JuMP.add_constraint(m::StructuredModel, c::JuMP.AbstractConstraint, name::String="")
m.nextconidx += 1
cref = StructuredConstraintRef(m, m.nextconidx)
Expand Down
10 changes: 2 additions & 8 deletions test/printhook.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ Subject to
x + y = 1.0
"""
@test sprint(show, parent) == """
A JuMP Model
An Abstract JuMP Model
Minimization problem with:
Variables: 2
Objective function type: GenericQuadExpr{Float64,StructJuMP.StructuredVariableRef}
Objective function type: GenericQuadExpr{Float64, StructJuMP.StructuredVariableRef}
Constraint: 1
Names registered in the model: x, y"""
@test sprint(show, "text/latex", parent) == """
\$\$ \\begin{alignat*}{1}\\min\\quad & x^2 + y\\\\
\\text{Subject to} \\quad & x + y = 1.0\\\\
\\end{alignat*}
\$\$"""
#@test occursin("Child", str)
end

0 comments on commit 90a4634

Please sign in to comment.