optunity.solvers.util module¶
-
class
optunity.solvers.util.
Solver
[source]¶ Bases:
abc.SolverBase
Base class of all Optunity solvers.
-
maximize
(f, pmap=<built-in function map>)[source]¶ Maximizes f.
Parameters: - f (callable) – the objective function
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
-
class
optunity.solvers.util.
ThreadSafeQueue
(lst=None)[source]¶ Bases:
object
Initializes a new object.
Parameters: lst (list or None) – initial content -
append
(value)[source]¶ Acquires lock and appends value to the content.
>>> q1 = ThreadSafeQueue() >>> q1 [] >>> q1.append(1) [1]
-
content
¶
-
copy
()[source]¶ Makes a deep copy of this ThreadSafeQueue.
>>> q1 = ThreadSafeQueue([1,2,3]) >>> q2 = q1.copy() >>> q2.append(4) >>> q1 [1, 2, 3] >>> q2 [1, 2, 3, 4]
-
lock
¶
-
-
optunity.solvers.util.
scale_unit_to_bounds
(seq, bounds)[source]¶ Scales all elements in seq (unit hypercube) to the box constraints in bounds.
Parameters: - seq (iterable of [lb, ub] pairs) – the sequence in the unit hypercube to scale
- bounds – bounds to scale to
Returns: a list of scaled elements of seq
>>> scale_unit_to_bounds([0.0, 0.5, 0.5, 1.0], [[-1.0, 2.0], [-2.0, 0.0], [0.0, 3.0], [0.0, 2.0]]) [-1.0, -1.0, 1.5, 2.0]
-
optunity.solvers.util.
score
(value)[source]¶ General wrapper around objective function evaluations to get the score.
Parameters: value – output of the objective function Returns: the score If value is a scalar, it is returned immediately. If value is iterable, its first element is returned.