foxes_opt.objectives.farm_vars¶
Classes¶
Objectives based on farm variables. |
|
Maximize the mean wind farm power |
|
Minimize the maximal turbine TI |
Module Contents¶
-
class foxes_opt.objectives.farm_vars.FarmVarObjective(problem: foxes_opt.core.farm_opt_problem.FarmOptProblem, name: str, variable: str, contract_states: str, contract_turbines: str, minimize: bool, deps: list[str] | None =
None, scale: float =1.0, **kwargs: Any)[source]¶ Bases:
foxes_opt.core.farm_objective.FarmObjectiveObjectives based on farm variables.
- Parameters:¶
- problem
The underlying optimization problem
- name
The name of the objective function
- variable
The foxes variable name
- contract_states
Contraction rule for states: min, max, sum, mean, weights
- contract_turbines
Contraction rule for turbines: min, max, sum, mean
- minimize
Switch for maximizing or minimizing
- deps
The foxes variables on which the variable depends, or None for all
- scale
The scaling factor
- kwargs
Additional parameters for FarmObjective
- add_to_layout_figure(ax: matplotlib.axes.Axes, **kwargs: Any) matplotlib.axes.Axes¶
Add to a layout figure
- Parameters:¶
- ax
The figure axis
-
ana_deriv(vars_int, vars_float, var, components=
None)¶ Calculates the analytic derivative, if possible.
Use numpy.nan if analytic derivatives cannot be calculated.
- Parameters:¶
- vars_int: np.array
The integer variable values, shape: (n_vars_int,)
- vars_float: np.array
The float variable values, shape: (n_vars_float,)
- var: int
The index of the differentiation float variable
- components: list of int
The selected components, or None for all
- Returns:¶
- deriv: numpy.ndarray
The derivative values, shape: (n_sel_components,)
-
calc_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, components: list[int] | None =
None) numpy.ndarray[source]¶ Calculate values for a single individual of the underlying problem.
- Parameters:¶
- vars_int
The integer variable values, shape: (n_vars_int,)
- vars_float
The float variable values, shape: (n_vars_float,)
- problem_results
The results of the variable application to the problem
- components
The selected components or None for all
- Returns:¶
- values
The component values, shape: (n_sel_components,)
-
calc_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, components: list[int] | None =
None) numpy.ndarray[source]¶ Calculate values for 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)
- problem_results
The results of the variable application to the problem
- components
The selected components or None for all
- Returns:¶
- values
The component values, shape: (n_pop, n_sel_components)
-
finalize(verbosity=
0)¶ Finalize the object.
- Parameters:¶
- verbosity: int
The verbosity level, 0 = silent
-
finalize_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, verbosity: int =
1) numpy.ndarray[source]¶ 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,)
- problem_results
The results of the variable application to the problem
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- values
The component values, shape: (n_components,)
-
finalize_population(vars_int, vars_float, problem_results, verbosity=
1)¶ Finalization, given the final population data.
- Parameters:¶
- vars_int: np.array
The integer variable values of the final generation, shape: (n_pop, n_vars_int)
- vars_float: np.array
The float variable values of the final generation, shape: (n_pop, n_vars_float)
- problem_results: Any
The results of the variable application to the problem
- verbosity: int
The verbosity level, 0 = silent
- Returns:¶
- values: np.array
The component values, shape: (n_pop, n_components)
-
initialize(verbosity: int =
0) None[source]¶ Initialize the object.
- Parameters:¶
- verbosity
The verbosity level, 0 = silent
- maximize() list[bool][source]¶
Returns flag for maximization of each component.
- Returns:¶
- flags
Bool array for component maximization, shape
- n_components() int[source]¶
Returns the number of components of the function.
- Returns:¶
- value
The number of components.
- classmethod new(objective_type: str, *args: Any, **kwargs: Any) Any¶
Run-time farm objective factory.
- Parameters:¶
- objective_type
The selected derived class name
- args
Additional parameters for the constructor
- kwargs
Additional parameters for the constructor
- rename_vars_float(varmap)¶
Rename float variables.
- Parameters:¶
- varmap: dict
The name mapping. Key: old name str, Value: new name str
- rename_vars_int(varmap)¶
Rename integer variables.
- Parameters:¶
- varmap: dict
The name mapping. Key: old name str, Value: new name str
- vardeps_float() numpy.ndarray[tuple[int, int], numpy.dtype[numpy.bool_]][source]¶
Gets the dependencies of all components on the function float variables
- Returns:¶
- deps
The dependencies of components on function variables, shape
- vardeps_int()¶
Gets the dependencies of all components on the function int variables
- Returns:¶
- deps: numpy.ndarray of bool
The dependencies of components on function variables, shape: (n_components, n_vars_int)
- property component_names¶
The names of the components
- Returns:¶
- names: list of str
The component names
-
deps =
None¶
- property initialized¶
Flag for finished initialization
- Returns:¶
- bool
True if initialization has been done
- minimize¶
- property n_sel_turbines : int¶
The numer of selected turbines
- Returns:¶
- value
The numer of selected turbines
- name¶
- problem¶
- rules¶
-
scale =
1.0¶
- property sel_turbines : list[int]¶
The list of selected turbines
- Returns:¶
- value
The list of selected turbines
- property var_names_float¶
The names of the float variables
- Returns:¶
- names: list of str
The float variable names
- property var_names_int¶
The names of the integer variables
- Returns:¶
- names: list of str
The integer variable names
- variable¶
-
class foxes_opt.objectives.farm_vars.MaxFarmPower(problem: foxes_opt.core.farm_opt_problem.FarmOptProblem, name: str =
'maximize_power', **kwargs: Any)[source]¶ Bases:
FarmVarObjectiveMaximize the mean wind farm power
Parameters¶
- problem
The underlying optimization problem
- name
The name of the objective function
- kwargs
Additional parameters for FarmVarObjective
- Parameters:
- problem
The underlying optimization problem
- name
The name of the objective function
- variable
The foxes variable name
- contract_states
Contraction rule for states: min, max, sum, mean, weights
- contract_turbines
Contraction rule for turbines: min, max, sum, mean
- minimize
Switch for maximizing or minimizing
- deps
The foxes variables on which the variable depends, or None for all
- scale
The scaling factor
- kwargs
Additional parameters for FarmObjective
- add_to_layout_figure(ax: matplotlib.axes.Axes, **kwargs: Any) matplotlib.axes.Axes¶
Add to a layout figure
- Parameters:¶
- ax
The figure axis
-
ana_deriv(vars_int, vars_float, var, components=
None)¶ Calculates the analytic derivative, if possible.
Use numpy.nan if analytic derivatives cannot be calculated.
- Parameters:¶
- vars_int: np.array
The integer variable values, shape: (n_vars_int,)
- vars_float: np.array
The float variable values, shape: (n_vars_float,)
- var: int
The index of the differentiation float variable
- components: list of int
The selected components, or None for all
- Returns:¶
- deriv: numpy.ndarray
The derivative values, shape: (n_sel_components,)
-
calc_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, components: list[int] | None =
None) numpy.ndarray¶ Calculate values for a single individual of the underlying problem.
- Parameters:¶
- vars_int
The integer variable values, shape: (n_vars_int,)
- vars_float
The float variable values, shape: (n_vars_float,)
- problem_results
The results of the variable application to the problem
- components
The selected components or None for all
- Returns:¶
- values
The component values, shape: (n_sel_components,)
-
calc_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, components: list[int] | None =
None) numpy.ndarray¶ Calculate values for 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)
- problem_results
The results of the variable application to the problem
- components
The selected components or None for all
- Returns:¶
- values
The component values, shape: (n_pop, n_sel_components)
-
finalize(verbosity=
0)¶ Finalize the object.
- Parameters:¶
- verbosity: int
The verbosity level, 0 = silent
-
finalize_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, verbosity: int =
1) 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,)
- problem_results
The results of the variable application to the problem
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- values
The component values, shape: (n_components,)
-
finalize_population(vars_int, vars_float, problem_results, verbosity=
1)¶ Finalization, given the final population data.
- Parameters:¶
- vars_int: np.array
The integer variable values of the final generation, shape: (n_pop, n_vars_int)
- vars_float: np.array
The float variable values of the final generation, shape: (n_pop, n_vars_float)
- problem_results: Any
The results of the variable application to the problem
- verbosity: int
The verbosity level, 0 = silent
- Returns:¶
- values: np.array
The component values, shape: (n_pop, n_components)
-
initialize(verbosity: int =
0) None¶ Initialize the object.
- Parameters:¶
- verbosity
The verbosity level, 0 = silent
- maximize() list[bool]¶
Returns flag for maximization of each component.
- Returns:¶
- flags
Bool array for component maximization, shape
- n_components() int¶
Returns the number of components of the function.
- Returns:¶
- value
The number of components.
- classmethod new(objective_type: str, *args: Any, **kwargs: Any) Any¶
Run-time farm objective factory.
- Parameters:¶
- objective_type
The selected derived class name
- args
Additional parameters for the constructor
- kwargs
Additional parameters for the constructor
- rename_vars_float(varmap)¶
Rename float variables.
- Parameters:¶
- varmap: dict
The name mapping. Key: old name str, Value: new name str
- rename_vars_int(varmap)¶
Rename integer variables.
- Parameters:¶
- varmap: dict
The name mapping. Key: old name str, Value: new name str
- vardeps_float() numpy.ndarray[tuple[int, int], numpy.dtype[numpy.bool_]]¶
Gets the dependencies of all components on the function float variables
- Returns:¶
- deps
The dependencies of components on function variables, shape
- vardeps_int()¶
Gets the dependencies of all components on the function int variables
- Returns:¶
- deps: numpy.ndarray of bool
The dependencies of components on function variables, shape: (n_components, n_vars_int)
- property component_names¶
The names of the components
- Returns:¶
- names: list of str
The component names
-
deps =
None¶
- property initialized¶
Flag for finished initialization
- Returns:¶
- bool
True if initialization has been done
- minimize¶
- property n_sel_turbines : int¶
The numer of selected turbines
- Returns:¶
- value
The numer of selected turbines
- name¶
- problem¶
- rules¶
-
scale =
1.0¶
- property sel_turbines : list[int]¶
The list of selected turbines
- Returns:¶
- value
The list of selected turbines
- property var_names_float¶
The names of the float variables
- Returns:¶
- names: list of str
The float variable names
- property var_names_int¶
The names of the integer variables
- Returns:¶
- names: list of str
The integer variable names
- variable¶
-
class foxes_opt.objectives.farm_vars.MinimalMaxTI(problem: foxes_opt.core.farm_opt_problem.FarmOptProblem, name: str =
'minimize_TI', **kwargs: Any)[source]¶ Bases:
FarmVarObjectiveMinimize the maximal turbine TI
Parameters¶
- problem
The underlying optimization problem
- name
The name of the objective function
- kwargs
Additional parameters for FarmVarObjective
- Parameters:
- problem
The underlying optimization problem
- name
The name of the objective function
- variable
The foxes variable name
- contract_states
Contraction rule for states: min, max, sum, mean, weights
- contract_turbines
Contraction rule for turbines: min, max, sum, mean
- minimize
Switch for maximizing or minimizing
- deps
The foxes variables on which the variable depends, or None for all
- scale
The scaling factor
- kwargs
Additional parameters for FarmObjective
- add_to_layout_figure(ax: matplotlib.axes.Axes, **kwargs: Any) matplotlib.axes.Axes¶
Add to a layout figure
- Parameters:¶
- ax
The figure axis
-
ana_deriv(vars_int, vars_float, var, components=
None)¶ Calculates the analytic derivative, if possible.
Use numpy.nan if analytic derivatives cannot be calculated.
- Parameters:¶
- vars_int: np.array
The integer variable values, shape: (n_vars_int,)
- vars_float: np.array
The float variable values, shape: (n_vars_float,)
- var: int
The index of the differentiation float variable
- components: list of int
The selected components, or None for all
- Returns:¶
- deriv: numpy.ndarray
The derivative values, shape: (n_sel_components,)
-
calc_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, components: list[int] | None =
None) numpy.ndarray¶ Calculate values for a single individual of the underlying problem.
- Parameters:¶
- vars_int
The integer variable values, shape: (n_vars_int,)
- vars_float
The float variable values, shape: (n_vars_float,)
- problem_results
The results of the variable application to the problem
- components
The selected components or None for all
- Returns:¶
- values
The component values, shape: (n_sel_components,)
-
calc_population(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, components: list[int] | None =
None) numpy.ndarray¶ Calculate values for 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)
- problem_results
The results of the variable application to the problem
- components
The selected components or None for all
- Returns:¶
- values
The component values, shape: (n_pop, n_sel_components)
-
finalize(verbosity=
0)¶ Finalize the object.
- Parameters:¶
- verbosity: int
The verbosity level, 0 = silent
-
finalize_individual(vars_int: numpy.ndarray, vars_float: numpy.ndarray, problem_results: Any, verbosity: int =
1) 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,)
- problem_results
The results of the variable application to the problem
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- values
The component values, shape: (n_components,)
-
finalize_population(vars_int, vars_float, problem_results, verbosity=
1)¶ Finalization, given the final population data.
- Parameters:¶
- vars_int: np.array
The integer variable values of the final generation, shape: (n_pop, n_vars_int)
- vars_float: np.array
The float variable values of the final generation, shape: (n_pop, n_vars_float)
- problem_results: Any
The results of the variable application to the problem
- verbosity: int
The verbosity level, 0 = silent
- Returns:¶
- values: np.array
The component values, shape: (n_pop, n_components)
-
initialize(verbosity: int =
0) None¶ Initialize the object.
- Parameters:¶
- verbosity
The verbosity level, 0 = silent
- maximize() list[bool]¶
Returns flag for maximization of each component.
- Returns:¶
- flags
Bool array for component maximization, shape
- n_components() int¶
Returns the number of components of the function.
- Returns:¶
- value
The number of components.
- classmethod new(objective_type: str, *args: Any, **kwargs: Any) Any¶
Run-time farm objective factory.
- Parameters:¶
- objective_type
The selected derived class name
- args
Additional parameters for the constructor
- kwargs
Additional parameters for the constructor
- rename_vars_float(varmap)¶
Rename float variables.
- Parameters:¶
- varmap: dict
The name mapping. Key: old name str, Value: new name str
- rename_vars_int(varmap)¶
Rename integer variables.
- Parameters:¶
- varmap: dict
The name mapping. Key: old name str, Value: new name str
- vardeps_float() numpy.ndarray[tuple[int, int], numpy.dtype[numpy.bool_]]¶
Gets the dependencies of all components on the function float variables
- Returns:¶
- deps
The dependencies of components on function variables, shape
- vardeps_int()¶
Gets the dependencies of all components on the function int variables
- Returns:¶
- deps: numpy.ndarray of bool
The dependencies of components on function variables, shape: (n_components, n_vars_int)
- property component_names¶
The names of the components
- Returns:¶
- names: list of str
The component names
-
deps =
None¶
- property initialized¶
Flag for finished initialization
- Returns:¶
- bool
True if initialization has been done
- minimize¶
- property n_sel_turbines : int¶
The numer of selected turbines
- Returns:¶
- value
The numer of selected turbines
- name¶
- problem¶
- rules¶
-
scale =
1.0¶
- property sel_turbines : list[int]¶
The list of selected turbines
- Returns:¶
- value
The list of selected turbines
- property var_names_float¶
The names of the float variables
- Returns:¶
- names: list of str
The float variable names
- property var_names_int¶
The names of the integer variables
- Returns:¶
- names: list of str
The integer variable names
- variable¶