Skip to content

Commit a5c6d6e

Browse files
committed
use .ext dictionary to store object dict
1 parent 7a8aebf commit a5c6d6e

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ When a disjunction is defined using the `@disjunction` macro, the disjunctions a
3535

3636
For empty disjuncts, use `nothing` for their positional argument (e.g., `@disjunction(m, x <= 1, nothing, reformulation = :big_m)`).
3737

38-
NOTE: `:gdp_variable_refs` are forbidden JuMP model object names when using *DisjunctiveProgramming.jl*. They are used to store the variable names and variable references in the original model.
38+
NOTE: `:object_dict` is used in the extension dictionary to store the object dictionary of models using *DisjunctiveProgramming.jl*.
3939

4040
## Logical Propositions
4141

src/constraint.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function check_constraint!(m::Model, constr::ConstraintRef)
4444
constr_name = gen_constraint_name(constr)
4545
delete_constraint!(m, constr, constr_name)
4646
m[constr_name] = new_constr
47-
m[:original_object_dict][constr_name] = new_constr
47+
m.ext[:object_dict][constr_name] = new_constr
4848
end
4949
return new_constr
5050
end
@@ -67,7 +67,7 @@ function check_constraint!(m::Model, constr::AbstractArray{<:ConstraintRef})
6767
constr_name = gen_constraint_name(constr)
6868
delete_constraint!.(m, constr, constr_name)
6969
m[constr_name] = new_constr
70-
m[:original_object_dict][constr_name] = new_constr
70+
m.ext[:object_dict][constr_name] = new_constr
7171
end
7272
return new_constr
7373
end

src/reformulate.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ Reformulate disjunction on a JuMP model.
88
Reformulate disjunction.
99
"""
1010
function reformulate_disjunction(m::Model, disj...; bin_var, reformulation, param)
11-
#get original variable refs and variable names
12-
vars = setdiff(all_variables(m), m[bin_var])
13-
if !in(:gdp_variable_refs, keys(object_dictionary(m)))
14-
@expression(m, gdp_variable_refs, vars)
15-
end
16-
@expression(m, original_object_dict, object_dictionary(m))
11+
m.ext[:object_dict] = copy(object_dictionary(m))
1712
#check disj
1813
disj = [check_constraint!(m, constr) for constr in disj]#check_disjunction!(m, disj)
1914
#run reformulation

src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ function gen_constraint_name(constr::ConstraintRef)
7171
return Symbol(constr_name)
7272
end
7373
function gen_constraint_name(constr::NonlinearConstraintRef)
74-
constr_name = findfirst(==(constr), constr.model[:original_object_dict])
74+
constr_name = findfirst(==(constr), constr.model.ext[:object_dict])
7575
if isnothing(constr_name)
7676
constr_name = gensym("constraint")
7777
end
7878

7979
return Symbol(constr_name)
8080
end
8181
function gen_constraint_name(constr::AbstractArray{<:NonlinearConstraintRef})
82-
constr_name = findfirst(==(constr), first(constr).model[:original_object_dict])
82+
constr_name = findfirst(==(constr), first(constr).model.ext[:object_dict])
8383
if isnothing(constr_name)
8484
constr_name = gensym("constraint")
8585
end

0 commit comments

Comments
 (0)