/
problem.jl
51 lines (39 loc) · 1.41 KB
/
problem.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# Define a global problem and ist constructors
#
# ---
"""
Problem{T}
Describe the problem that should be optimized by stating all properties, that do not change
during an optimization or that are dependent of a certain solver.
The parameter `T` can be used to distinguish problems with different representations
or implementations.
The default parameter [`AllocatingEvaluation`](@ref), which might be slower but easier to use.
The usually faster parameter value is [`MutatingEvaluation`](@ref)
See [`Options`](@ref) for the changing and solver dependent properties.
"""
abstract type Problem{T} end
"""
AbstractEvaluationType
An abstract type to specify the kind of evaluation a [`Problem`](@ref) supports.
"""
abstract type AbstractEvaluationType end
"""
AllocatingEvaluation <: AbstractEvaluationType
A parameter for a [`Problem`](@ref) indicating that the problem uses functions that
allocate memory for their result, i.e. they work out of place.
"""
struct AllocatingEvaluation <: AbstractEvaluationType end
"""
MutatingEvaluation
A parameter for a [`Problem`](@ref) indicating that the problem uses functions that
do not allocate memory but work on their input, i.e. in place.
"""
struct MutatingEvaluation <: AbstractEvaluationType end
"""
get_cost(p, x)
evaluate the cost function `F` stored within a [`Problem`](@ref) at the point `x`.
"""
function get_cost(p::Problem, x)
return p.cost(p.M, x)
end