Skip to content

Commit a8af8a4

Browse files
committed
abstract solver type and behavior
1 parent c4c047e commit a8af8a4

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/SolverCore.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ using NLPModels
88

99
include("logger.jl")
1010
include("stats.jl")
11+
include("solver.jl")
1112

1213
end

src/solver.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export AbstractSolver, AbstractOptimizationSolver, solve!
2+
3+
"Abstract type from which JSO solvers derive."
4+
abstract type AbstractSolver end
5+
6+
abstract type AbstractOptimizationSolver <: AbstractSolver end
7+
8+
"""
9+
solve!(solver, model; kwargs...)
10+
solve!(solver, model, stats; kwargs...)
11+
12+
Apply `solver` to `model`.
13+
14+
# Arguments
15+
16+
- `solver::AbstractOptimizationSolver`: solver structure to hold all storage necessary for a solve
17+
- `model::AbstractNLPModel`: the model solved, see `NLPModels.jl`
18+
- `stats::GenericExecutionStats`: stats structure to hold solution information.
19+
20+
The first invocation allocates and returns a new `GenericExecutionStats`.
21+
The second one fills out a preallocated stats structure and allows for efficient re-solves.
22+
23+
The `kwargs` are passed to the solver.
24+
25+
# Return Value
26+
27+
- `stats::GenericExecutionStats`: stats structure holding solution information.
28+
"""
29+
function solve!(solver::AbstractOptimizationSolver, model::AbstractNLPModel; kwargs...)
30+
stats = GenericExecutionStats(model)
31+
solve!(solver, model, stats; kwargs...)
32+
end
33+
34+
function solve!(
35+
::AbstractOptimizationSolver,
36+
::AbstractNLPModel,
37+
::GenericExecutionStats;
38+
kwargs...,
39+
) end

0 commit comments

Comments
 (0)