foxes_opt.problems.layout.geom_layouts.geom_reggrids¶
Classes¶
A regular grid within a boundary geometry. |
Module Contents¶
-
class foxes_opt.problems.layout.geom_layouts.geom_reggrids.GeomRegGrids(boundary: foxes.utils.geom2d.AreaGeometry, min_dist: float, n_grids: int, n_max: int | None =
None, n_row_max: int | None =None, max_dist: float | None =None, D: float | None =None)[source]¶ Bases:
iwopy.ProblemA regular grid within a boundary geometry.
This optimization problem does not involve wind farms.
- Parameters:¶
- boundary
The boundary geometry
- min_dist
The minimal distance between points
- n_grids
The number of grids
- n_max
The maximal number of points
- n_row_max
The maximal number of points in a row
- max_dist
The maximal distance between points
- D
The diameter of circle fully within boundary
-
add_constraint(constraint: iwopy.core.constraint.Constraint, varmap_int: collections.abc.Mapping[str | int, str | int | numpy.integer] | None =
None, varmap_float: collections.abc.Mapping[str | int, str | int | numpy.integer] | None =None, verbosity: int =0) None¶ Add a constraint to the problem.
- Parameters:¶
- constraint
The constraint
- varmap_int
Mapping from objective variables to problem variables. Key: str or int, value: str or int
- varmap_float
Mapping from objective variables to problem variables. Key: str or int, value: str or int
- verbosity
The verbosity level, 0 = silent
-
add_objective(objective: iwopy.core.objective.Objective, varmap_int: collections.abc.Mapping[str | int, str | int | numpy.integer] | None =
None, varmap_float: collections.abc.Mapping[str | int, str | int | numpy.integer] | None =None, verbosity: int =0) None¶ Add an objective to the problem.
- Parameters:¶
- objective
The objective
- varmap_int
Mapping from objective variables to problem variables. Key: str or int, value: str or int
- varmap_float
Mapping from objective variables to problem variables. Key: str or int, value: str or int
- verbosity
The verbosity level, 0 = silent
- apply_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray][source]¶
Apply new variables to the problem.
- apply_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray][source]¶
Apply new variables to the problem, for a whole population.
-
calc_jacobian(vars_int: numpy.ndarray, vars_float: numpy.ndarray, func: iwopy.core.function.OptFunction, components: collections.abc.Sequence[int] | numpy.ndarray | None, ivars: list[int], fvars: list[int], vrs: list[int], pop: bool =
False, verbosity: int =0, func_values: numpy.ndarray | None =None, max_deltas: numpy.ndarray | None =None) scipy.sparse.csr_matrix¶ Assemble a CSR Jacobian from analytical partial derivatives.
Call
get_jacobianinstead of calling this method directly. Derived classes can supply numerical derivatives for unresolved entries.- Parameters:¶
- vars_int
The integer variable values, shape: (n_vars_int,)
- vars_float
The float variable values, shape: (n_vars_float,)
- func
The initialized function to differentiate.
- components
Component indices in the requested row order, or None for all.
- ivars
The indices of the function int variables in the problem
- fvars
The indices of the function float variables in the problem
- vrs
The function float variable indices wrt which the derivatives are to be calculated
- func_values
Previously calculated values for the selected components, with shape
(n_components,). The analytical implementation ignores them.- max_deltas
Positive finite call-local displacement caps in complete problem float-variable order, shape (n_vars_float,). Ignored analytically.
- pop
Flag for vectorizing calculations via population
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- jacobian
CSR Jacobian with shape
(n_components, n_vrs). Independent entries and exact zeros are not stored. Unavailable analytical derivatives remain explicitly stored asNaN.
-
check_constraints_individual(constraint_values: numpy.ndarray, verbosity: int =
0) numpy.ndarray¶ Check if the constraints are fullfilled for the given individual.
-
check_constraints_population(constraint_values: numpy.ndarray, verbosity: int =
0) numpy.ndarray¶ Check if the constraints are fullfilled for the given population.
-
evaluate_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, ret_prob_res: False =
False) tuple[numpy.ndarray, numpy.ndarray]¶ - evaluate_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, ret_prob_res: True) tuple[numpy.ndarray, numpy.ndarray, object | None]
Evaluate a single individual of the problem.
- Parameters:¶
- vars_int
The integer variable values, shape: (n_vars_int,)
- vars_float
The float variable values, shape: (n_vars_float,)
- ret_prob_res
Flag for additionally returning of problem results
- Returns:¶
- objs
The objective function values, shape: (n_objectives,)
- con
The constraints values, shape: (n_constraints,)
- prob_res
The problem results
-
evaluate_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray, ret_prob_res: False =
False) tuple[numpy.ndarray, numpy.ndarray]¶ - evaluate_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray, ret_prob_res: True) tuple[numpy.ndarray, numpy.ndarray, object | None]
Evaluate all individuals of a population.
- Parameters:¶
- vars_int
The integer variable values, shape: (n_pop, n_vars_int)
- vars_float
The float variable values, shape: (n_pop, n_vars_float)
- ret_prob_res
Flag for additionally returning of problem results
- Returns:¶
- objs
The objective function values, shape: (n_pop, n_objectives)
- cons
The constraints values, shape: (n_pop, n_constraints)
- prob_res
The problem results
-
finalize(verbosity: int =
0, /) None¶ -
finalize(*, verbosity: int =
0) None Finalize the object.
- Parameters:¶
- verbosity
The verbosity level, 0 = silent
-
finalize_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, verbosity: int =
1) tuple[object | None, numpy.ndarray, numpy.ndarray]¶ Finalization, given the champion data.
- Parameters:¶
- vars_int
The optimal integer variable values, shape: (n_vars_int,)
- vars_float
The optimal float variable values, shape: (n_vars_float,)
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- problem_results
The results of the variable application to the problem
- objs
The objective function values, shape: (n_objectives,)
- cons
The constraints values, shape: (n_constraints,)
-
finalize_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray, verbosity: int =
0) tuple[object | None, numpy.ndarray, numpy.ndarray]¶ Finalization, given the final population data.
- Parameters:¶
- vars_int
The integer variable values of the final generation, shape: (n_pop, n_vars_int)
- vars_float
The float variable values of the final generation, shape: (n_pop, n_vars_float)
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- problem_results
The results of the variable application to the problem
- objs
The final objective function values, shape: (n_pop, n_components)
- cons
The final constraint values, shape: (n_pop, n_constraints)
- get_active_constraint_components(vars_float: numpy.ndarray, lower: numpy.ndarray, upper: numpy.ndarray) numpy.ndarray¶
Obtain bound-certified constraint components in problem order.
- Parameters:¶
- vars_float
Initial float variables, shape: (n_vars_float,).
- lower, upper
Enforced bounds in problem float-variable order, with the same shape. Lower bounds must not exceed upper bounds.
- Returns:¶
- components
Sorted global constraint indices. Every omitted component must be certified feasible throughout the box by its owner.
- Raises:¶
- ValueError
If bounds have invalid shapes or a selector returns invalid or duplicate component indices.
-
get_fig(xy: numpy.ndarray | None =
None, valid: numpy.ndarray | None =None, ax: Axes | None =None, title: str | None =None, true_circle: bool =True, **bargs: Any) matplotlib.axes.Axes[source]¶ Return plotly figure axis.
-
get_jacobian(vars_int: numpy.ndarray, vars_float: numpy.ndarray, func: iwopy.core.function.OptFunction | None =
None, components: collections.abc.Sequence[int] | numpy.ndarray | None =None, vars: collections.abc.Sequence[str | int] | None =None, pop: bool =False, verbosity: int =0, func_values: numpy.ndarray | None =None, max_deltas: numpy.ndarray | None =None) scipy.sparse.csr_matrix¶ Obtain a CSR Jacobian for a function linked to this problem.
The func object typically is a iwopy.core.OptFunctionList object that contains a selection of objectives and/or constraints that were previously added to this problem. By default all objectives and constraints (and all their components) are being considered, cf. class ProblemDefaultFunc.
- Parameters:¶
- vars_int
The integer variable values, shape: (n_vars_int,)
- vars_float
The float variable values, shape: (n_vars_float,)
- func
The functions to be differentiated, or None for a list of all objectives and all constraints (in that order)
- components
Component indices in the requested row order, or None for all.
- vars
Floating variable names, integer problem-variable indices, or name patterns, or None for all problem floating variables. Selection order and repeated matches are preserved. Every selected variable must belong to the function.
- func_values
Previously calculated values in the selected component order, with shape
(n_components,). Numerical wrappers can reuse them.- max_deltas
Positive finite call-local displacement caps in complete problem float-variable order, shape (n_vars_float,). LocalFD uses the smaller of its configured delta and this cap. Analytical and fixed-grid derivatives are unchanged.
- verbosity
The verbosity level, 0 = silent
- pop
Flag for vectorizing calculations via population
- Returns:¶
- jacobian
CSR Jacobian with shape
(n_components, n_vars). Rows follow the selected component order and columns the selected floating variable order. Independent entries and exact zeros are implicit. Usejacobian.toarray()when a dense array is required.
- Raises:¶
- ValueError
If the function belongs to another problem, a selected variable is unavailable, an analytical derivative remains unresolved, or displacement caps have invalid shapes or non-positive/non-finite values.
- TypeError
If a variable selector is neither a name nor an integer index.
- initial_values_float() numpy.ndarray[source]¶
The initial values of the float variables.
- Returns:¶
- values
Initial float values, shape: (n_vars_float,)
- initial_values_int() numpy.ndarray[source]¶
The initial values of the int variables.
- Returns:¶
- values
Initial int values, shape: (n_vars_int,)
-
initialize(verbosity: int =
1) None[source]¶ Initialize the object.
- Parameters:¶
- verbosity
The verbosity level, 0 = silent
- layout_derivative(vars_int: numpy.ndarray, vars_float: numpy.ndarray, var: int) numpy.ndarray[source]¶
Calculate the layout derivative for one float variable.
- max_values_float() numpy.ndarray[source]¶
The maximal values of the float variables.
Use numpy.inf for unbounded.
- Returns:¶
- values
Maximal float values, shape: (n_vars_float,)
- max_values_int() numpy.ndarray[source]¶
The maximal values of the integer variables.
Use self.INT_INF for unbounded.
- Returns:¶
- values
Maximal int values, shape: (n_vars_int,)
- min_values_float() numpy.ndarray[source]¶
The minimal values of the float variables.
Use -numpy.inf for unbounded.
- Returns:¶
- values
Minimal float values, shape: (n_vars_float,)
- min_values_int() numpy.ndarray[source]¶
The minimal values of the integer variables.
Use -self.INT_INF for unbounded.
- Returns:¶
- values
Minimal int values, shape: (n_vars_int,)
- classmethod new(problem_type: str, *args: object, **kwargs: object) Problem¶
Run-time problem factory.
- Parameters:¶
- problem_type
The selected derived class name
- args
Additional parameters for constructor
- kwargs
Additional parameters for constructor
- prob_res_einsum_individual(prob_res_list: collections.abc.Sequence[object | None], coeffs: numpy.ndarray) object | None¶
Calculate the einsum of problem results
- prob_res_einsum_population(prob_res_list: collections.abc.Sequence[object | None], coeffs: numpy.ndarray) object | None¶
Calculate the einsum of problem results
- var_names_float() list[str][source]¶
The names of float variables.
- Returns:¶
- names
The names of the float variables
- var_names_int() list[str][source]¶
The names of int variables.
- Returns:¶
- names
The names of the int variables
-
D =
None¶
-
INT_INF =
-999999¶
- boundary¶
- cons : iwopy.core.function_list.OptFunctionList[iwopy.core.constraint.Constraint]¶
- property initialized : bool¶
Flag for finished initialization
- Returns:¶
- initialized
True if initialization has been done
- property max_values_constraints : numpy.ndarray | None¶
Gets the maximal values of constraints
- Returns:¶
- cma
The maximal constraint values, shape: (n_constraints,)
- property maximize_objs : numpy.ndarray¶
Flags for objective maximization
- Returns:¶
- maximize
Boolean flag for maximization of objective, shape: (n_objectives,)
- min_dist¶
- property min_values_constraints : numpy.ndarray | None¶
Gets the minimal values of constraints
- Returns:¶
- cmi
The minimal constraint values, shape: (n_constraints,)
- property n_constraints : int¶
The total number of constraints, i.e., the sum of all components
- Returns:¶
- n_con
The total number of constraint functions
- n_grids¶
-
n_max =
None¶
- property n_objectives : int¶
The total number of objectives, i.e., the sum of all components
- Returns:¶
- n_obj
The total number of objective functions
-
n_row_max =
None¶
-
name =
'Base'¶
- objs : iwopy.core.function_list.OptFunctionList[iwopy.core.objective.Objective]¶