Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hdavid16 committed Mar 10, 2022
2 parents df940fc + daefad6 commit d261d77
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/reformulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ function apply_interval_arithmetic(ref)
interval_map = Dict()
vars = all_variables(ref.model) #get all variable names
for var in vars
ub = has_upper_bound(var) ? upper_bound(var) : (is_binary(var) ? 1 : Inf)
lb = has_lower_bound(var) ? lower_bound(var) : (is_binary(var) ? 0 : Inf)
interval_map[string(var)] = lb..ub
@assert !is_binary(var) && !is_integer(var) "GDP does not allow mixed-integer or integer constraints inside the disjuncts."
UB = has_upper_bound(var) ? upper_bound(var) : Inf
LB = has_lower_bound(var) ? lower_bound(var) : -Inf
interval_map[string(var)] = LB..UB
end
ref_func_expr = replace_vars!(ref_func_expr, interval_map)
#get bounds on the entire expression
Expand Down Expand Up @@ -161,17 +162,16 @@ function CHR!(m, constr, bin_var, i, k, eps)
bin_var_ref = variable_by_name(ref.model, "$bin_var[$i]")
for var in m[:original_model_variables]
#get bounds for disaggregated variable
@assert has_upper_bound(var) || is_binary(var) "Variable $var does not have an upper bound."
# @assert has_lower_bound(var) || is_binary(var) "Variable $var does not have a lower bound."
UB = is_binary(var) ? 1 : upper_bound(var)
@assert !is_binary(var) && !is_integer(var) "GDP does not allow mixed-integer or integer constraints inside the disjuncts."
@assert has_upper_bound(var) "Variable $var does not have an upper bound."
UB = upper_bound(var)
LB = has_lower_bound(var) ? lower_bound(var) : 0 #set lower bound for disaggregated variable to 0 if binary or no lower bound given
#create disaggregated variable
var_i = Symbol("$(var)_$i")
if !(var_i in keys(object_dictionary(m)))
eval(:(@variable($m, $LB <= $var_i <= $UB)))
eval(:(@constraint($m, $LB * $bin_var_ref <= $var_i)))
eval(:(@constraint($m, $var_i <= $UB * $bin_var_ref)))
is_binary(var) && set_binary(m[var_i])
end
end
#create convex hull constraint
Expand Down

3 comments on commit d261d77

@hdavid16
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegister register

@hdavid16
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/56354

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" d261d77768110df1568096677e56198d82bedc09
git push origin v0.1.3

Please sign in to comment.