API
This section documents the ApplicationDrivenLearning API.
Constructors
ApplicationDrivenLearning.Model — Type
Model <: JuMP.AbstractModelCreate an empty ApplicationDrivenLearning.Model with empty plan and assess models, missing forecast model and default settings.
ApplicationDrivenLearning.PredictiveModel — Type
PredictiveModel(networks, input_output_map, input_size, output_size)Creates a predictive (forecast) model for the AppDrivenLearning module from Flux models and input/output information.
...
Arguments
networks: array of Flux models to be used.input_output_map::Union{Vector{<:Dict{Vector{Int},<:Vector{<:Forecast}}},Nothing}: array in the same ordering as networks of mappings from input indexes to output indexes on which the models should be applied.output_variables::Union{Vector{<:Forecast},Nothing}: array of output variables to be used.input_size::Int: size of the input vector.output_size::Int: size of the output vector. ...
Example
julia> pred_model = PredictiveModel(
[Flux.Dense(1 => 1), Flux.Dense(3 => 2)],
[
Dict([1] => [1], [1] => [2]),
Dict([1,2,3] => [3,4], [1,4,5] => [5,6])
],
5,
6
);ApplicationDrivenLearning.Plan — Function
Upper(model::ApplicationDrivenLearning.Model)Create a reference to the plan model of an application driven learning model.
ApplicationDrivenLearning.Assess — Function
Assess(model::ApplicationDrivenLearning.Model)Create a reference to the assess model of an application driven learning model.
JuMP variable types
ApplicationDrivenLearning.Policy — Type
Policy{T}Policy variable type that holds plan and assess variables.
ApplicationDrivenLearning.Forecast — Type
Forecast{T}Forecast variable type that holds plan and assess variables.
Structs
ApplicationDrivenLearning.Options — Type
Options(mode; params...)Options struct to hold optimization mode and mode parameters.
...
Example
options = Options(
GradientMode;
rule = Optim.RMSProp(0.01),
epochs = 100,
batch_size = 10,
)...
ApplicationDrivenLearning.Solution — Type
SolutionA struct to store the result of the optimisation process with final cost and solution.
Modes
ApplicationDrivenLearning.NelderMeadMode — Type
NelderMeadMode <: AbstractOptimizationModeUsed to solve the application driven learning training problem using the Nelder-Mead optimization method implementation from Optim.jl package.
...
Parameters
initial_simplexis the initial simplex of solutions to be applied.parametersis the parameters to be applied to the Nelder-Mead optimization method. ...
ApplicationDrivenLearning.GradientMode — Type
GradientMode <: AbstractOptimizationModeUsed to solve the application driven learning training problem using the gradient optimization method
...
Parameters
ruleis the optimiser object to be used in the gradient optimization process.- 'epochs' is the number of epochs to be used in the gradient optimization process.
- 'batch_size' is the batch size to be used in the gradient optimization process.
- 'verbose' is the flag of whether to print the training process.
- 'computecostevery' is the epoch frequency for computing the cost and evaluating best solution.
- 'time_limit' is the time limit for the training process. ...
ApplicationDrivenLearning.NelderMeadMPIMode — Type
NelderMeadMPIMode <: AbstractOptimizationModeMPI implementation of NelderMeadMode.
ApplicationDrivenLearning.GradientMPIMode — Type
GradientMPIMode <: AbstractOptimizationModeMPI implementation of GradientMode.
ApplicationDrivenLearning.BilevelMode — Type
BilevelMode <: AbstractOptimizationModeUsed to solve the application driven learning training problem as a bilevel optimization problem by using the BilevelJuMP.jl package.
...
Parameters
optimizer::Functionis equivalent tosolverin BilevelJuMP.BilevelModel.silent::Boolis equivalent tosilentin BilevelJuMP.BilevelModel.mode::Union{Nothing, BilevelJuMP.BilevelMode}is equivalent tomodein BilevelJuMP.BilevelModel. ...
Attributes getters and setters
ApplicationDrivenLearning.plan_policy_vars — Function
Returns vector of policy variables from plan model.
ApplicationDrivenLearning.assess_policy_vars — Function
Returns vector of policy variables from assess model.
ApplicationDrivenLearning.plan_forecast_vars — Function
Returns vector of forecast variables from plan model.
ApplicationDrivenLearning.assess_forecast_vars — Function
Returns vector of forecast variables from assess model.
ApplicationDrivenLearning.set_forecast_model — Function
Sets Chain, Dense or custom PredictiveModel object as forecast model.
ApplicationDrivenLearning.extract_params — Function
extract_params(model)Extract the parameters of a PredictiveModel into a single vector.
ApplicationDrivenLearning.apply_params — Function
apply_params(model, θ)Return model after fixing the parameters from an adequate vector of parameters.
Flux attributes getters and setters
ApplicationDrivenLearning.extract_flux_params — Function
extract_flux_params(model)Extract the parameters of a Flux model (Flux.Chain or Flux.Dense) into a single vector.
ApplicationDrivenLearning.fix_flux_params_single_model — Function
fix_flux_params_single_model(model, θ)Return model after fixing the parameters from an adequate vector of parameters.
ApplicationDrivenLearning.fix_flux_params_multi_model — Function
fix_flux_params_multi_model(models, θ)Return iterable of models after fixing the parameters from an adequate vector of parameters.
ApplicationDrivenLearning.has_params — Function
has_params(layer)Check if a Flux layer has parameters.
ApplicationDrivenLearning.apply_gradient! — Function
apply_gradient!(model, dCdy, X, rule)Apply a gradient vector to the model parameters.
...
Arguments
model::PredictiveModel: model to be updated.dCdy::Vector{<:Real}: gradient vector.X::Matrix{<:Real}: input data.rule: Optimisation rule. ...
Other functions
ApplicationDrivenLearning.compute_cost — Function
compute_cost(model, X, Y, with_gradients=false)Compute the cost function (C) based on the model predictions and the true values matrix.
...
Arguments
model::ApplicationDrivenLearning.Model: model to evaluate.X::Matrix{<:Real}: input data.Y::Matrix{<:Real}: true values.with_gradients::Bool=false: flag to compute and return gradients. ...
ApplicationDrivenLearning.train! — Function
train!(model, X, y, options)Train model using given data and options.
ApplicationDrivenLearning.build_plan_model_forecast_params — Function
Creates new forecast variables to plan model using MOI.Parameter and new constraint fixing to original forecast variables.
ApplicationDrivenLearning.build_assess_model_policy_constraint — Function
Creates new constraint to assess model that fixes policy variables.
ApplicationDrivenLearning.build — Function
Calls functions that set new variables and constraints that are necessary to cost computation.