Problem¶
A problem contains the objective as well as all information like prior describing the problem to be solved.
-
class
pypesto.problem.
Problem
(objective: pypesto.objective.objective.Objective, lb: Union[numpy.ndarray, List[float]], ub: Union[numpy.ndarray, List[float]], dim_full: Optional[int] = None, x_fixed_indices: Optional[Iterable[int]] = None, x_fixed_vals: Optional[Iterable[float]] = None, x_guesses: Optional[Iterable[float]] = None, x_names: Optional[Iterable[str]] = None)¶ Bases:
object
The problem formulation. A problem specifies the objective function, boundaries and constraints, parameter guesses as well as the parameters which are to be optimized.
Parameters: - objective – The objective function for minimization. Note that a shallow copy is created.
- ub (lb,) – The lower and upper bounds. For unbounded directions set to inf.
- dim_full – The full dimension of the problem, including fixed parameters.
- x_fixed_indices – Vector containing the indices (zero-based) of parameter components that are not to be optimized.
- x_fixed_vals – Vector of the same length as x_fixed_indices, containing the values of the fixed parameters.
- x_guesses – Guesses for the parameter values, shape (g, dim), where g denotes the number of guesses. These are used as start points in the optimization.
- x_names – Parameter names that can be optionally used e.g. in visualizations. If objective.get_x_names() is not None, those values are used, else the values specified here are used if not None, otherwise the variable names are set to [‘x0’, … ‘x{dim_full}’]. The list must always be of length dim_full.
-
dim
¶ The number of non-fixed parameters. Computed from the other values.
-
x_free_indices
¶ Vector containing the indices (zero-based) of free parameters (complimentary to x_fixed_indices).
Type: array_like of int
Notes
On the fixing of parameter values:
The number of parameters dim_full the objective takes as input must be known, so it must be either lb a vector of that size, or dim_full specified as a parameter.
All vectors are mapped to the reduced space of dimension dim in __init__, regardless of whether they were in dimension dim or dim_full before. If the full representation is needed, the methods get_full_vector() and get_full_matrix() can be used.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'pypesto.problem', '__doc__': "\n The problem formulation. A problem specifies the objective function,\n boundaries and constraints, parameter guesses as well as the parameters\n which are to be optimized.\n\n Parameters\n ----------\n objective:\n The objective function for minimization. Note that a shallow copy\n is created.\n lb, ub:\n The lower and upper bounds. For unbounded directions set to inf.\n dim_full:\n The full dimension of the problem, including fixed parameters.\n x_fixed_indices:\n Vector containing the indices (zero-based) of parameter components\n that are not to be optimized.\n x_fixed_vals:\n Vector of the same length as x_fixed_indices, containing the values\n of the fixed parameters.\n x_guesses:\n Guesses for the parameter values, shape (g, dim), where g denotes the\n number of guesses. These are used as start points in the optimization.\n x_names:\n Parameter names that can be optionally used e.g. in visualizations.\n If objective.get_x_names() is not None, those values are used,\n else the values specified here are used if not None, otherwise\n the variable names are set to ['x0', ... 'x{dim_full}']. The list\n must always be of length dim_full.\n\n Attributes\n ----------\n\n dim:\n The number of non-fixed parameters.\n Computed from the other values.\n x_free_indices: array_like of int\n Vector containing the indices (zero-based) of free parameters\n (complimentary to x_fixed_indices).\n\n Notes\n -----\n\n On the fixing of parameter values:\n\n The number of parameters dim_full the objective takes as input must\n be known, so it must be either lb a vector of that size, or dim_full\n specified as a parameter.\n\n All vectors are mapped to the reduced space of dimension dim in __init__,\n regardless of whether they were in dimension dim or dim_full before. If\n the full representation is needed, the methods get_full_vector() and\n get_full_matrix() can be used.\n ", '__init__': <function Problem.__init__>, 'normalize_input': <function Problem.normalize_input>, 'fix_parameters': <function Problem.fix_parameters>, 'unfix_parameters': <function Problem.unfix_parameters>, 'get_full_vector': <function Problem.get_full_vector>, 'get_full_matrix': <function Problem.get_full_matrix>, 'get_reduced_vector': <function Problem.get_reduced_vector>, 'get_reduced_matrix': <function Problem.get_reduced_matrix>, 'print_parameter_summary': <function Problem.print_parameter_summary>, '__dict__': <attribute '__dict__' of 'Problem' objects>, '__weakref__': <attribute '__weakref__' of 'Problem' objects>})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
(objective: pypesto.objective.objective.Objective, lb: Union[numpy.ndarray, List[float]], ub: Union[numpy.ndarray, List[float]], dim_full: Optional[int] = None, x_fixed_indices: Optional[Iterable[int]] = None, x_fixed_vals: Optional[Iterable[float]] = None, x_guesses: Optional[Iterable[float]] = None, x_names: Optional[Iterable[str]] = None)¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'pypesto.problem'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
fix_parameters
(parameter_indices: Union[Iterable[int], int], parameter_vals: Union[Iterable[float], float]) → None¶ Fix specified parameters to specified values
-
get_full_matrix
(x: Optional[numpy.ndarray]) → Optional[numpy.ndarray]¶ Map matrix from dim to dim_full. Usually used for hessian.
Parameters: x (array_like, shape=(dim, dim)) – The matrix in dimension dim.
-
get_full_vector
(x: Optional[numpy.ndarray], x_fixed_vals: Iterable[float] = None) → Optional[numpy.ndarray]¶ Map vector from dim to dim_full. Usually used for x, grad.
Parameters: - x (array_like, shape=(dim,)) – The vector in dimension dim.
- x_fixed_vals (array_like, ndim=1, optional) – The values to be used for the fixed indices. If None, then nans are inserted. Usually, None will be used for grad and problem.x_fixed_vals for x.
-
get_reduced_matrix
(x_full: Optional[numpy.ndarray]) → Optional[numpy.ndarray]¶ Map matrix from dim_full to dim, i.e. delete fixed indices.
Parameters: x_full (array_like, ndim=2) – The matrix in dimension dim_full.
-
get_reduced_vector
(x_full: Optional[numpy.ndarray]) → Optional[numpy.ndarray]¶ Map vector from dim_full to dim, i.e. delete fixed indices.
Parameters: x_full (array_like, ndim=1) – The vector in dimension dim_full.
-
normalize_input
(check_x_guesses: bool = True) → None¶ Reduce all vectors to dimension dim and have the objective accept vectors of dimension dim.
-
print_parameter_summary
() → None¶ Prints a summary of what parameters are being optimized and what parameter boundaries are
-
unfix_parameters
(parameter_indices: Union[Iterable[int], int]) → None¶ Free specified parameters