cosapp.drivers.optimizer¶
Driver`s for `System optimization calculation.
Classes
|
Driver running an optimization problem on its System owner. |
-
class
cosapp.drivers.optimizer.Optimizer(name: str, owner: Optional[cosapp.systems.System] = None, **kwargs)[source]¶ Bases:
cosapp.drivers.abstractsolver.AbstractSolverDriver running an optimization problem on its System owner.
In general, the optimization problems are of the form:
minimize f(x) subject to g_i(x) >= 0, i = 1,...,m h_j(x) = 0, j = 1,...,p
where
xis a vector of one or more variables.g_i(x)are the inequality constraints.h_j(x)are the equality constrains.Optionally, the lower and upper bounds for each element in x can also be specified.
- Parameters
-
name¶ Name of the driver
- Type
str
-
options¶ - Options for the current driververbose : int, {0, 1}Verbosity level of the driver; default 0 (i.e. minimal information)eps : float, [1.5e-8, 1.]Step size used for numerical approximation of the Jacobian; default 1.5e-8ftol : float, [1.5e-8, 1.]Iteration termination criteria (f^k - f^{k+1})/max{|f^k|,|f^{k+1}|,1} <= ftol;default 1e-6max_iter : int, [1, [Maximum number of iterations; default 100
- Type
-
solution¶ - Type
# TODO
Notes
This optimizer is a wrapper around
scipy.optimize.minimizefunction. For more details please refer to: https://docs.scipy.org/doc/scipy-1.0.0/reference/generated/scipy.optimize.minimize.html-
add_constraints(expression: Union[str, List[str]]) → None[source]¶ Add constraints to the optimization problem.
- Parameters
expression [str or List[str]] (-) – Human-readable equality or inequality constraints, such as ‘x >= y**2’, ‘0 < alpha < 1’, ‘a == b’, or a list thereof.
Note
Expressions are parsed into non-negative constraints in the optimization problem. Strict inequalities are not enforced, and treated as non-strict inequalities. For instance, x < y translates into: y - x >= 0.
-
add_unknown(name: Union[str, Iterable[Union[dict, str, cosapp.core.numerics.boundary.Unknown]]], max_abs_step: numbers.Number = inf, max_rel_step: numbers.Number = inf, lower_bound: numbers.Number = - inf, upper_bound: numbers.Number = inf) → cosapp.core.numerics.basics.MathematicalProblem[source]¶ Add unknown variables.
You can set variable one by one or provide a list of dictionary to set multiple variable at once. The dictionary key are the arguments of this method.
- Parameters
name (str or Iterable of dictionary or str) – Name of the variable or list of variable to add
max_rel_step (float, optional) – Maximal relative step by which the variable can be modified by the numerical solver; default numpy.inf
max_abs_step (float, optional) – Maximal absolute step by which the variable can be modified by the numerical solver; default numpy.inf
lower_bound (float, optional) – Lower bound on which the solver solution is saturated; default -numpy.inf
upper_bound (float, optional) – Upper bound on which the solver solution is saturated; default numpy.inf
- Returns
The modified MathematicalSystem
- Return type
-
static
available_methods() → List[str][source]¶ Returns all possible values of option method. For more information, please refer to the online documentation of scipy.optimize.minimize.
-
property
constraints¶ representation of optimization constraints.
- Type
Set[str]
-
property
objective¶
-
property
objective_expr¶
-
resolution_method(fresidues: Callable[[Sequence[float]], float], x0: numpy.ndarray, args: Tuple[Union[float, str], bool] = (), options: Optional[cosapp.utils.options_dictionary.OptionsDictionary] = None, bounds=None, constraints=None) → cosapp.core.numerics.basics.SolverResults[source]¶ Function call to cancel the residues.
- Parameters
fresidues (Callable[[Sequence[float], Union[float, str]], float]) – Residues function taking two parameters (evaluation vector, time/ref) and returning the residues
x0 (numpy.ndarray) – The initial values vector to converge to the solution
args (Tuple[Union[float, str], bool], optional) – A tuple of additional argument for fresidues starting with the time/ref parameter
options (OptionsDictionary, optional) – Options for the numerical resolution method
- Returns
Solution container
- Return type
-
set_maximum(expression: str) → None[source]¶ Set the scalar objective function to be maximized.
- Parameters
expression (str) – The objective expression to be maximized.
-
set_minimum(expression: str) → None[source]¶ Set the scalar objective function to be minimized.
- Parameters
expression (str) – The objective expression to be minimized.