Api
LearningToOptimize
LearningToOptimize.FullyConnectedLearningToOptimize.ProblemIteratorLearningToOptimize.RecorderLearningToOptimize._objective_valueLearningToOptimize.all_primal_variablesLearningToOptimize.box_samplerLearningToOptimize.feasibility_evaluatorLearningToOptimize.general_evaluatorLearningToOptimize.general_samplerLearningToOptimize.general_samplerLearningToOptimize.inconvexhullLearningToOptimize.line_samplerLearningToOptimize.load_parametersLearningToOptimize.load_parametersLearningToOptimize.make_convex!LearningToOptimize.make_convex!LearningToOptimize.model_outputsLearningToOptimize.model_outputsLearningToOptimize.objective_evaluatorLearningToOptimize.recordLearningToOptimize.recordLearningToOptimize.saveLearningToOptimize.scaled_distribution_samplerLearningToOptimize.solve_and_recordLearningToOptimize.solve_batchLearningToOptimize.update_model!LearningToOptimize.update_model!LearningToOptimize.variable_pointLearningToOptimize.variable_point
LearningToOptimize.FullyConnected — MethodFullyConnected(input_size::Int, hidden_sizes::Vector{Int}, output_size::Int)::FullyConnectedCreate a fully connected neural network with input_size inputs, hidden_sizes hidden layers and output_size outputs. Adds a pass through layer for each layer.
LearningToOptimize.ProblemIterator — TypeProblemIterator(ids::Vector{UUID}, pairs::Dict{VariableRef, Vector{Real}})Iterator for optimization problem instances.
LearningToOptimize.Recorder — TypeRecorder(filename; primal_variables=[], dual_variables=[], filterfn=(model)-> termination_status(model) == MOI.OPTIMAL)Recorder of optimization problem solutions.
LearningToOptimize._objective_value — Method_objective_value(model::JuMP.Model, point::Dict{VariableRef,Float64})Objective value of a solution over a JuMP model.
LearningToOptimize.all_primal_variables — Methodall_primal_variables(model::JuMP.Model)Returns all primal variables of a JuMP model.
LearningToOptimize.box_sampler — Methodfunction box_sampler(
original_parameter::VariableRef,
num_s::F;
rng::AbstractRNG=Random.GLOBAL_RNG,
max_multiplier::T=1.25,
min_multiplier::T=0.8,
) where {T<:Real,F<:Integer}Uniformly sample values around the original parameter value over a discrete range inside a box.
LearningToOptimize.feasibility_evaluator — Methodfeasibility_evaluator(problem_iterator::ProblemIterator, output)Feasibility evaluator of a solution over a ProblemIterator dataset. PS.: Probably can be made much more efficient.
LearningToOptimize.general_evaluator — Methodgeneral_evaluator(problem_iterator::ProblemIterator, model)General evaluator of a predictor model over a ProblemIterator dataset. Returns objective, feasibility, inference time and allocated memory.
LearningToOptimize.general_sampler — Methodfunction general_sampler(
original_parameters::Vector{VariableRef};
samplers::Vector{Function}=[
(original_parameters) -> scaled_distribution_sampler(original_parameters, 1000),
LearningToOptimize.line_sampler,
(original_parameters) -> box_sampler(original_parameters, 10),
]
)This function is a general sampler that uses a set of samplers to sample the parameter space.
LearningToOptimize.general_sampler — Methodgeneral_sampler(
file::AbstractString;
samplers::Vector{Function}=[
(original_parameters) -> scaled_distribution_sampler(original_parameters, 1000),
LearningToOptimize.line_sampler,
(original_parameters) -> box_sampler(original_parameters, 10),
],
batch_id::UUID=uuid1(),
save_file::AbstractString=split(file, ".mof.json")[1] * "_input_" * string(batch_id),
filetype::Type{T}=ArrowFile
) where {T<:FileType}This function is a general sampler that uses a set of samplers to sample the parameter space. It loads the underlying model from file and samples the parameters. It saves the sampled parameters to save_file.
LearningToOptimize.inconvexhull — Methodinconvexhull(training_set::Matrix{Float64}, test_set::Matrix{Float64}, solver; silent=true, tol=1e-4)Check if new points are inside the convex hull of the given points. Solves a linear programming problem to check if the points are inside the convex hull.
LearningToOptimize.line_sampler — Methodfunction line_sampler(
original_parameters::Vector{T},
parameter_indexes::Vector{F},
range_p::AbstractVector{T},
) where {T<:Real,F<:Integer}This sampler returns a set of parameters that for a line in one dimension of the parameter space. The idea is to change the value of one parameter and keep the rest constant.
LearningToOptimize.load_parameters — Methodload_parameters(file::AbstractString)Load the parameters from a saved jump model.
LearningToOptimize.load_parameters — Methodload_parameters(model::JuMP.Model)Load the parameters from a JuMP model.
LearningToOptimize.make_convex! — Methodfunction make_convex!(chain::PairwiseFusion; tol = 1e-6)Make a PairwiseFusion model convex by making sure all dense layers (a part from the first) have positive weights. This procedure only makes sense for single output fully connected models.
LearningToOptimize.make_convex! — Methodfunction make_convex!(model::FullyConnected; tol = 1e-6)Make a FullyConnected model convex by making sure all dense layers (a part from the first) have positive weights. This procedure only makes sense for single output fully connected models.
LearningToOptimize.model_outputs — Methodmodel_outputs(model::Function, problem_iterator::ProblemIterator)Returns the output of a machine learning model over a ProblemIterator dataset.
LearningToOptimize.model_outputs — Methodmodel_outputs(mach::T, problem_iterator::ProblemIterator)Returns the output of a machine learning model over a ProblemIterator dataset.
LearningToOptimize.objective_evaluator — Methodobjective_evaluator(problem_iterator::ProblemIterator, output)Objective evaluator of a solution over a ProblemIterator dataset. PS.: Probably can be made much more efficient.
LearningToOptimize.record — Methodrecord(recorder::Recorder{ArrowFile}, id::UUID)Record optimization problem solution to an Arrow file.
LearningToOptimize.record — Methodrecord(recorder::Recorder{CSVFile}, id::UUID)Record optimization problem solution to a CSV file.
LearningToOptimize.save — Methodsave(problem_iterator::ProblemIterator, filename::AbstractString, file_type::Type{T})Save optimization problem instances to a file.
LearningToOptimize.scaled_distribution_sampler — Methodfunction scaled_distribution_sampler(
original_parameters::Vector{VariableRef},
num_s::F;
rng::AbstractRNG=Random.GLOBAL_RNG,
scaler_multiplier::Distribution=Uniform(0.8, 1.25),
distribution::Distribution=MvLogNormal(fill(-(1.05 .^ 2) ./ 2.0, length(original_parameters)), 1.05)
) where {F<:Integer}Sample from a distribution and scale the parameters by a random value over a uniform distribution.
LearningToOptimize.solve_and_record — Methodsolve_and_record(problem_iterator::ProblemIterator, recorder::Recorder, idx::Integer)Solve an optimization problem and record the solution.
LearningToOptimize.solve_batch — Methodsolve_batch(problem_iterator::AbstractProblemIterator, recorder)Solve a batch of optimization problems and record the solutions.
LearningToOptimize.update_model! — Methodupdate_model!(model::JuMP.Model, pairs::Dict, idx::Integer)Update the values of parameters in a JuMP model.
LearningToOptimize.update_model! — Methodupdate_model!(model::JuMP.Model, p::VariableRef, val::Real)Update the value of a parameter in a JuMP model.
LearningToOptimize.variable_point — Methodvariable_point(vals::Tables.MatrixTable, problem_iterator::ProblemIterator, idx::Int)Returns a dictionary with the values of the variables and parameters for the idx-th problem instance.
LearningToOptimize.variable_point — Methodvariable_point(vals::Array{T,2}, problem_iterator::ProblemIterator, idx::Int)Returns a dictionary with the values of the variables and parameters for the idx-th problem instance.