BinaryProblem#
- class pybrops.opt.prob.BinaryProblem.BinaryProblem(ndecn, decn_space, decn_space_lower, decn_space_upper, nobj, obj_wt=None, nineqcv=None, ineqcv_wt=None, neqcv=None, eqcv_wt=None, vtype=None, vars=None, elementwise=True, elementwise_func=<class 'pymoo.core.problem.ElementwiseEvaluationFunction'>, elementwise_runner=<pymoo.core.problem.LoopedElementwiseEvaluation object>, replace_nan_values_by=None, exclude_from_serialization=None, callback=None, strict=True, **kwargs)[source]#
Bases:
ProblemPartially implemented class for optimization problems with nominal decision variables where the goal is to select an optimal subset.
Constructor for BinaryProblem.
- Parameters:
ndecn (Integral) – Number of decision variables.
decn_space (numpy.ndarray) – A 1d array containing the set of available elements
decn_space_lower (numpy.ndarray) – A 1d array representing the lower bound of the decision variables.
decn_space_upper (numpy.ndarray) – A 1d array representing the upper bound of the decision variables.
nobj (Integral) – Number of objectives for the problem.
obj_wt (numpy.ndarray, Real, None) –
Objective function weights. Weights from this vector are applied to objective function values via the Hadamard product. If values are
1.0or-1.0, this can be used to specify minimizing and maximizing objectives, respectively.If
obj_wtisnumpy.ndarray, then the array must be of shape(nobj,).If
obj_wtisReal, then the value is broadcast to anumpy.ndarrayof shape(nobj,).If
obj_wtisNone, then the value1.0is broadcast to anumpy.ndarrayof shape(nobj,). This assumes that all objectives are to be minimized.nineqcv (Integral, None) –
Number of inequality constraint violation functions. This is equivalent to the vector length returned by the
ineqcv_transfunction. Must beIntegralgreater than or equal to zero.If
nineqcvisNone, then set to zero.ineqcv_wt (numpy.ndarray, None) –
Inequality constraint violation function weights. Weights from this vector are applied to inequality constraint violation function values via the Hadamard product. If values are
1.0or-1.0, this can be used to specify minimizing and maximizing constraints, respectively.If
ineqcv_wtisnumpy.ndarray, then the array must be of shape(nineqcv,).If
ineqcv_wtisReal, then the value is broadcast to anumpy.ndarrayof shape(nineqcv,).If
ineqcv_wtisNone, then the value1.0is broadcast to anumpy.ndarrayof shape(nineqcv,). This assumes that all constraints are to be minimized.neqcv (Integral, None) –
Number of equality constraint violations. This is equivalent to the vector length returned by the
eqcv_transfunction. Must beIntegralgreater than or equal to zero.If
neqcvisNone, then set to zero.eqcv_wt (numpy.ndarray, None) –
Equality constraint violation function weights. Weights from this vector are applied to equality constraint violation function values via the Hadamard product. If values are
1.0or-1.0, this can be used to specify minimizing and maximizing constraints, respectively.If
eqcv_wtisnumpy.ndarray, then the array must be of shape(neqcv,).If
eqcv_wtisReal, then the value is broadcast to anumpy.ndarrayof shape(neqcv,).If
eqcv_wtisNone, then the value1.0is broadcast to anumpy.ndarrayof shape(neqcv,). This assumes that all constraints are to be minimized.vtype (type, None) – Used by PyMOO interface to construct a PyMOO Problem object.
vars (Sequence, None) – Used by PyMOO interface to construct a PyMOO Problem object.
elementwise (bool) – Used by PyMOO interface to construct a PyMOO Problem object.
elementwise_func (type) – Used by PyMOO interface to construct a PyMOO Problem object.
elementwise_runner (Callable) – Used by PyMOO interface to construct a PyMOO Problem object.
replace_nan_values_by (Real, None) – Used by PyMOO interface to construct a PyMOO Problem object.
exclude_from_serialization (Iterable, None) – Used by PyMOO interface to construct a PyMOO Problem object.
callback (Callable, None) – Used by PyMOO interface to construct a PyMOO Problem object.
strict (bool) – Used by PyMOO interface to construct a PyMOO Problem object.
kwargs (dict) – Additional keyword arguments used for cooperative inheritance.
Methods
boundsdoEvaluate a candidate solution for the given Problem.
evaluatehas_boundshas_constraintsideal_pointnadir_pointnamepareto_frontpareto_setAttributes
A callback function to be called after every evaluation.
Type of the variable to be evaluated.
Decision space boundaries.
Lower boundary of the decision space.
Upper boundary of the decision space.
Whether the evaluation function should be run elementwise.
A class that creates the function that evaluates a single individual.
A function that runs the function that evaluates a single individual.
Equality constraint violation function weights.
attributes which are excluded from being serialized.
Inequality constraint violation function weights.
n_constrn_eq_constr.
Number of inequality constraints.
Number of objectives.
Number of decision variables.
Number of decision variables.
Number of equality constraint violations.
Number of inequality constraint violation functions.
Number of objectives.
Objective function weights.
replace_nan_values_by.
Whether the shapes are checked strictly.
Variables provided in their explicit form.
The variable type.
Lower boundary of the decision space.
Upper boundary of the decision space.
- property callback: Callable | None#
A callback function to be called after every evaluation.
- property data: dict#
Type of the variable to be evaluated.
- property decn_space: ndarray | None#
Decision space boundaries.
- property decn_space_lower: ndarray | None#
Lower boundary of the decision space.
- property decn_space_upper: ndarray | None#
Upper boundary of the decision space.
- property elementwise: bool#
Whether the evaluation function should be run elementwise.
- property elementwise_func: type#
A class that creates the function that evaluates a single individual.
- property elementwise_runner: Callable#
A function that runs the function that evaluates a single individual.
- property eqcv_wt: ndarray#
Equality constraint violation function weights.
- abstract evalfn(x, *args, **kwargs)#
Evaluate a candidate solution for the given Problem.
This calculates three vectors which are to be minimized:
\[\mathbf{v_{obj}} = \mathbf{w_{obj} \odot F_{obj}(x)} \ \mathbf{v_{ineqcv}} = \mathbf{w_{ineqcv} \odot G_{ineqcv}(x)} \ \mathbf{v_{eqcv}} = \mathbf{w_{eqcv} \odot H_{eqcv}(x)}\]- Parameters:
x (numpy.ndarray) – A candidate solution vector of shape
(ndecn,).args (tuple) – Additional non-keyword arguments.
kwargs (dict) – Additional keyword arguments.
- Returns:
out – A tuple
(obj, ineqcv, eqcv).Where:
objis a numpy.ndarray of shape(nobj,)that containsobjective function evaluations.
ineqcvis a numpy.ndarray of shape(nineqcv,)that containsinequality constraint violation values.
eqcvis a numpy.ndarray of shape(neqcv,)that containsequality constraint violation values.
- Return type:
tuple
- property exclude_from_serialization: Iterable | None#
attributes which are excluded from being serialized.
- property ineqcv_wt: ndarray#
Inequality constraint violation function weights.
- property n_eq_constr: Integral#
n_eq_constr.
- property n_ieq_constr: Integral#
Number of inequality constraints.
- property n_obj: Integral#
Number of objectives.
- property n_var: Integral#
Number of decision variables.
- property ndecn: Integral#
Number of decision variables.
- property neqcv: Integral#
Number of equality constraint violations.
- property nineqcv: Integral#
Number of inequality constraint violation functions.
- property nobj: Integral#
Number of objectives.
- property obj_wt: ndarray#
Objective function weights.
- property replace_nan_values_by: Real | None#
replace_nan_values_by.
- property strict: bool#
Whether the shapes are checked strictly.
- property vars: Container | None#
Variables provided in their explicit form.
- property vtype: type | None#
The variable type. So far, just used as a type hint.
- property xl: ndarray | None#
Lower boundary of the decision space.
- property xu: ndarray | None#
Upper boundary of the decision space.