MOProblem
- class desdeo_problem.problem.MOProblem(objectives, variables, constraints=None, nadir=None, ideal=None)[source]
Bases:
ProblemBase
An user defined multiobjective optimization problem.
A multiobjective optimization problem with user defined objective functions, constraints, and variables.
- Parameters:
objectives (List[Union[ScalarObjective, VectorObjective]]) – A list containing the objectives of the problem.
variables (List[Variable]) – A list containing the variables of the problem.
constraints (List[ScalarConstraint]) – A list of the constraints of the problem.
nadir (Optional[np.ndarray], optional) – Nadir point of the problem. Defaults to None.
ideal (Optional[np.ndarray], optional) – Ideal point of the problem. Defaults to None.
- __objectives
A list containing the objectives of the problem.
- Type:
List[Union[ScalarObjective, VectorObjective]]
- __constraints
A list of the constraints of the problem.
- Type:
List[ScalarConstraint]
- __nadir
Nadir point of the problem. Defaults to None.
- Type:
Optional[np.ndarray], optional
- __ideal
Ideal point of the problem. Defaults to None.
- Type:
Optional[np.ndarray], optional
- __n_of_variables
The number of variables
- Type:
int
- __n_of_objectives
The number of objectives
- Type:
int
- Raises:
ProblemError – If ideal or nadir vectors are not the same size as number of objectives.
Attributes Summary
list of constraints.
number of constraints.
number of dimensions of the fitness matrix.
number of objectives.
number of variables.
list of objectives.
List of variables
Methods Summary
evaluate
(decision_vectors[, use_surrogate])Evaluates the problem using an ensemble of input vectors.
evaluate_constraint_values
(decision_vectors, ...)Evaluate constraint values
evaluate_fitness
(objective_vectors)Evaluate fitness of the objectives.
evaluate_objectives
(decision_vectors[, ...])Evaluate objective values of the problem
Get objective names.
Get variable bounds.
Get variable lower bounds.
Get variable names.
Get variable upper bounds.
number_of_objectives
(obj_instance)Return the number of objectives in the given obj_instance.
update_ideal
(objective_vectors, fitness)Update the ideal vector
Attributes Documentation
- constraints
list of constraints.
- Returns:
list of constraints
- Return type:
List[ScalarConstraint]
- Type:
Property
- n_of_constraints
number of constraints.
- Returns:
Number of constraints
- Return type:
int
- Type:
Property
- n_of_fitnesses
number of dimensions of the fitness matrix. May be different than the number of objectives in inherited classes.
- Returns:
number of fitness dimensions.
- Return type:
int
- Type:
Property
- n_of_objectives
number of objectives.
- Returns:
number of objectives
- Return type:
int
- Type:
Property
- n_of_variables
number of variables.
- Returns:
Number of variables.
- Return type:
int
- Type:
Property
- objectives
list of objectives.
- Returns:
list of objectives
- Return type:
List[ScalarObjective]
- Type:
Property
Methods Documentation
- evaluate(decision_vectors, use_surrogate=False)[source]
Evaluates the problem using an ensemble of input vectors.
- Parameters:
decision_vectors (np.ndarray) – An 2D array of decision variable input vectors. Each column represent the values of each decision variable.
use_surrogate (bool) – A bool to control whether to use the true, potentially expensive function or a surrogate model to evaluate the objectives.
- Returns:
If constraint are defined, returns the objective vector values and corresponding constraint values. Or, if no constraints are defined, returns just the objective vector values with None as the constraint values.
- Return type:
Tuple[np.ndarray, Union[None, np.ndarray]]
- Raises:
ProblemError – The decision_vectors have wrong dimensions.
ValueError – If decision_vectors violate the lower or upper bounds.
- evaluate_constraint_values(decision_vectors, objective_vectors)[source]
Evaluate constraint values
Evaluate just the constraint function values using the attributes decision_vectors and objective_vectors
- Parameters:
decision_vectors (np.ndarray) – An 2D array of decision variable input vectors. Each column represent the values of each decision variable.
use_surrogate (bool) – A bool to control whether to use the true, potentially expensive function or a surrogate model to evaluate the objectives.
- Returns:
- if there are constraints, then this returns
np.ndarray of constraint values, else returns None
- Return type:
Optional[np.ndarray]
- Raises:
NotImplementedError –
Note
Currently not supported by ScalarMOProblem
- evaluate_fitness(objective_vectors)[source]
Evaluate fitness of the objectives.
- Parameters:
objective_vectors (np.ndarray) – objective vector array
- Returns:
fitness of each objective vector
- Return type:
np.ndarray
- evaluate_objectives(decision_vectors, use_surrogate=False)[source]
Evaluate objective values of the problem
- Parameters:
decision_vectors (np.ndarray) – An 2D array of decision variable input vectors. Each column represent the values of each decision variable.
use_surrogate (bool) – A bool to control whether to use the true, potentially expensive function or a surrogate model to evaluate the objectives.
- Returns:
Objective vector values with their uncertainty.
- Return type:
Tuple[np.ndarray]
- get_objective_names()[source]
Get objective names. Return the names of the objectives present in the problem in the order they were added.
- Returns:
Names of the objectives in the order they were added.
- Return type:
List[str]
- get_variable_bounds()[source]
Get variable bounds. Return the upper and lower bounds of each decision variable present in the problem as a 2D numpy array. The first column corresponds to the lower bounds of each variable, and the second column to the upper bound.
- Returns:
Lower and upper bounds of each variable as a 2D numpy array. If undefined variables, return None instead.
- Return type:
np.ndarray
- get_variable_lower_bounds()[source]
Get variable lower bounds.
Return the lower bounds of each variable as a list. The order of the bounds follows the order the variables were added to the problem.
- Returns:
An array with the lower bounds of the variables.
- Return type:
np.ndarray
- get_variable_names()[source]
Get variable names. Return the variable names of the variables present in the problem in the order they were added.
- Returns:
Names of the variables in the order they were added.
- Return type:
List[str]
- get_variable_upper_bounds()[source]
Get variable upper bounds.
Return the upper bounds of each variable as a list. The order of the bounds follows the order the variables were added to the problem.
- Returns:
An array with the upper bounds of the variables.
- Return type:
np.ndarray
- static number_of_objectives(obj_instance)[source]
Return the number of objectives in the given obj_instance.
- Parameters:
obj_instance (Union[ScalarObjective, VectorObjective]) – An instance of one of the objective classes
- Raises:
ProblemError – Raised when obj_instance is not an instance of the supported classes
- Returns:
Number of objectives in obj_instance
- Return type:
int