JuMP Model Optimisation
PortfolioOptimisers.Solver Type
struct Solver{T1, T2, T3, T4, T5} <: AbstractEstimator
name::T1
solver::T2
settings::T3
check_sol::T4
add_bridges::T5
endContainer for configuring a JuMP solver and its settings.
The Solver struct encapsulates all information needed to set up and run a JuMP optimisation, including the solver backend, solver-specific settings, solution checks, and bridge options.
Fields
name: Symbol or string identifier for the solver.solver: Theoptimizer_factoryinset_optimizer.settings: Solver-specific settings used inset_attribute.check_sol: Named tuple of solution for keyword arguments inassert_is_solved_and_feasible.add_bridges: Theadd_bridgeskeyword argument inset_optimizer.
Constructor
Solver(; name::Union{Symbol, <:AbstractString} = "", solver = nothing,
settings::Union{Nothing, <:AbstractDict, <:Pair, <:AbstractVector{<:Pair}} = nothing,
check_sol::NamedTuple = (;), add_bridges::Bool = true)Keyword arguments correspond to the fields above.
Validation
settings:Union{<:AbstractDict, <:AbstractVector}:!isempty(settings).
Examples
julia> Solver()
Solver
name ┼ String: ""
solver ┼ nothing
settings ┼ nothing
check_sol ┼ @NamedTuple{}: NamedTuple()
add_bridges ┴ Bool: trueRelated
sourcePortfolioOptimisers.JuMPResult Type
struct JuMPResult{T1, T2} <: AbstractJuMPResult
trials::T1
success::T2
endResult type for JuMP model optimisation.
The JuMPResult struct records the outcome of a JuMP optimisation, including trial errors and success status.
Fields
trials: Dictionary of solver trials and errors.success: Boolean indicating whether optimisation succeeded.
Constructor
JuMPResult(; trials::AbstractDict, success::Bool)Keyword arguments correspond to the fields above.
Examples
julia> JuMPResult(; trials = Dict(:HiGHS => Dict(:optimize! => "error")), success = true)
JuMPResult
trials ┼ Dict{Symbol, Dict{Symbol, String}}: Dict(:HiGHS => Dict(:optimize! => "error"))
success ┴ Bool: trueRelated
sourcePortfolioOptimisers.AbstractJuMPResult Type
abstract type AbstractJuMPResult <: AbstractResult endAbstract supertype for all JuMP-based optimisation result types in PortfolioOptimisers.jl.
All concrete types representing the result of a JuMP model optimisation should subtype AbstractJuMPResult. This enables a consistent interface for handling solver results throughout the package.
Related
sourcePortfolioOptimisers.set_solver_attributes Function
set_solver_attributes(args...)Set solver attributes for a JuMP model.
This is a generic fallback that does nothing if no model or settings are provided.
Arguments
args...: Arguments (ignored).
Returns
nothing
set_solver_attributes(model::JuMP.Model,
settings::Union{<:AbstractDict, <:AbstractVector{<:Pair}})Set multiple solver attributes on a JuMP model.
Iterates over the provided settings and applies each as a solver attribute.
Arguments
model: JuMP model.settings: Dictionary or vector of pairs of solver settings.
Returns
nothing
set_solver_attributes(model::JuMP.Model, settings::Pair)Set a single solver attribute on a JuMP model.
Arguments
model: JuMP model.settings: Pair of attribute name and value.
Returns
nothing
PortfolioOptimisers.optimise_JuMP_model! Function
optimise_JuMP_model!(model::JuMP.Model, slv::Union{<:Solver, <:AbstractVector{<:Solver}})Attempt to optimise a JuMP model using one or more configured solvers.
Tries each solver in order, applying settings and checking for solution feasibility. Returns a JuMPResult with trial errors and success status.
Arguments
model: JuMP model to optimise.slv: SingleSolveror vector ofSolverobjects.
Returns
JuMPResult: Result object containing trial errors and success flag.
Details
For each solver, sets the optimizer and attributes, runs
JuMP.optimize!, and checks solution feasibility.If a solver fails, records the error and tries the next.
Stops at the first successful solution.