Api

LearningToOptimize

LearningToOptimize.FullyConnected — Method
FullyConnected(input_size::Int, hidden_sizes::Vector{Int}, output_size::Int)::FullyConnected

Create 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.

source
LearningToOptimize.Recorder — Type
Recorder(filename; primal_variables=[], dual_variables=[], filterfn=(model)-> termination_status(model) == MOI.OPTIMAL)

Recorder of optimization problem solutions.

source
LearningToOptimize.box_sampler — Method
function 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.

source
LearningToOptimize.feasibility_evaluator — Method
feasibility_evaluator(problem_iterator::ProblemIterator, output)

Feasibility evaluator of a solution over a ProblemIterator dataset. PS.: Probably can be made much more efficient.

source
LearningToOptimize.general_evaluator — Method
general_evaluator(problem_iterator::ProblemIterator, model)

General evaluator of a predictor model over a ProblemIterator dataset. Returns objective, feasibility, inference time and allocated memory.

source
LearningToOptimize.general_sampler — Method
function 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.

source
LearningToOptimize.general_sampler — Method
general_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.

source
LearningToOptimize.inconvexhull — Method
inconvexhull(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.

source
LearningToOptimize.line_sampler — Method
function 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.

source
LearningToOptimize.make_convex! — Method
function 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.

source
LearningToOptimize.make_convex! — Method
function 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.

source
LearningToOptimize.model_outputs — Method
model_outputs(model::Function, problem_iterator::ProblemIterator)

Returns the output of a machine learning model over a ProblemIterator dataset.

source
LearningToOptimize.objective_evaluator — Method
objective_evaluator(problem_iterator::ProblemIterator, output)

Objective evaluator of a solution over a ProblemIterator dataset. PS.: Probably can be made much more efficient.

source
LearningToOptimize.save — Method
save(problem_iterator::ProblemIterator, filename::AbstractString, file_type::Type{T})

Save optimization problem instances to a file.

source
LearningToOptimize.scaled_distribution_sampler — Method
function 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.

source
LearningToOptimize.variable_point — Method
variable_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.

source
LearningToOptimize.variable_point — Method
variable_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.

source