Model
Index
SLiDE.fix!
SLiDE.fix_lower_bound!
SLiDE.lower_bound
SLiDE.set_bounds!
SLiDE.set_lower_bound!
SLiDE.set_upper_bound!
SLiDE.upper_bound
SLiDE.zero_negative!
Functions
These functions were developed to set and update JuMP.Model
variables.
SLiDE.set_lower_bound!
— Functionset_lower_bound!(model::JuMP.Model, var, idx; kwargs...)
This function sets a JuMP Model variable's lower bound as calculated by SLiDE.lower_bound
.
Arguments
model::JuMP.Model
to updatevar::Symbol
orvar::AbstractArray
: variable or list of variables to updateidx::Symbol
,idx::Tuple
, oridx::AbstractArray
: index or list of indices overwhich to set bounds.
Keyword Arguments
Consistent with SLiDE.lower_bound
SLiDE.lower_bound
— Functionlower_bound(x::Real; kwargs...)
This function calculates a lower bound on x
:
\[x_{lower} = \begin{cases} \max\left\{0,\, factor \cdot x \right\} & \texttt{allow_negative} \ factor \cdot x & \texttt{!allow_negative} \end{cases}\]
Arguments
x::Real
reference value to calculate lower bound
Keyword Arguments
factor::Real=0
to use to calculate lower bound.value::Real=NaN
: If a value is given, set lower bound to this value.allow_negative::Bool=true
: Do we want to set negative values to zero?
Returns
x::Real
: calculted lower bound
SLiDE.set_upper_bound!
— Functionset_upper_bound!(model::JuMP.Model, var, idx; kwargs...)
This function sets a JuMP Model variable's upper bound as calculated by SLiDE.upper_bound
.
Arguments
model::JuMP.Model
to updatevar::Symbol
orvar::AbstractArray
: variable or list of variables to updateidx::Symbol
,idx::Tuple
, oridx::AbstractArray
: index or list of indices overwhich to set bounds.
Keyword Arguments
Consistent with SLiDE.upper_bound
SLiDE.upper_bound
— Functionupper_bound(x::Real; kwargs...)
This function returns an upper bound on x
:
\[x_{upper} = \begin{cases} \abs\left\{factor \cdot x \right\} & \texttt{allow_negative} \ factor \cdot x & \texttt{!allow_negative} \end{cases}\]
Arguments
x::Real
reference value to calculate upper bound
Keyword Arguments
factor::Real=0
to use to calculate upper bound.value::Real=NaN
: If a value is given, set upper bound to this value.allow_negative::Bool=true
: Do we want to make negative values positive?
Returns
x::Real
: calculted upper bound
SLiDE.set_bounds!
— Functionset_bounds!(model::JuMP.Model, var, idx; kwargs...)
This function sets upper and lower bound on the specified JuMP Model variable(s).
Arguments
model::JuMP.Model
to updatevar::Symbol
orvar::AbstractArray
: variable or list of variables to updateidx::Symbol
,idx::Tuple
, oridx::AbstractArray
: index or list of indices overwhich to set bounds.
Keyword Arguments
lower_factor::Real=0
: passed toSLiDE.lower_bound
asfactor
upper_factor::Real=0
: passed toSLiDE.upper_bound
asfactor
allow_negative::Bool=true
: passed toSLiDE.lower_bound
andSLiDE.upper_bound
SLiDE.fix!
— Functionfix!(model::JuMP.Model, var, idx; kwargs...)
This function fixes a model variable model[var][idx]
if its start value meets a specified condition.
Arguments
model::JuMP.Model
to updatevar::Symbol
orvar::AbstractArray
: variable or list of variables to updateidx::Symbol
,idx::Tuple
, oridx::AbstractArray
: index or list of indices overwhich to set bounds.
Keyword Arguments
values::Real=NaN
, to which to fix the JuMP Variable if it meets the condition. Ifvalue==NaN
, as is specified by default, fix the variable based on its start value.condition::Function=isreal
, that determines whether to fix the value. By default, all Real-valued start values will be fixed. If, for instance,condition=iszero
, is given, all variables with start values of zero will be fixed to zero. Non-zero values will not be fixed.force::true
, passed to JuMP.fix
SLiDE.fix_lower_bound!
— Functionfix_lower_bound!(model::JuMP.Model, var, idx; kwargs...)
This function fixes a model variable model[var][idx]
if its start value meets a specified condition using SLiDE.fix!
, OR sets its lower bound using SLiDE.set_lower_bound!
.
Arguments
model::JuMP.Model
to updatevar::Symbol
orvar::AbstractArray
: variable or list of variables to updateidx::Symbol
,idx::Tuple
, oridx::AbstractArray
: index or list of indices overwhich to set bounds.
Keyword Arguments
See [SLiDE.fix!
] and [SLiDE.lower_bound
]
SLiDE.zero_negative!
— FunctionThis function sets negative values to zero.
Arguments
zero_negative!(d)
zero_negative!(d, var)
d::Dict{Symbol,DataFrame}
to editvar::Symbol
orvar::AbstractArray
: variable or list of variables to editzeronegative!(df) zeronegative!(df, subset)df::DataFrame
to editsubset::Pair
: If given, only zero negative values for thisidx => value
pair.
Returns
df::DataFrame
ord::Dict{Symbol,DataFrame}
with negative values set to zero.