solver.ScalarSolver
Implements methods for solving scalar valued functions.
Module Contents
Classes
A class the define and implement methods for minimizing scalar valued functions. 

Implements a class for minimizing scalar valued functions with bounds set for the 

Implements a class for finding the minimum value of a discrete of scalarized vectors. 
Attributes
 exception solver.ScalarSolver.ScalarSolverException[source]
Bases:
Exception
Common base class for all nonexit exceptions.
Initialize self. See help(type(self)) for accurate signature.
 class solver.ScalarSolver.ScalarMethod(method: Callable, method_args=None, use_scipy: bool  None = False)[source]
A class the define and implement methods for minimizing scalar valued functions.
 Parameters:
method (Callable) – A callable minimizer function which expects a callable scalar valued function to be minimized. The function should accept as its first argument a two dimensional numpy array and should return a dictionary with at least the keys: “x” the found optimal solution, “success” boolean indicating if the minimization was successfull, “message” a string of additional info.
method_args (Dict, optional) – Any other keyword arguments to be supplied to the method. Defaults to None.
use_scipy (Optional[bool]) – Whether to use scipy’s NonLinearConstraint to handle the constraints.
 __call__(obj_fun: Callable, x0: numpy.ndarray, bounds: numpy.ndarray, constraint_evaluator: Callable) Dict [source]
Minimizes a scalar valued function.
 Parameters:
obj_fun (Callable) – A callable scalar valued function that accepts a two dimensional numpy array as its first arguments.
x0 (np.ndarray) – An initial guess.
bounds (np.ndarray) – The upper and lower bounds for each variable accepted by obj_fun. Expects a 2D numpy array with each row representing the lower and upper bounds of a variable. The first column should contain the lower bounds and the last column the upper bounds. Use np.inf to indicate no bound.
constraint_evaluator (Callable) – Should accepts exactly the same arguments as obj_fun. Returns a scalar value for each constraint present. This scalar value should be positive if a constraint holds, and negative otherwise.
 Returns:
 A dictionary with at least the following entries: ‘x’ indicating the optimal
variables found, ‘fun’ the optimal value of the optimized function, and ‘success’ a boolean indicating whether the optimization was conducted successfully.
 Return type:
Dict
 class solver.ScalarSolver.ScalarMinimizer(scalarizer: desdeo_tools.scalarization.Scalarizer.Scalarizer, bounds: numpy.ndarray, constraint_evaluator: Callable = None, method: ScalarMethod  str  None = None)[source]
Implements a class for minimizing scalar valued functions with bounds set for the variables, and constraints.
 Parameters:
scalarizer (Scalarizer) – A Scalarizer to be minimized.
bounds (np.ndarray) – The bounds of the independent variables the scalarizer is called with.
constraint_evaluator (Callable, optional) – A Callable which representing a vector valued constraint function. The array the constraint function returns should be two dimensional with each row corresponding to the constraint function values when evaluated. A value of less than zero is understood as a non valid constraint. Defaults to None.
method (Optional[Union[Callable, str]], optional) – The optimization method the scalarizer should be minimized with. It should accepts as keyword the arguments ‘bounds’ and ‘constraints’ which will be used to pass it the bounds and constraint_evaluator. If none is supplied, uses the minimizer implemented in SciPy. Otherwise a str can be given to use one of the preset solvers available. Use the method ‘get_presets’ to get a list of available preset solvers. Defaults to None.
 minimize(x0: numpy.ndarray) Dict [source]
Minimizes the scalarizer given an initial guess x0.
 Parameters:
x0 (np.ndarray) – A numpy array containing an initial guess of variable values.
 Returns:
 A dictionary with at least the following entries: ‘x’ indicating the optimal
variables found, ‘fun’ the optimal value of the optimized function, and ‘success’ a boolean indicating whether the optimizaton was conducted successfully.
 Return type:
Dict
 class solver.ScalarSolver.DiscreteMinimizer(discrete_scalarizer: desdeo_tools.scalarization.Scalarizer.DiscreteScalarizer, constraint_evaluator: Callable[[numpy.ndarray], numpy.ndarray]  None = None)[source]
Implements a class for finding the minimum value of a discrete of scalarized vectors.
 Parameters:
discrete_scalarizer (DiscreteScalarizer) – A discrete scalarizer which takes as its arguments an array of vectors and returns a scalar value for each vector.
(Optional[Callable[[np.ndarray] (constraint_evaluator) –
:param : :param np.ndarray]]: An evaluator which returns True if a
given vector(s) adheres to given constraints, and False otherwise. Defaults to None.
 Parameters:
optional) – An evaluator which returns True if a given vector(s) adheres to given constraints, and False otherwise. Defaults to None.
 minimize(vectors: numpy.ndarray) dict [source]
Find the index of the element in vectors which minimizes the scalar value returned by the scalarizer. If multiple minimum values are found, returns the index of the first occurrence.
 Parameters:
vectors (np.ndarray) – The vectors for which the minimum scalar value should be computed for.
 Raises:
ScalarSolverException – None of the given vectors adhere to the given constraints.
 Returns:
 A dictionary with at least the following entries: ‘x’ indicating the optimal
variables found, ‘fun’ the optimal value of the optimized function, and ‘success’ a boolean indicating whether the optimizaton was conducted successfully.
 Return type:
Dict