Helper functions
Work in progress...
Main.OCTHaGOn.deconstruct
— Functiondeconstruct(data::DataFrame, vars::Array, varmap::Array)
Takes in data for input into a Function, and rips it apart into appropriate arrays.
Main.OCTHaGOn.data_to_DataFrame
— Functiondata_to_DataFrame(data::Union{Dict, DataFrame, DataFrameRow})
Gets data with different keys, and returns a DataFrame with string headers.
Main.OCTHaGOn.get_datamap
— FunctionReturns the mapping from flattened expr_vars to vars.
Main.OCTHaGOn.get_param
— Functionget_param(gm::Dict, key::Symbol) -> Any
Returns the value of a parameter.
Main.OCTHaGOn.get_varmap
— Functionget_varmap(expr_vars::Array, vars::Array)
Helper function to map vars to flatvars. Arguments: flatvars is a flattened Array{JuMP.VariableRef} vars is the unflattened version, usually derived from an Expr. Returns: Dict of ID maps
Main.OCTHaGOn.get_var_ranges
— FunctionReturns the relevant index ranges for variables in expr_vars.
Main.OCTHaGOn.gradientify
— Functiongradientify(expr::Expr, expr_vars::Array)
gradientify(expr::JuMP.ConstraintRef, expr_vars::Array)
Turns an expression into a gradient-able (via ForwardDiff), flattened function. TODO: add option to not use gradients for certain functions or data driven constraints.
Main.OCTHaGOn.functionify
— Functionfunctionify(constraint::Any) -> Union{Nothing, Function}
Returns an "evaluate-able" function from an Expr, or nothing for a JuMP.ConstraintRef. Can extend in the future to other elements.
Main.OCTHaGOn.merge_kwargs
— FunctionHelper function for merging learner arguments.
Main.OCTHaGOn.set_param
— Functionset_param(gm::Dict, key::Symbol, val::Any)
set_param(gm::Dict, key::Symbol, val::Any, checks::Any)
Sets the value of a parameter.
Main.OCTHaGOn.substitute
— FunctionFor substitution into expressions. IMPORTANT.
Main.OCTHaGOn.vars_from_expr
— Functionvars_from_expr(expr::Expression, model::JuMP.Model)
Returns the JuMP Variables that are associated with a given expression. Note: Expr's must be defined with a single input or a tuple of inputs, eg:
ex = :(x -> 5*x)
ex = :((x, y, z) -> sum(x[i] for i=1:4) - y[1] * y[2] + z)