| 32 | |
| 33 | |
| 34 | class Problem: |
| 35 | def __init__( |
| 36 | self, |
| 37 | n_var=-1, |
| 38 | n_obj=1, |
| 39 | n_ieq_constr=0, |
| 40 | n_eq_constr=0, |
| 41 | xl=None, |
| 42 | xu=None, |
| 43 | vtype=None, |
| 44 | vars=None, |
| 45 | elementwise=False, |
| 46 | elementwise_func=ElementwiseEvaluationFunction, |
| 47 | elementwise_runner=LoopedElementwiseEvaluation(), |
| 48 | requires_kwargs=False, |
| 49 | replace_nan_values_by=None, |
| 50 | exclude_from_serialization=None, |
| 51 | callback=None, |
| 52 | strict=True, |
| 53 | **kwargs, |
| 54 | ): |
| 55 | """Initialize a Problem. |
| 56 | |
| 57 | Args: |
| 58 | n_var: Number of variables. |
| 59 | n_obj: Number of objectives. |
| 60 | n_ieq_constr: Number of inequality constraints. |
| 61 | n_eq_constr: Number of equality constraints. |
| 62 | xl: Lower bounds for variables (float/int/array). |
| 63 | xu: Upper bounds for variables (float/int/array). |
| 64 | vtype: Variable type hint. |
| 65 | vars: Variables in explicit form. |
| 66 | elementwise: Whether to use elementwise evaluation. |
| 67 | elementwise_func: Function for elementwise evaluation. |
| 68 | elementwise_runner: Runner for elementwise evaluation. |
| 69 | requires_kwargs: Whether evaluation requires kwargs. |
| 70 | replace_nan_values_by: Value to replace NaN with. |
| 71 | exclude_from_serialization: Attributes to exclude from serialization. |
| 72 | callback: Callback function after each evaluation. |
| 73 | strict: Whether to check shapes strictly. |
| 74 | **kwargs: Additional keyword arguments. |
| 75 | """ |
| 76 | # number of variable |
| 77 | self.n_var = n_var |
| 78 | |
| 79 | # number of objectives |
| 80 | self.n_obj = n_obj |
| 81 | |
| 82 | # number of inequality constraints |
| 83 | self.n_ieq_constr = ( |
| 84 | n_ieq_constr |
| 85 | if "n_constr" not in kwargs |
| 86 | else max(n_ieq_constr, kwargs["n_constr"]) |
| 87 | ) |
| 88 | |
| 89 | # number of equality constraints |
| 90 | self.n_eq_constr = n_eq_constr |
| 91 | |